Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python GUROBI-如何使用50个效率最低的提供商运行优化_Python_Mathematical Optimization_Gurobi - Fatal编程技术网

Python GUROBI-如何使用50个效率最低的提供商运行优化

Python GUROBI-如何使用50个效率最低的提供商运行优化,python,mathematical-optimization,gurobi,Python,Mathematical Optimization,Gurobi,我正在使用Python和Gurobi解算器。我正在解决一个混合整数优化问题,我正试图得到50个效率最低的供应商的优化结果。但我得到了47个供应商的结果,而不是预期的50个。 如何运行此优化以实现相同的目标 我试图优化至少50个低效率提供者的代码片段 model.addConstr(quicksum(df_Eff_Spend_p['Tier_Status']), GRB.GREATER_EQUAL, 50) model.update() Efficiency = df_Eff_Spen

我正在使用Python和Gurobi解算器。我正在解决一个混合整数优化问题,我正试图得到50个效率最低的供应商的优化结果。但我得到了47个供应商的结果,而不是预期的50个。 如何运行此优化以实现相同的目标

我试图优化至少50个低效率提供者的代码片段

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()

Gurobi解决方案的输出如下所示-

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
用于检查网络中有多少用户的代码-

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 )  

网络中所选提供商的总数=47.0


网络中的提供商总数=1121

您如何准确地初始化df_Eff_Spend_p['Tier_Status']?此数据结构是否包含所有1121个变量?如何准确初始化df_Eff_Spend_p[“Tier_Status”]?此数据结构是否包含所有1121变量?