Repository navigation
Conversation
Exercise continuous, mixed-integer, and local node dispatch with GLPK and Ipopt. Remove the unrelated MindtPy change and its vacuous mock-based regression.
…relaxed-nlp-solver
emma58
left a comment
There was a problem hiding this comment.
This mostly looks good--a few comments below. I'm not sure if you're testing what you want to though... Maybe adding some solver-specific arguments would both exercise that code and actually ensure you're calling the solvers you think you are?
| def test_continuous_node_subproblem_uses_relaxed_nlp_solver(self): | ||
| m = ConcreteModel() | ||
| m.x = Var(bounds=(0, 2), initialize=1.5) | ||
| m.obj = Objective(expr=(m.x - 1) ** 2) | ||
|
|
||
| solver = self._make_lbb_solver(m) | ||
| config = self._make_config(solver, relaxed_nlp_solver='ipopt') | ||
| solver._solve_rnGDP_subproblem(m, config) | ||
|
|
||
| self.assertAlmostEqual(value(m.x), 1.0, places=6) | ||
|
|
||
| def test_continuous_node_subproblem_defaults_to_minlp_solver(self): | ||
| m = ConcreteModel() | ||
| m.x = Var(bounds=(1, 2)) | ||
| m.obj = Objective(expr=m.x) | ||
|
|
||
| solver = self._make_lbb_solver(m) | ||
| config = self._make_config(solver) | ||
| solver._solve_rnGDP_subproblem(m, config) | ||
|
|
||
| self.assertAlmostEqual(value(m.x), 1.0) |
There was a problem hiding this comment.
I don't see how these tests test the solver you're using. They just check that you get the right answer both times and that the second time you get it exactly.
There was a problem hiding this comment.
Added solver-specific options and checks on the solver output. I also changed the mixed-integer test because FBBT was fixing its binary variable before dispatch.
| def test_continuous_local_node_subproblem_uses_relaxed_nlp_solver(self): | ||
| m = ConcreteModel() | ||
| m.x = Var(bounds=(0, 2), initialize=1.5) | ||
| m.obj = Objective(expr=(m.x - 1) ** 2) | ||
|
|
||
| solver = self._make_lbb_solver(m) | ||
| config = self._make_config(solver, relaxed_nlp_solver='ipopt') | ||
| solver._solve_local_rnGDP_subproblem(m, config) | ||
|
|
||
| self.assertAlmostEqual(value(m.x), 1.0, places=6) |
There was a problem hiding this comment.
The local tests now check the solver output too. They use different GLPK options from the global tests to check that the local arguments are used.
| discrete_solver = getattr(config, discrete_solver_name) | ||
| discrete_solver_args_name = discrete_solver_name + "_args" | ||
| discrete_solver_args = dict(getattr(config, discrete_solver_args_name)) |
There was a problem hiding this comment.
Just a style thing, but rather than manipulating strings to get the right config options, why not just pass discrete_solver and discrete_solver_args as arguments to this method: They're much more straightforward to get in the scope in which you're calling this rather than here.
There was a problem hiding this comment.
Both callers now pass discrete_solver and discrete_solver_args directly.
| "Transformed node subproblem has unfixed discrete variables: %s. " | ||
| "Solving with mixed-integer solver %s." | ||
| % (", ".join(v.name for v in unfixed_discrete_vars), discrete_solver) |
There was a problem hiding this comment.
I'm not sure it's wise to log the name of every unfixed discrete variable. That could be quite a large number of Vars depending on the problem.
There was a problem hiding this comment.
Removed the variable names from the debug message.
|
@bernalde could you address Emma's comments, resolve the conflicts, and merge main into this PR? |
Pass mixed-integer solver settings explicitly and keep node debug output bounded. Verify real Ipopt and GLPK selection and per-role options, including local screening and fixed discrete variables. Copy GAMS options before applying per-node time limits.
Fixes #3945.
Summary/Motivation:
GDPopt LBB routes every transformed node subproblem through
minlp_solver(orlocal_minlp_solverfor optional local screening), even at nodes where every discrete variable has already been fixed by branching. Those nodes are continuous NLPs, so sending them to a MINLP solver is unnecessary and forces users to have a MINLP solver configured for work a continuous NLP solver could do.This adds an explicit, opt-in solver role for that case rather than changing the default dispatch, so existing LBB configurations keep their current global-bounding behavior.
This is a replacement for #3946, which GitHub would not allow me to reopen after it was closed. The prior discussion and history remain available there.
Changes proposed in this PR:
relaxed_nlp_solverandrelaxed_nlp_solver_argsonGDP_LBB_Solver.CONFIGinpyomo/contrib/gdpopt/branch_and_bound.py, for transformed node subproblems with no unfixed discrete variables._get_rnGDP_subproblem_solver(), which reuses GDPopt's existingdetect_unfixed_discrete_vars()helper to choose between the relaxed NLP solver and the mixed-integer node solver, and logs which one it picked.relaxed_nlp_solveris unset: such nodes continue to go tominlp_solver/local_minlp_solver.reslimtime-limit handling into_apply_rnGDP_subproblem_time_limit()so it applies to whichever subsolver is dispatched.pyomo/contrib/mindtpy/algorithm_base_class.pyto test for no unfixed discrete variables rather than an empty discrete variable list, and update the surrounding docstring.TestGDPoptLBBNodeSolverDispatchinpyomo/contrib/gdpopt/tests/test_LBB.pyand a MindtPy GOA fixed-discrete routing regression inpyomo/contrib/mindtpy/tests/test_mindtpy_no_discrete.py.main:python -m pytest -q pyomo/contrib/gdpopt/tests/ pyomo/contrib/mindtpy/tests/test_mindtpy_no_discrete.py108 passed, 35 skipped, 5 deselected in 196.51spython -m black --check pyomo/contrib/gdpopt/branch_and_bound.py pyomo/contrib/gdpopt/tests/test_LBB.py pyomo/contrib/mindtpy/algorithm_base_class.py pyomo/contrib/mindtpy/tests/test_mindtpy_no_discrete.py4 files would be left unchangedtypos --config ./.github/workflows/typos.tomlon the four changed filesAI-Use Disclosure
or
AI tools contributed to the development of this PR
Review process (select ONE):
Notes for reviewers (optional): This replacement PR carries over the implementation and tests from #3946 unchanged, then refreshes the branch against current
main. The replacement PR description and branch-refresh workflow were prepared with AI assistance and reviewed before posting.Three things I would like focused feedback on, since this PR is larger than the other GDPopt fixes I have open:
relaxed_nlp_solverdefaults toNonespecifically so that nonconvex nodes keep their current global-bounding behavior. Please confirm that opt-in default is the semantics you want, rather than defaulting to the existingnlp_solver.reslimlogic into_apply_rnGDP_subproblem_time_limit()means the local node screening path now also gets a GAMS time limit applied; previously that path passedlocal_minlp_solver_argsthrough untouched. I believe that is the correct behavior, but it is a behavior change beyond the strict dispatch fix and should be a deliberate decision.len(discrete_variable_list) == 0becoming "no unfixed discrete variables") alters when MindtPy short-circuits to a direct solve. It is needed for consistency with the LBB dispatch rule, but it touches MindtPy rather than GDPopt, so it may warrant a separate reviewer.Related: this PR touches
pyomo/contrib/gdpopt/tests/test_LBB.pynear the same imports as #4010 (replacement for #3942, already approved by @emma58). The runtime changes are independent and do not overlap. I recommend merging #4010 first; I will then rebase this branch and resolve the small test-file conflict.Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: