メインコンテンツへスキップ

Finding multiple feasible solutions using JuMP in julia

ユーザーの入力を待っています。

コメント

4件のコメント

  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Do I understand correctly that the difference is only in the objective function, but you get a different number of solutions? Did you also set the parameter PoolGap or PoolGapAbs?

    Can you share the log files for both runs?

    0
  • Marloes Remijnse
    Gurobi-versary
    First Question
    First Comment

    Dear Marika,

    Yes, I only adapt the objective function and then get a different number of solutions.
    I did not set either of the parameters for PoolGap or PoolGapAbs. Would you propose to do so?

    This is the solution summary for objective A:

    Number of solutions found: 1
    JuMP.solution_summary(m) = * Solver : Gurobi

    * Status
      Result count       : 1
      Termination status : OPTIMAL
      Message from the solver:
      "Model was solved to optimality (subject to tolerances), and an optimal solution is available."

    * Candidate solution (result #1)
      Primal status      : FEASIBLE_POINT
      Dual status        : NO_SOLUTION
      Objective value    : -4.16673e-14
      Objective bound    : -4.16673e-14
      Relative gap       : 0.00000e+00
      Dual objective value : -4.16673e-14

    * Work counters
      Solve time (sec)   : 8.66302e-01
      Barrier iterations : 0
      Node count         : 1


    And this is the solution summary for objective B:

    Number of solutions found: 3
    JuMP.solution_summary(m) = * Solver : Gurobi

    * Status
      Result count       : 3
      Termination status : OPTIMAL
      Message from the solver:
      "Model was solved to optimality (subject to tolerances), and an optimal solution is available."

    * Candidate solution (result #1)
      Primal status      : FEASIBLE_POINT
      Dual status        : NO_SOLUTION
      Objective value    : 9.24702e+02
      Objective bound    : 9.24702e+02
      Relative gap       : 0.00000e+00
      Dual objective value : 9.24702e+02

    * Work counters
      Solve time (sec)   : 1.12726e+00
      Barrier iterations : 0
      Node count         : 1
    0
  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi Marloes,

    I am not so familiar with Julia. Could you make sure that the parameter PoolSearchMode is active in your run?
    I tested some Julia code I found here:

    using JuMP, Gurobi
    m = Model(optimizer_with_attributes(Gurobi.Optimizer, "PoolSearchMode"=>2, "PoolSolutions" => 1000))
    @variables(m,begin
    0 <= x <= 5
    0 <= y <= 10, Int
    z, Bin
    zz, Bin
    end)
    @objective(m, Max, x + 2y + 5*(z+zz))
    @constraint(m, x + y + z + zz<= 10)
    @constraint(m, x + 2y + z + zz <= 15)
    @constraint(m, z + zz <= 1)
    optimize!(m)

    This produces the following output

    Set parameter PoolSearchMode to value 2
    Set parameter PoolSolutions to value 1000
    Gurobi Optimizer version 11.0.3 build v11.0.3rc0 (win64 - Windows 10.0 (19045.2))
    
    CPU model: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz, instruction set [SSE2|AVX|AVX2|AVX512]
    Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
    
    Optimize a model with 3 rows, 4 columns and 10 nonzeros
    Model fingerprint: 0xea01b6e5
    Variable types: 1 continuous, 3 integer (2 binary)
    Coefficient statistics:
      Matrix range     [1e+00, 2e+00]
      Objective range  [1e+00, 5e+00]
      Bounds range     [5e+00, 1e+01]
      RHS range        [1e+00, 2e+01]
    Found heuristic solution: objective 15.0000000
    Presolve time: 0.01s
    Presolved: 3 rows, 4 columns, 10 nonzeros
    Variable types: 1 continuous, 3 integer (2 binary)
    Found heuristic solution: objective 18.0000000
    
    Root relaxation: objective 1.900000e+01, 3 iterations, 0.00 seconds (0.00 work units)
    
        Nodes    |    Current Node    |     Objective Bounds      |     Work
     Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
    
    *    0     0               0      19.0000000   19.00000  0.00%     -    0s
    
    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          -    0               -   19.00000      -     -    0s
         0     0          -    0               -   19.00000      -     -    0s
         0     2          -    0               -   19.00000      -     -    0s
    
    Explored 47 nodes (10 simplex iterations) in 0.03 seconds (0.00 work units)
    Thread count was 8 (of 8 available processors)
    
    Solution count 24: 19 19 19 ... 5
    No other solutions better than 5

    Here, you can see the line

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

    Can you verify this also happen in your runs?

    0
  • Marloes Remijnse
    Gurobi-versary
    First Question
    First Comment

    Dear Marika,

    Thank you for the suggestion to check if the parameter is correctly activated. Thanks to that I noticed that I set the parameters within an if-statement that did not hold. Adapting this made the parameters active and I now obtain an equal number of solutions!

    Thank you for your help!

    0

サインインしてコメントを残してください。