Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbynum committed Feb 23, 2024
1 parent ab1e1c8 commit 97e01d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 1 addition & 4 deletions pyomo/contrib/solver/ipopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def __init__(
)
self.writer_config: ConfigDict = self.declare(
'writer_config',
ConfigValue(
default=NLWriter.CONFIG(),
description="Configuration that controls options in the NL writer.",
),
NLWriter.CONFIG(),
)


Expand Down
12 changes: 10 additions & 2 deletions pyomo/contrib/solver/tests/solvers/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,10 @@ def test_presolve_with_zero_coef(
opt: SolverBase = opt_class()
if not opt.available():
raise unittest.SkipTest(f'Solver {opt.name} not available.')
if use_presolve:
opt.config.writer_config.linear_presolve = True
else:
opt.config.writer_config.linear_presolve = False

"""
when c2 gets presolved out, c1 becomes
Expand All @@ -1539,8 +1543,12 @@ def test_presolve_with_zero_coef(
res = opt.solve(
m, load_solutions=False, raise_exception_on_nonoptimal_result=False
)
if use_presolve:
exp = TerminationCondition.provenInfeasible
else:
exp = TerminationCondition.locallyInfeasible
self.assertEqual(
res.termination_condition, TerminationCondition.provenInfeasible
res.termination_condition, exp
)

m = pe.ConcreteModel()
Expand All @@ -1566,7 +1574,7 @@ def test_presolve_with_zero_coef(
m, load_solutions=False, raise_exception_on_nonoptimal_result=False
)
self.assertEqual(
res.termination_condition, TerminationCondition.provenInfeasible
res.termination_condition, exp
)

@parameterized.expand(input=_load_tests(all_solvers))
Expand Down
2 changes: 1 addition & 1 deletion pyomo/repn/plugins/nl_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ def _linear_presolve(self, comp_by_linear_var, lcon_by_linear_nnz, var_bounds):
id2_isdiscrete = var_map[id2].domain.isdiscrete()
if var_map[_id].domain.isdiscrete() ^ id2_isdiscrete:
# if only one variable is discrete, then we need to
# substiitute out the other
# substitute out the other
if id2_isdiscrete:
_id, id2 = id2, _id
coef, coef2 = coef2, coef
Expand Down

0 comments on commit 97e01d9

Please sign in to comment.