AttributeError: "AbstractModel" object has no attribute "computeIIS"
AttributeError: "AbstractModel" object has no attribute "computeIIS"
我有一个随机混合整数问题,其中某些场景可能会给出不可行的问题。
该模型被制定为抽象 Pyomo 模型,我使用的求解器是 gurobi 8.1.0
我想看看 Irreducible Inconsistent Subsystem (IIS),这样我就可以解决我的绝对错误问题。
下面的 link 中是我尝试使用的函数 model.computeIIS()。
http://www.gurobi.com/documentation/8.1/refman/py_model_computeiis.html
我已经尝试从上面 link 开始复制粘贴并实现下面的代码(http://www.gurobi.com/documentation/8.1/examples.pdf ,workforce1.py 第 401 页)
model.computeIIS()
if model.IISMinimal :
print("IIS is minimal \n")
else :
print ("IIS is not minimal \n")
print ("\ n The following constraint (s) cannot be satisfied:")
for c in model.getConstrs():
if c.IISConstr:
print ("%s" % c.constrName)
我希望这会打印 IIS。不幸的是,它只是给我属性错误:"AbstractModel" 对象没有属性 "computeISS"
您的模型似乎是 Pyomo 模型,但示例使用的是 Gurobi 模型 class。 Pyomo class 没有方法 computeIIS
.
GurobiDirect
class 接受一些 Gurobi 参数,包括 ResultFile
。以下将使 Gurobi 将 IIS 写入文件:
opt = SolverFactory('gurobi')
opt.options['ResultFile'] = "test.ilp"
文件名的后缀决定了结果文件的类型; .ilp
适用于 IIS。 See here.
我有一个随机混合整数问题,其中某些场景可能会给出不可行的问题。
该模型被制定为抽象 Pyomo 模型,我使用的求解器是 gurobi 8.1.0
我想看看 Irreducible Inconsistent Subsystem (IIS),这样我就可以解决我的绝对错误问题。
下面的 link 中是我尝试使用的函数 model.computeIIS()。
http://www.gurobi.com/documentation/8.1/refman/py_model_computeiis.html
我已经尝试从上面 link 开始复制粘贴并实现下面的代码(http://www.gurobi.com/documentation/8.1/examples.pdf ,workforce1.py 第 401 页)
model.computeIIS()
if model.IISMinimal :
print("IIS is minimal \n")
else :
print ("IIS is not minimal \n")
print ("\ n The following constraint (s) cannot be satisfied:")
for c in model.getConstrs():
if c.IISConstr:
print ("%s" % c.constrName)
我希望这会打印 IIS。不幸的是,它只是给我属性错误:"AbstractModel" 对象没有属性 "computeISS"
您的模型似乎是 Pyomo 模型,但示例使用的是 Gurobi 模型 class。 Pyomo class 没有方法 computeIIS
.
GurobiDirect
class 接受一些 Gurobi 参数,包括 ResultFile
。以下将使 Gurobi 将 IIS 写入文件:
opt = SolverFactory('gurobi')
opt.options['ResultFile'] = "test.ilp"
文件名的后缀决定了结果文件的类型; .ilp
适用于 IIS。 See here.