How to run the optimization with 50 lowest efficiency providers

49 views
Skip to first unread message

kamal mustafa

unread,
Mar 19, 2019, 3:46:44 AM3/19/19
to Gurobi Optimization

I am using Python with Gurobi solver. I am solving a mixed integer optimization problem and I am trying to get an optimization result with 50 lowest efficiency providers. But I am getting 47 providers in the result and not 50 as expected. How do I run this optimization to achieve the same?

Code snippet where I am trying to optimize atleast low 50 efficiency providers.


model.addConstr(quicksum(df_Eff_Spend_p['Tier_Status']), GRB.GREATER_EQUAL, 50)
model.update()     
Efficiency  = df_Eff_Spend_p['Efficiency Score'] * df_Eff_Spend_p['Tier_Status']
model.setObjective( Efficiency.sum(), GRB.MINIMIZE)
model.optimize()


The output from the Gurobi solution is as below -

Optimize a model with 1 rows, 1121 columns and 1112 nonzeros
Variable types: 0 continuous, 1121 integer (1121 binary)
Coefficient statistics:
  Matrix range     [1e+00, 2e+02]
  Objective range  [1e-01, 5e+02]
  Bounds range     [1e+00, 1e+00]
  RHS range        [5e+01, 5e+01]
Found heuristic solution: objective 128.2053191
Presolve removed 0 rows and 160 columns
Presolve time: 0.01s
Presolved: 1 rows, 961 columns, 961 nonzeros
Variable types: 0 continuous, 961 integer (819 binary)

Root relaxation: objective 1.978018e+01, 1 iterations, 0.00 seconds

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

     0     0   19.78018    0    1  128.20532   19.78018  84.6%     -    0s
H    0     0                      19.7952723   19.78018  0.08%     -    0s
H    0     0                      19.7823530   19.78018  0.01%     -    0s
     0     0 infeasible    0        19.78235   19.78235  0.00%     -    0s

Explored 1 nodes (1 simplex iterations) in 0.06 seconds
Thread count was 4 (of 4 available processors)

Solution count 3: 19.7824 19.7953 128.205 

Optimal solution found (tolerance 1.00e-04)
Best objective 1.978235301932e+01, best bound 1.978235301932e+01, gap 0.0000%
---**--- Model Details ---**---

Number of Variables       : 1121
Number of Constraints     : 1


---**--- Optimum network ---**---

Total Efficiency          : 19.782


Runtime                   : 0

Code to check how many are in the network -

count_network = 0
count_all = 0
for v in model.getVars ():
    count_network = count_network + v.x
    count_all = count_all + 1
print("The total number of selected providers in the network= ", count_network )
print("The total number of providers in the network= ", count_all )  

The total number of selected providers in the network= 47.0 
The total number of providers in the network= 1121

Silke Horn

unread,
Mar 25, 2019, 10:01:02 AM3/25/19
to gur...@googlegroups.com
Hi,

Could you post a code example to reproduce this?

- Silke
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages