-
Notifications
You must be signed in to change notification settings - Fork 6
Example fallback option #1680
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: master
Are you sure you want to change the base?
Example fallback option #1680
Conversation
9690a0b
to
65ca439
Compare
Illustrate how to fallback to a different solver in case the last solver fails. This includes an example with goal programming where the fallback option is applied for each priority.
65ca439
to
41d5d15
Compare
:pyobject: Example.optimize | ||
:lineno-match: | ||
|
||
Here, we iteratore over the solvers `ipopt` and `highs`. |
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.
iteratore --> iterate
|
||
def __init__(self, **kwargs): | ||
self.solver = None | ||
super().__init__(**kwargs) |
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 think this constructor can be removed as it does nothing?
|
||
def __init__(self, **kwargs): | ||
self.solver = "ipopt" # Solver, by default ipopt. | ||
super().__init__(**kwargs) |
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.
Can this constructor be removed?
until one of them succeeds. | ||
* Let your main optimization problem class also inherit from ``MultiRunMixin``. | ||
It is important that ``MultiRunMixin`` comes after ``GoalProgrammingMixin`` | ||
in the inheritance list. |
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 could be an argument for including a dedicated `MultiRunMixin' in the library after all. @jackvreeken thoughts?
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'd say it's fine for now. Order of inheritance is important the other way around as well (with a "helper" in run_optimization_problem
). I don't like "solver workarounds" in the core, but if it proves really useful we can always decide to include it in the library at a later date.
Could you please address Jorn's comments? |
Add an example that illustrates how to implement a fallback option in case a solver fails.