我正在尝试运行以下优化模型,但是 CBC 求解器崩溃并显示以下消息:
错误:求解器(cbc)返回非零返回码(3)错误:请参见 上面的求解程序日志中提供了诊断信息。
主要思想是确保在一个时间步长“ ts”之后,将每个节点“ n”中每个类型/组的数量转移到节点“ n-1”中。我的真实模型更加复杂,具有真实的Objective函数和其他一些约束,但这是我当前的瓶颈。
import pyomo.environ as pyo
from pyomo.opt import SolverFactory
model = pyo.AbstractModel()
# Parameters
model.T = 5*252 # total time-steps
model.N = 252 # total number of nodes
# Sets
model.time_steps = pyo.RangeSet(0, model.T) # set of time steps
model.nodes = pyo.RangeSet(1, model.N) # set of nodes
model.groups = pyo.Set(initialize=['A','B']) # set of groups
model.types = pyo.Set(initialize=['Type1','Type2','Type3','Type4','Type5']) # set of types
# Variables
model.node_amounts = pyo.Var(model.time_steps, model.nodes, model.types, model.groups, initialize=0)
# Objectives
def total_cost_rule(model):
return True
model.obj = pyo.Objective(rule=total_cost_rule)
# Constraints
def flow_rule(model, ts, n, ccy, g):
if ts == 0:
if n == model.N:
return model.node_amounts[ts, n, ccy, g] == 1
else:
return model.node_amounts[ts, n, ccy, g] == 0
else:
if n == model.N:
return model.node_amounts[ts, n, ccy, g] == 0
else:
return model.node_amounts[ts, n, ccy, g] == model.node_amounts[ts-1, n+1, ccy, g]
model.flow_constraints = pyo.Constraint(model.time_steps, model.nodes, model.types, model.groups, rule=flow_rule)
# Concrete Model
concrete_model = model.create_instance()
# Solving model
opt = SolverFactory('cbc')
results = opt.solve(concrete_model, tee=True, keepfiles=True)
When I run the same model using 'glpk' it works fine.
opt = SolverFactory('glpk')
您知道“ CBC”求解器是否有大小限制吗? “ lp”文件约为250MB,大约有1000万行。
我正在Windows环境中运行它: -Python 3.6.3 64位。 -CBC v.2.9.7 -Pyomo 5.6.1 -32 GB RAM
请让我知道是否有人遇到类似问题,以及解决方法。
关于如何使用其他方法构建时间流入/流出模型的任何想法吗?
谢谢, 尼尔森