Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed the documentation from the class docstring. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
capitalized the notations. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Refine test class docstring to clarify focus on critical control-flow and validation.
Refine test description for clarity and focus.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* the test docstring/comment no longer references specific source line numbers.
* unused test attribute (self.number_of_external_variables) removed.
2. Changed ldsda.py:
* update the wording to “squared Euclidean distance” in the comment describing the tiebreaker logic.
…ailure Previously, primal_bound was computed even when the solver returned an unsuccessful termination condition. Now primal_bound is only computed when primal_improved is True, making the behavior consistent with the docstring that states primal_bound is None when the subproblem is infeasible.
Replace tabulate-based reformulation summary with simple logger output, consistent with other GDPopt solvers. This avoids adding an unnecessary dependency to the package.
Removed the tabulate dependency and replaced it with simple logger output. Fixed _solve_GDP_subproblem so primal_bound is None when the solver fails (not just on preprocessing infeasibility).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix/ldsda fix
|
@bernalde could you give the Pyomo team edit permissions on this PR? Should be a checkbox at the bottom of the right side information summary about "Allowing maintainers to edit this pull request". |
|
Oh no, since this is coming from the SECQUOIA fork I can’t do that https://github.com/orgs/community/discussions/5634 |
emma58
left a comment
There was a problem hiding this comment.
Thank you for fixing the bug and adding so many tests! I put several comments in, but nothing needs to hold up the PR other than that I think you are missing assertions in one test, and there's on import that is inside of a test. The rest is all just preference and some design ideas that are totally optional.
| with self.assertRaisesRegex( | ||
| ValueError, "should be a list of ExactlyExpression" | ||
| ): | ||
| self.solver._get_external_information(self.model.util_block, self.config) |
There was a problem hiding this comment.
Same question about testing private methods here (and in the tests following as well.)
Ok, no problem. I didn't know about that limitation. We'll work with this PR, no need to reopen it from a personal fork. |
…s, make get_external_information public - Add DirectionNorm enum (L2, Linf) with backward compatibility for string values - Add SearchPhase enum (INITIAL, NEIGHBOR, LINE) for search type - Rename _get_external_information to get_external_information (public API) - Update all usages and tests accordingly
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3830 +/- ##
==========================================
+ Coverage 89.73% 89.75% +0.01%
==========================================
Files 904 904
Lines 105870 105885 +15
==========================================
+ Hits 95005 95035 +30
+ Misses 10865 10850 -15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emma58
left a comment
There was a problem hiding this comment.
A couple comments on the change to enums, but otherwise this looks good to me!
| The dimensionality of the neighborhood (number of external variables). | ||
| config : ConfigBlock | ||
| GDPopt configuration block | ||
| The configuration block specifying the norm ('L2' or 'Linf'). |
There was a problem hiding this comment.
You probably want to update this docstring to reference your new DirectionNorm enum.
There was a problem hiding this comment.
My apologies for the late response. It is a good point. Since DirectionNorm is a str-Enum, the legacy == 'L2'/'Linf' checks would work with either enum or string inputs. The explicit tuple membership check was retained mainly to make it visually clear that both DirectionNorm values and legacy string inputs are accepted. I am happy to simplify it if you'd prefer.
There was a problem hiding this comment.
I personally think simplifying it is better, and that you should encourage users to use the enum rather than relying on string arguments. We get burned relying on strings a lot and have been trying to move away from it. But I'm not opposed to this going in as is if that's your preference.
There was a problem hiding this comment.
(Though I do think you may as well make the reversions in the comments below to just check the equality like before.)
pyomo/contrib/gdpopt/ldsda.py
Outdated
| if config.direction_norm == 'L2': | ||
| if config.direction_norm in (DirectionNorm.L2, 'L2'): |
There was a problem hiding this comment.
Since you set the value of the enum to be the string, the old version should work in either case.
There was a problem hiding this comment.
Since DirectionNorm is a str-Enum, another clean option would be to normalize once using norm = str(config.direction_norm) and then compare against the string values. This keeps compatibility with legacy string inputs while avoiding redundant membership checks.
Something like,
norm = str(config.direction_norm)
if norm == 'L2':
...
elif norm == 'Linf':
...There was a problem hiding this comment.
You don't need to cast it to a string--it's already a string. You can just make this line:
if config.direction_norm == DirectionNorm.L2
(This works because DirectionNorm.L2 == 'L2')
There was a problem hiding this comment.
(Sorry, just realized my original comment was confusing. What I meant is above.)
pyomo/contrib/gdpopt/ldsda.py
Outdated
| elif config.direction_norm == 'Linf': | ||
| elif config.direction_norm in (DirectionNorm.Linf, 'Linf'): |
There was a problem hiding this comment.
Same comment here: Since you set the value of the enum to be the string, the old version should work in either case.
There was a problem hiding this comment.
If normalizing the DirectionNorm using norm = str(config.direction_norm) is a good idea, I will implement it.
|
@bernalde or @AlbertLee125 could you reply to Emma's review comments or mark them resolved if there isn't anything to be done? |
|
My apologies for the late response. It is a good point. Since |
|
I applied the suggested change. Backward compatibility remains intact. Thank you very much for your kind instruction. |
| from pyomo.environ import ( | ||
| SolverFactory, | ||
| value, | ||
| Var, | ||
| Constraint, | ||
| TransformationFactory, | ||
| ConcreteModel, | ||
| BooleanVar, | ||
| LogicalConstraint, | ||
| Block, | ||
| ) |
There was a problem hiding this comment.
@AlbertLee125 this looks like a bad merge. You lost some of the imports required for this test.
There was a problem hiding this comment.
Thanks for pointing that out. It was a merge issue on my side. I restored the missing imports.
|
Jenkins failure is unrelated (it's an intermittent cuOpt failure). This is safe to merge. |
Fixes # .
Summary/Motivation:
Changes proposed in this PR:
tabulatepackage from ldsda and use simple logger output instead.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: