[英]pyomo constraints section missing
I'm new at using pyomo and getting following error: /var/folders/dk/932rtpm52sg0jdzzkz81mhn00000gn/T/tmp7Psz4a.pyomo.lp:5: constraints section missing 我是使用pyomo的新手,并收到以下错误:/var/folders/dk/932rtpm52sg0jdzzkz81mhn00000gn/T/tmp7Psz4a.pyomo.lp:5:缺少约束部分
My constraint is: 我的约束是:
matrix_bis = np.ones((size_node, size_node))
c11_param = matrix_bis.copy()
c11_param = np.tril(c11_param)
param11 = np.dot(c11_param, m.Y)
# Constraints
def c11_rule(m,j):
for e in node_set:
return (data.ix[e, 'cp_min'], c11_param[e,j]*m.Y[e], data.ix[e, 'cp_max']/interval)
else:
return pe.Constraint.Skip
m.c11 = pe.Constraint(node_set, rule = c11_rule)
Any help much appreciated. 任何帮助,不胜感激。
I'm not sure if this is the cause of your error but the first issue I see is that you don't need the for loop inside of the constraint rule. 我不确定这是否是导致错误的原因,但是我看到的第一个问题是您不需要约束规则中的for循环。 By declaring the Constraint as indexed over node_set the rule will automatically be called once for every value in node_set. 通过将约束声明为在node_set上建立索引,该规则将自动为node_set中的每个值调用一次。 It looks like you are distinguishing between the index 'e' and the index 'j' in c11_param so I'm guessing that you want to index the constraint over the cross product of node_set. 看来您正在c11_param中的索引'e'和索引'j'之间进行区分,所以我猜您想对node_set的叉积的约束进行索引。 You also don't need Constraint.Skip. 您也不需要Constraint.Skip。 Maybe something like this: 也许是这样的:
def c11_rule(m, j, e):
return (data.ix[e,'cp_min'], c11_param[e,j]*m.Y[e], data.ix[e, 'cp_max']/interval)
m.c11 = Constraint(node_set, node_set, rule=c11_rule)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.