@@ -53,13 +53,6 @@ def __init__(self, spbase_object, fullcomm, strata_comm, cylinder_comm, communic
53
53
def setup_hub (self ):
54
54
pass
55
55
56
- @abc .abstractmethod
57
- def sync (self ):
58
- """ To be called within the whichever optimization algorithm
59
- is being run on the hub (e.g. PH)
60
- """
61
- pass
62
-
63
56
@abc .abstractmethod
64
57
def is_converged (self ):
65
58
""" The hub has the ability to halt the optimization algorithm on the
@@ -167,37 +160,32 @@ def determine_termination(self):
167
160
return abs_gap_satisfied or rel_gap_satisfied or max_stalled_satisfied
168
161
169
162
def hub_finalize (self ):
170
- self .receive_outerbounds ()
171
- self .receive_innerbounds ()
163
+ self .update_receive_buffers ()
164
+ self .update_outerbounds ()
165
+ self .update_innerbounds ()
172
166
173
167
if self .global_rank == 0 :
174
168
self .print_init = True
175
169
global_toc ("Statistics at termination" , True )
176
170
self .screen_trace ()
177
171
178
- def receive_innerbounds (self ):
179
- """ Get inner bounds from inner bound spokes
180
- NOTE: Does not check if there _are_ innerbound spokes
181
- (but should be harmless to call if there are none)
172
+ def update_innerbounds (self ):
173
+ """ Update the inner bounds after receiving them from the spokes
182
174
"""
183
- logging .debug ("Hub is trying to receive from InnerBounds" )
175
+ logging .debug ("Hub is trying to update from InnerBounds" )
184
176
for idx , cls , recv_buf in self .receive_field_spcomms [Field .OBJECTIVE_INNER_BOUND ]:
185
- is_new = self .get_receive_buffer (recv_buf , Field .OBJECTIVE_INNER_BOUND , idx )
186
- if is_new :
177
+ if recv_buf .is_new ():
187
178
bound = recv_buf [0 ]
188
179
logging .debug ("!! new InnerBound to opt {}" .format (bound ))
189
180
self .BestInnerBound = self .InnerBoundUpdate (bound , cls , idx )
190
181
logging .debug ("ph back from InnerBounds" )
191
182
192
- def receive_outerbounds (self ):
193
- """ Get outer bounds from outer bound spokes
194
- NOTE: Does not check if there _are_ outerbound spokes
195
- (but should be harmless to call if there are none)
183
+ def update_outerbounds (self ):
184
+ """ Update the outer bounds after receiving them from the spokes
196
185
"""
197
- logging .debug ("Hub is trying to receive from OuterBounds" )
186
+ logging .debug ("Hub is trying to update from OuterBounds" )
198
187
for idx , cls , recv_buf in self .receive_field_spcomms [Field .OBJECTIVE_OUTER_BOUND ]:
199
- is_new = self .get_receive_buffer (recv_buf , Field .OBJECTIVE_OUTER_BOUND , idx )
200
- if is_new :
188
+ if recv_buf .is_new ():
201
189
bound = recv_buf [0 ]
202
190
logging .debug ("!! new OuterBound to opt {}" .format (bound ))
203
191
self .BestOuterBound = self .OuterBoundUpdate (bound , cls , idx )
@@ -320,17 +308,19 @@ def sync(self):
320
308
self .send_ws ()
321
309
self .send_nonants ()
322
310
self .send_boundsout ()
323
- self .receive_outerbounds ()
324
- self .receive_innerbounds ()
311
+ self .update_receive_buffers ()
312
+ self .update_outerbounds ()
313
+ self .update_innerbounds ()
325
314
if self .opt .extensions is not None :
326
315
self .opt .extobject .sync_with_spokes ()
327
316
328
317
def sync_with_spokes (self ):
329
318
self .sync ()
330
319
331
320
def sync_bounds (self ):
332
- self .receive_outerbounds ()
333
- self .receive_innerbounds ()
321
+ self .update_receive_buffers ()
322
+ self .update_outerbounds ()
323
+ self .update_innerbounds ()
334
324
self .send_boundsout ()
335
325
336
326
def sync_extensions (self ):
@@ -431,8 +421,9 @@ def sync(self, send_nonants=True):
431
421
"""
432
422
if send_nonants :
433
423
self .send_nonants ()
434
- self .receive_outerbounds ()
435
- self .receive_innerbounds ()
424
+ self .update_receive_buffers ()
425
+ self .update_innerbounds ()
426
+ self .update_outerbounds ()
436
427
# in case LShaped ever gets extensions
437
428
if getattr (self .opt , "extensions" , None ) is not None :
438
429
self .opt .extobject .sync_with_spokes ()
0 commit comments