python - GUROBI - 如何与 50 个效率最低的提供商一起运行优化
问题描述
我正在将 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
解决方案
推荐阅读
- powershell - 当使用 PowerShell 不知道结构时如何迭代 HTTP JSON 响应?
- javascript - 有哪些方法可以减少使用工作线程的 NodeJS 程序的内存使用量?
- django - 如何使用 Mongo 引擎在 Point 字段中存储位置并获取位置附近最近的 5 家餐厅
- c - c TCP中的套接字我如何测试连接?
- macos - macos 上是否有 getcwd() 系统调用之类的东西
- ruby - 如何修复 Mac OS Catalina 10.15.4 上的 RVM 安装错误
- javascript - TypeError:无法读取未定义的属性“allMarkdownRemark”(在页面中)
- swiftui - 图像之间的 SwiftUI 文本未正确对齐
- firebase - 在 Firebase Flutter 上更新数组中的项目
- maven - 如何将基于 java 的注释 maven 项目转换为 Spring Boot?