-
Notifications
You must be signed in to change notification settings - Fork 4
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
Cache And Reuse Solution Values Across Solver Invocations #66
Conversation
…al value available
@@ -162,6 +162,11 @@ void GurobiSolver::translateModel() { | |||
TETRISCHED_DEBUG("Adding variable " << variable->getName() << "(" | |||
<< variableId << ") to Gurobi Model."); | |||
gurobiVariables[variableId] = translateVariable(*gurobiModel, variable); | |||
// Give the Gurobi variable an initial solution value if it is available. | |||
if (variable->getInitialValue().has_value()) { | |||
gurobiVariables[variableId].set(GRB_DoubleAttr_Start, variable->getInitialValue().value()); |
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 feel like it would be better if I set start attribute for gurobi variables inside translateVariable
? Let me know if you think so and I can change it
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.
Yep, that would be ideal!
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.
LGTM. Minor changes, let me know if you want me to take them on!
For the logging issue, just set TETRISCHED_DEBUG_ENABLED
to false
in Types.hpp
. :)
@@ -162,6 +162,11 @@ void GurobiSolver::translateModel() { | |||
TETRISCHED_DEBUG("Adding variable " << variable->getName() << "(" | |||
<< variableId << ") to Gurobi Model."); | |||
gurobiVariables[variableId] = translateVariable(*gurobiModel, variable); | |||
// Give the Gurobi variable an initial solution value if it is available. | |||
if (variable->getInitialValue().has_value()) { | |||
gurobiVariables[variableId].set(GRB_DoubleAttr_Start, variable->getInitialValue().value()); |
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.
Yep, that would be ideal!
…obiSolver::translateVariable
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.
LGTM
Summary
This PR introduces functionality to retain the solution values of variables from the previous invocation of the solver. These values are stored in a cache that persists between solver runs.
When a new variable is added to the solver model, addition logic now checks whether a solution value for a variable with the same name exists in the cache. If a cached value exists, it sets this value as the initial hint for the variable.
Test Plan
Pass unit test
Output for
./test_tetrisched
: https://app.warp.dev/block/j3sg3Urzyn1EIfns9CkQsYCan run
python3 main.py --flagfile=configs/new_av_workload.conf
with debug enabledThere are too many debug statements being printed and it's hard to capture ones that are relevant to this PR. So I just record a short video instead : )
Screen.Recording.2023-11-05.at.6.15.34.PM.mov