Skip to content

Commit 3de100e

Browse files
Merge pull request #429 from Pyomo/newiter0callback
Adding iter0_post_solver_creation callback to extensions object
2 parents d836482 + abb8e36 commit 3de100e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Diff for: mpisppy/extensions/extension.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,18 @@ def post_solve_loop(self):
9393
pass
9494

9595
def pre_iter0(self):
96-
''' Method called at the end of PH_Prep().
97-
When this method is called, all scenarios have been created, and
96+
''' When this method is called, all scenarios have been created, and
9897
the dual/prox terms have been attached to the objective, but the
9998
solvers have not yet been created.
10099
'''
101100
pass
102101

102+
def iter0_post_solver_creation(self):
103+
''' When this method is called, PH iteration 0 has been initiated and
104+
all solver objects have been created.
105+
'''
106+
pass
107+
103108
def post_iter0(self):
104109
''' Method called after the first PH iteration.
105110
When this method is called, one call to solve_loop() has been

Diff for: mpisppy/phbase.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,7 @@ def PH_Prep(
772772
773773
Note:
774774
This function constructs an Extension object if one was specified
775-
at the time the PH object was created. It also calls the
776-
`pre_iter0` method of the Extension object.
775+
at the time the PH object was created.
777776
"""
778777

779778
self.attach_Ws_and_prox()
@@ -832,9 +831,10 @@ def Iter0(self):
832831
stochastic program with the nonanticipativity constraints
833832
removed.
834833
"""
834+
835835
if (self.extensions is not None):
836836
self.extobject.pre_iter0()
837-
837+
838838
verbose = self.options["verbose"]
839839
dprogress = self.options["display_progress"]
840840
dtiming = self.options["display_timing"]
@@ -853,6 +853,9 @@ def _vb(msg):
853853
global_toc("Creating solvers")
854854
self._create_solvers()
855855

856+
if (self.extensions is not None):
857+
self.extobject.iter0_post_solver_creation()
858+
856859
teeme = ("tee-rank0-solves" in self.options
857860
and self.options['tee-rank0-solves']
858861
and self.cylinder_rank == 0

0 commit comments

Comments
 (0)