Skip to content

Commit

Permalink
Merge pull request #3422 from jsiirola/xpress-typo
Browse files Browse the repository at this point in the history
xpress_direct: resolve error retrieving reduced costs
  • Loading branch information
blnicho authored Nov 18, 2024
2 parents 9b95aad + 03ec9d2 commit ed495d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyomo/solvers/plugins/solvers/xpress_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ def _load_rc(self, vars_to_load=None):
vars_to_load = var_map.keys()

xpress_vars_to_load = [var_map[pyomo_var] for pyomo_var in vars_to_load]
vals = self._getRedCost(self._solver_model, xpress_vars_to_load)
vals = self._getRedCosts(self._solver_model, xpress_vars_to_load)

for var, val in zip(vars_to_load, vals):
if ref_vars[var] > 0:
Expand Down
13 changes: 13 additions & 0 deletions pyomo/solvers/tests/checks/test_xpress_persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ def test_basics(self):
res = opt.solve()
self.assertAlmostEqual(m.x.value, -0.4, delta=1e-6)
self.assertAlmostEqual(m.y.value, 0.2, delta=1e-6)

opt.load_duals()
self.assertEqual(len(m.dual), 1)
self.assertAlmostEqual(m.dual[m.c1], -0.4, delta=1e-6)
del m.dual

opt.load_rc()
self.assertEqual(len(m.rc), 2)
self.assertAlmostEqual(m.rc[m.x], 0, delta=1e-8)
self.assertAlmostEqual(m.rc[m.y], 0, delta=1e-8)
del m.rc

opt.load_slacks()
self.assertEqual(len(m.slack), 1)
self.assertAlmostEqual(m.slack[m.c1], 0, delta=1e-6)
del m.slack

m.c2 = pe.Constraint(expr=m.y >= -m.x + 1)
opt.add_constraint(m.c2)
self.assertEqual(opt.get_xpress_attribute('cols'), 2)
Expand Down

0 comments on commit ed495d6

Please sign in to comment.