Got different results on different laptop
AnsweredFirstly, I use the GitHub to sync my code and data (1000 instances of VRPTW), so they are the same.
Then I solved these instances by 2 laptops, one Thinkpad and one Dell. It's so weird that on a few instances I got different results (routes) from different laptops. But I expected I can get the same results over all the instances, no matter when or on which computer.
The results look like this (reward is the obj_value):
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
There are a few things that can lead to different results:
- The models may not be identical
- Both solutions may be optimal with respect to the MIP gap or other tolerances
- You have a time limit
To debug this, you should look at the full Gurobi logs, and export the models in MPS format to ensure they are identical.
1 -
As Greg said, I finally located the bug is on the tolerances issue.
In my code (python) I set the tolerances like this
# Limits the GAP (default 1e-4).
m.Params.MIPGap =1e-4
# set tolerance
m.Params.IntFeasTol = 1e-9
m.Params.FeasibilityTol = 1e-9I save the model in lp format, which the params above are not included.
Then on both laptops, I read and solved the lp format model and get the same results.
the version of python is different on my 2 laptops, I think maybe that cause some numerical problem.
0 -
Hi Yanfei,
please be aware that the MPS file format offers a more accurate precision than the lp file format. You should try to save your model as MPS if numerics might be troublesome.
That being said, as far as I know gurobi is deterministic on the same machine but not between different machines. So you should expect the same model to give you the same result on the same machine every time you solve it, but if you switch machines the results (as well as the solving times) might vary.
As you already found out the problem here looks like some numerical issues. Do you have the same operating system on both machines? And which python versions do you use (there are some differences between python 2 and 3)?
0
Post is closed for comments.
Comments
4 comments