Got different results on different laptop

Answered

Comments

3 comments

  • Greg Glockner

    There are a few things that can lead to different results:

    1. The models may not be identical
    2. Both solutions may be optimal with respect to the MIP gap or other tolerances
    3. 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
    Comment actions Permalink
  • Yanfei Huang

    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-9

    I 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
    Comment actions Permalink
  • Jakob Schelbert

    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
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk