我正在尝试解决 Pyomo 中的多目标 GDP。问题是 GDP,因为我的决策变量是半连续的。
def off_rule(d, i):
m = d.model()
d.c = Constraint(expr=model.x[i] == 0)
model.disjunct_off = Disjunct(Set, rule=off_rule)
def disyuncion_encendido_rule(d, i):
m = d.model()
d.c = Constraint(expr=inequality(LB[i], model.x[i], UB[i]))
model.disjunct_on = Disjunct(Set, rule=on_rule)
def ConjuntoDisyunciones_rule(m, i):
return[model.disjunct_off[i], model.disjunct_on[i]]
model.ConjuntoDisyunciones = Disjunction(Set, rule=ConjuntoDisyunciones_rule)
为了解决这个问题,我正在使用权重方法。
我已经定义了我的目标:
model.obj1 = Objective(expr = Objective1)
model.obj2 = Objective(expr = Objective2)
model.obj3 = Objective(expr = Objective3)
model.obj4 = Objective(expr = Objective4)
model.obj5 = Objective(expr = Objective5)
Objective1 和另一个 Objective 是包含 Pyomo 表达式的 Python 变量。
<pyomo.core.expr.numeric_expr.SumExpression at 0x27497156740>
然后我创建一个总体目标并添加所有目标及其相应的权重。
model.obj_total = Objective(expr = 0)
model.obj_total.expr += LAMBDA1*model.obj1
model.obj_total.expr += LAMBDA2*model.obj2
model.obj_total.expr += LAMBDA3*model.obj3
model.obj_total.expr += LAMBDA4*model.obj4
model.obj_total.expr += LAMBDA5*model.obj5
然后我停用个人目标
model.obj1.deactivate()
model.obj2.deactivate()
model.obj3.deactivate()
model.obj4.deactivate()
model.obj5.deactivate()
现在我的一个疑问出现了。 如何配置求解器调用?因为我的目标之一是二次方程。我试过:
results = SolverFactory('gdpopt.loa').solve(
model, mip_solver='gurobi', nlp_solver = 'ipopt')
这个表达正确吗?
求解器似乎在运行,因为它找到了解决方案,但在这样做时我收到以下警告消息:
WARNING: Discrete problem was unbounded. Re-solving with arbitrary bound
values of (-1e+15, 1e+15) on the objective, in order to get a discrete
solution. Check your initialization routine.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective.ScalarObjective'>. Bounds will not be improved
in this part of the tree.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective._GeneralObjectiveData'>. Bounds will not be
improved in this part of the tree.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective._GeneralObjectiveData'>. Bounds will not be
improved in this part of the tree.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective._GeneralObjectiveData'>. Bounds will not be
improved in this part of the tree.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective._GeneralObjectiveData'>. Bounds will not be
improved in this part of the tree.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective.ScalarObjective'>. Bounds will not be improved
in this part of the tree.
WARNING: Unsupported expression type for FBBT: <class
'pyomo.core.base.objective.ScalarObjective'>. Bounds will not be improved
in this part of the tree.
我不明白为什么它告诉我我的问题是无界的,在定义我的决策变量时,我已经用规则定义了限制。
def initials_bounds_rule(model,i):
return(0,Bounds[i])
model.x = Var(Set, bounds = initials_bounds_rule)
我也不明白为什么会出现消息Unsupported expression type for FBBT。 这是怎么回事?
简而言之,我的问题是:
求解器的名字好吗?
为什么我会收到这些警告信息?
定义
Objective
时,您将 Pyomo obj_total
对象放入表达式树中。如果您改为使用以下方式构造其表达式,则 FBBT 的警告应该消失:
model.obj_total.expr += LAMBDA1*model.obj1.expr
(其他的依此类推。)
关于离散问题是无界的,如果你能提供一个最小的例子会很有帮助。你是对的,如果你所有的变量都是有界的,那么你不应该得到那个特定的警告:边界应该在离散问题中。