Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpress_direct: resolve error retrieving reduced costs #3422

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading