-
Notifications
You must be signed in to change notification settings - Fork 22
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
Define glpk launcher and expose command line and api option #112
Conversation
pyreisejl/utility/call.py
Outdated
launch_map = {"gurobi": GurobiLauncher, "glpk": GLPKLauncher} | ||
if solver is None: | ||
return GurobiLauncher | ||
return launch_map[solver] |
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.
Should we provide a meaningful exception in case the user specifies something besides the keys in launch_map
?
Should we allow a little more flexibility so that strings like "Gurobi"
or "GLPK"
still resolve successfully?
Should we define launch_map
within the body of launchers.py so that we can do a single import?
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.
Affirmative, all good ideas. I probably could have made this a draft PR since it's a bit rough currently.
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 like where it's headed so far.
pyreisejl/utility/parser.py
Outdated
parser.add_argument( | ||
"--solver", | ||
help="Specify the solver to run the optimization. Will default to gurobi", | ||
) |
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.
If we define launch_map
within launchers.py, does that let us do something like automatically populate the help string with a list of valid keys?
runtime = round(end - start) | ||
hours, minutes, seconds = sec2hms(runtime) | ||
print(f"Run time: {hours}:{minutes:02d}:{seconds:02d}") | ||
|
||
return runtime |
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.
If we want to maximize our DRY, we could define a round_and_print_runtime
method of the Launcher
class and then call return self.round_and_print_runtime(start, end)
, but it's not really necessary.
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.
Yeah I wanted to reuse the code here but since it's interleaved it felt like the result would be harder to read. If we end up adding more solvers I would want to do something about it.
The code looks good. Has it been tested? |
Yeah, just manual tests in a container - checked with invalid solver and completed a simulation with glpk |
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.
Looks good, thanks!
Purpose
Add new
--solver
parameter (and corresponding query string) which can currently be eithergurobi
orglpk
. This enables running a simulation in test scenarios where a license is not available.What it does
call.py
relatively cleanTime to review
10 min