Gurobipy问题:无法将IIS写入.ilp文件

2024-05-14 23:16:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我们正在使用Gurobipy(来自它的Gurobi云产品)。我们正在利用它的IIS feature 来处理不可行性调试

但是Gurobipy无法将IIS写入.ilp文件(即生成一个完全空的文件)

以下是最小可复制代码:

main.py

import gurobipy

my_model = gurobipy.read("my_problem.lp", conf_env())  
# Note: conf_env() is custom func to set secret key

my_model.optimize()
my_model.computeIIS()         
my_model.write('my_iis.ilp')   # Generates an empty file: my_iis.ilp

my_problem.lp

\ENCODING=ISO-8859-1
\Problem name:

Minimize
 obj: x1 + x2
Subject To
 c1: - x1 <= -20
 c2: - x2 <= -20
 c3: - x1 <= -60
 c4: - x2 <= -60
 c5: x1 + x2 <= 110
Bounds
      x1 Free
      x2 Free
End

Tags: 文件envfreemodelmyconfiisx1
1条回答
网友
1楼 · 发布于 2024-05-14 23:16:13

在我的机器上(使用Gurobi云和本地优化),您的代码运行良好,并生成以下ILP文件:

Minimize
 
Subject To
 c3: - x1 <= -60
 c4: - x2 <= -60
 c5: x1 + x2 <= 110
Bounds
 x1 free
 x2 free
End

这是相应的输出:

Using license file C:\gurobi\gurobi.lic
Read LP format model from file inf.lp
Reading time = 0.00 seconds
obj: 5 rows, 2 columns, 6 nonzeros
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 5 rows, 2 columns and 6 nonzeros
Model fingerprint: 0xd8caa76c
Coefficient statistics:
  Matrix range     [1e+00, 1e+00]
  Objective range  [1e+00, 1e+00]
  Bounds range     [0e+00, 0e+00]
  RHS range        [2e+01, 1e+02]
Presolve removed 4 rows and 2 columns
Presolve time: 0.00s

Solved in 0 iterations and 0.00 seconds
Infeasible or unbounded model
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s

IIS computed: 3 constraints and 0 bounds
IIS runtime: 0.00 seconds

由于代码和模型文件是正确的,因此您的设置一定有问题。您应该检查解算器输出是否有任何线索

编辑:

更新古洛比解决了这个问题

相关问题 更多 >

    热门问题