Skip to main content

How I can stop the optimization when I the objectif function is less or equal than a value using (BestBdStop & BestObjStop)?

Answered

Comments

4 comments

  • Eli Towle
    Gurobi Staff Gurobi Staff

    Hi Zakarya,

    In your case, you can simply set the BestObjStop parameter equal to that specific value (plus some small tolerance). How exactly to set this parameter depends on the particular API you're using (see here). E.g., from the command line, you can do:

    gurobi_cl BestObjStop=100.0001 mymodel.mps

    From the Python API, this is done with

    model.params.BestObjStop = 100 + 1e-4

    Does this help? Thanks!

    Eli

    0
  • zakarya guettatfi
    Gurobi-versary
    Curious
    First Comment

    Thank you Eli for the answer,

    Is that mean the code becomes faster so if when the gurobi solver finds an objective less or equal than the BestObjStop value so it stops immediately, and not continues. (the solver is set to minimize).

     

    Zakarya

    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    Hi Zakarya,

    Yes, in general, Gurobi will terminate sooner if you set the BestObjStop parameter to a value greater than the optimal objective function value (for minimization MIPs). However, there are some cases where this doesn't make much difference (e.g., if Gurobi finds a provably optimal solution when the previous incumbent solution was of poor quality).

    Note that you can also direct Gurobi to terminate based on relative optimality gap by setting the MIPGap parameter, or absolute optimality gap by setting the MIPGapAbs parameter. These can be useful if you don't have a good idea of the optimal objective function value beforehand.

    Thanks!

    Eli

    0
  • zakarya guettatfi
    Gurobi-versary
    Curious
    First Comment

    Thanks Eli,

    Zakarya

    0

Please sign in to leave a comment.