Why does my optimization model's solution vary in a for-loop, despite the loop parameter not being in the model?
Awaiting user inputI have the following question. I have created a loop in which a model is solved. Various post-solver calculations are carried out for the varying parameters, whereby the parameter of the for-loop does not occur in the model. But now I have noticed that there are always different model solutions, even if nothing is changed in the model. I can avoid this problem by running the for loop only for the post-solver part and then passing the model that was solved once. I am still interested in why there are different solutions here and whether this can be "switched off" using a model parameter. This is the basic model structure:
m = Model()
for alpha in range(1,10):
Env.alpha = alpha
#### Model Staff
m.optimize
## Post Solve Stuff
-
Hi Karl,
If the same model is solved with the same parameters on the same hardware, the solution path should not change regardless of how many times you solve it. However, traversing the same solution path does not necessarily mean that Gurobi would stop at the same solution point, If you use a non-deterministic termination criterion such as TimeLimit, the exact point in the search tree where Gurobi stops in each run might differ because the exact number of CPU cycles your machine gives to Gurobi might differ in each run depending on the status of the other processes running on your machine.
What termination criteria are you using? In case you are using TimeLimit, you can consider setting the WorkLimit parameter instead which is deterministic.
Env.alpha = alpha
What is the Env object here? Is this a Gurobi Environment object?
Best regards,
Maliheh
0
Please sign in to leave a comment.
Comments
1 comment