diff --git a/pyomo/contrib/solver/ipopt.py b/pyomo/contrib/solver/ipopt.py index 207290a9948..469b964b5cf 100644 --- a/pyomo/contrib/solver/ipopt.py +++ b/pyomo/contrib/solver/ipopt.py @@ -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(), ) diff --git a/pyomo/contrib/solver/tests/solvers/test_solvers.py b/pyomo/contrib/solver/tests/solvers/test_solvers.py index be22048d63f..3b979c6f693 100644 --- a/pyomo/contrib/solver/tests/solvers/test_solvers.py +++ b/pyomo/contrib/solver/tests/solvers/test_solvers.py @@ -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 @@ -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() @@ -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)) diff --git a/pyomo/repn/plugins/nl_writer.py b/pyomo/repn/plugins/nl_writer.py index a53d93c55a6..b3d817fc55b 100644 --- a/pyomo/repn/plugins/nl_writer.py +++ b/pyomo/repn/plugins/nl_writer.py @@ -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