Skip to main content

Can the function PoolSolutions and MIPGap use at the same time?

Answered

Comments

4 comments

  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi,

    If you set the parameter PoolSearchMode to a non-default value, Gurobi tries to find n solutions where n equals PoolSolutions. If the MipGap is reached before n solutions are found, Gurobi continues in order to find additional, high-quality solutions.
    So, you can use both parameters at the same time and Gurobi stops if the MipGap is reached and n solutions are found (if possible).
    If you are not interested in finding exactly 10 solutions you could leave PoolSearchMode at its default value and all solutions found along the way are stored in the solution pool.

    Best regards,
    Marika

    0
  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    Hi Yansong,

    It does work, in the sense that it does not produce an error when used at the same time. In this case, the solver will not terminate until a solution of MIPGap lower than 0.05% is found and all the 9 other solutions in the pool are at most 50% away from this. It may happen that all these conditions cannot be met (e.g. if the model is hard to solve).

    For this reason, I would suggest removing some of the pool settings. In my experience, Gurobi is already pretty good at keeping a good number of solutions automatically. Further from this, there's not much more I can say without the log or .mps file.

    If you want to get the best parameter set for your problem, you can also try out our automatic tuning tool. As I'm guessing you are using YALMIP, to use the tuning tool you can save the model to a file and use the command line option. To save the model to a file from YALMIP, you can use the ResultFile parameter as:

    ops = sdpsettings('solver', 'gurobi', 'gurobi.ResultFile', 'model.mps');

    Cheers, 
    David

    0
  • yansong bai
    Gurobi-versary
    Conversationalist
    Curious

    Thank you very much, Marika and David.

    I just find the output 'xn' has the same value.And the information will not appear while the default MIPGap can appear.

    Optimal solution found at node 0 - now completing solution pool...

        Nodes    |    Current Node    |      Pool Obj. Bounds     |     Work
                 |                    |   Worst                   |
     Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

         0     0 1787.26000    0  337          - 1787.26000      -     -    7s
         0     0 1787.26000    0  364          - 1787.26000      -     -    7s
         0     0 1787.26000    0   27          - 1787.26000      -     -    9s
         0     2 1787.26000    0   27 1844.58000 1787.26000  3.11%     -   10s

    Best regards,
    Yansong

    0
  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    Hi Yansong,

    It appears we are in the case that Marika described. The solver finds the optimal solution very fast (<7s) "before n solutions are found, Gurobi continues in order to find additional, high-quality solutions."

    If these solutions are available, to query them using the variable attribute, Xn, you need to vary the values of the SolutionNumber attribute. This should be between 0 and SolCount.

    Is there any specific reason you need a further 9 solutions as well as the optimal one?
    Just running with default settings, don't specify any pool or other parameters, maybe MIPGap if you like, should terminate fast (in around 7s) as indicated by the first line of the log.

    Cheers, 
    David

    0

Please sign in to leave a comment.