-
Notifications
You must be signed in to change notification settings - Fork 552
New GAMS solver interface, writer, and solution loader. #3683
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
base: main
Are you sure you want to change the base?
Conversation
…ittest and coverage test
@AnhTran01 - Please make sure to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Immediate piece of feedback, recognizing that I have not thoroughly looked over anything - there are no tests anywhere, and there absolutely will need to be some.
Thanks for this, though, I am so excited!!
…riting process. Added WIP unittest for the new solver interface
… and writing to gms.
@@ -518,6 +518,11 @@ def write(self, model): | |||
con_list[label] = declaration + definition + bounds | |||
self.var_symbol_map.addSymbol(obj, label) | |||
|
|||
# Write the GAMS model | |||
ostream.write("$offlisting\n") | |||
# $offdigit ignores extra precise digits instead of erroring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was the error that you were seeing that prompted this addition? maybe something was being set above 1e300
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the previous commit test (b0c3450), the listing file output error message is "Too many digits in number $offdigit can be used to ignore trailing digits"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but do you know what triggered this? which test was causing this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back to check the failed test. The following tests that triggered the "Too many digits error" are:
- TestSolvers.test_equality
- TestSolvers.test_linear_expression
- TestSolvers.test_mutable_param_with_range
- TestSolvers.test_param_changes
- TestSolvers.test_no_objective
- TestSolvers.test_time_limit
- TestLegacySolverInterface.test_param_updates
By testing locally, I see there are trailing decimal places and not the cases of 1e300
or large numbers.
… constraint). Fixed bug of load_solution that contains constraint id in addition to variable id
…arsing solver_options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Some initial comments, mostly on configuration)
pyomo/contrib/solver/solvers/gams.py
Outdated
self.writer_config: ConfigDict = self.declare( | ||
'writer_config', GAMSWriter.CONFIG() | ||
) | ||
# Share the same config as the writer, passes at the function call write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below: this should just insert a copy of the CONFIG from the writer. See Ipopt here for an example.
pyomo/contrib/solver/solvers/gams.py
Outdated
n, | ||
) | ||
|
||
def version(self, config=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our review of the new solver interfaces, we changed the API to:
def version(self, rehash: bool=False) -> Tuple:
Much like available()
, this should leverage a cache (class dict attribute). You can look at the ipopt implementation for an idea (although that hasn't been updated to the new API).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify the purpose of using rehash and whether the user can call rehash
from the solve statement?
I found the documentation here: https://pyomo.readthedocs.io/en/latest/api/pyomo.common.fileutils.PathManager.html
Would the implementation be Executable(config.executable.path()).rehash()
?
pyomo/contrib/solver/solvers/gams.py
Outdated
if config.logfile is not None: | ||
config.logfile = os.path.abspath(config.logfile) | ||
|
||
config.writer_config.put_results_format = 'gdx' if gdxcc_available else 'dat' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably only overwrite the configuration if it is still None (that way users can set / override the interface)
…lable() and version()
…are no longer valid.
…etting default to gdx that caused failed test. Implemented raise infeasible
… rehash handling with Executable.rehash()
…age for infeasible model when calling load_var, dual, reduced_cost
…ded handling solvestat and modelstat when solver is interrupted
@mrmundt is the |
Fixes NA
Summary/Motivation:
This PR introduced a new GAMS solver interface that uses the
LinearRepnVisitor
to enable coefficient gathering when writing out the scalar GAMS model ingms
format.Changes proposed in this PR:
pyomo.contrib.solver.solvers
pyomo.repn.plugins
pyomo.contrib.solver.solvers
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: