Skip to content

Commit b5105c3

Browse files
committed
standarize agnostic to use inner_bound
1 parent b0c00a9 commit b5105c3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

mpisppy/agnostic/ampl_guest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def solve_one(self, Ag, s, solve_keyword_args, gripe, tee=False, need_solution=T
270270
if gripe:
271271
print (f"Solve failed for scenario {s.name} on rank {global_rank}")
272272
print(f"{gs.solve_result =}")
273-
s._mpisppy_data._obj_from_agnostic = None
273+
s._mpisppy_data.inner_bound = None
274274
return
275275

276276
else:
@@ -289,7 +289,7 @@ def solve_one(self, Ag, s, solve_keyword_args, gripe, tee=False, need_solution=T
289289
if gd["sense"] == pyo.minimize:
290290
s._mpisppy_data.outer_bound = objval - mipgap
291291
else:
292-
s._mpisppy_data.inner_bound = objval + mipgap
292+
s._mpisppy_data.outer_bound = objval + mipgap
293293

294294
# copy the nonant x values from gs to s so mpisppy can use them in s
295295
# in general, we need more checks (see the pyomo agnostic guest example)
@@ -311,7 +311,7 @@ def solve_one(self, Ag, s, solve_keyword_args, gripe, tee=False, need_solution=T
311311

312312
s._mpisppy_data.nonant_indices[ndn_i]._value = gxvar.value()
313313

314-
s._mpisppy_data._obj_from_agnostic = objval
314+
s._mpisppy_data.inner_bound = objval
315315

316316

317317
# local helper

mpisppy/agnostic/examples/farmer_gurobipy_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def solve_one(Ag, s, solve_keyword_args, gripe, tee, need_solution=True):
200200
s._mpisppy_data.nonant_indices[ndn_i]._value = grb_var.X
201201

202202
# Store the objective function value in the host scenario
203-
s._mpisppy_data._obj_from_agnostic = objval
203+
s._mpisppy_data.inner_bound = objval
204204

205205
# Additional checks and operations for bundling if needed (depending on the problem)
206206
# ...

mpisppy/agnostic/gams_guest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def solve_one(self, Ag, s, solve_keyword_args, gripe, tee, need_solution=True):
204204
if gripe:
205205
print (f"Solve failed for scenario {s.name} on rank {global_rank}")
206206
print(f"{gs.model_status =}")
207-
s._mpisppy_data._obj_from_agnostic = None
207+
s._mpisppy_data.inner_bound = None
208208
return
209209

210210
if solver_exception is not None and need_solution:
@@ -248,7 +248,7 @@ def solve_one(self, Ag, s, solve_keyword_args, gripe, tee, need_solution=True):
248248
s._mpisppy_data.outer_bound = objval
249249

250250
# the next line ignores bundling
251-
s._mpisppy_data._obj_from_agnostic = objval
251+
s._mpisppy_data.inner_bound = objval
252252

253253
# TBD: deal with other aspects of bundling (see solve_one in spopt.py)
254254
#print(f"For {s.name} in {global_rank=}: {objval=}")

mpisppy/agnostic/pyomo_guest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def solve_one(self, Ag, s, solve_keyword_args, gripe, tee=False, need_solution=T
262262
s._mpisppy_data.nonant_indices[ndn_i]._value = gxvar._value
263263

264264
# the next line ignore bundles (other than proper bundles)
265-
s._mpisppy_data._obj_from_agnostic = pyo.value(sputils.get_objs(gs)[0])
265+
s._mpisppy_data.inner_bound = pyo.value(sputils.get_objs(gs)[0])
266266

267267

268268
# local helper

mpisppy/spopt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def Eobjective(self, verbose=False):
421421
local_Eobjs.append(s._mpisppy_probability * pyo.value(objfct))
422422
else:
423423
# Agnostic will have attached the objective (and doesn't bundle as of Aug 2023)
424-
local_Eobjs.append(s._mpisppy_probability * s._mpisppy_data._obj_from_agnostic)
424+
local_Eobjs.append(s._mpisppy_probability * s._mpisppy_data.inner_bound)
425425
if verbose:
426426
print ("caller", inspect.stack()[1][3])
427427
print ("E_Obj Scenario {}, prob={}, Obj={}, ObjExpr={}"\

0 commit comments

Comments
 (0)