使用BigM方程最小化变量
我正在尝试最大程度地减少以下方程式:
p_ch_max = min(22,e_need*m_int),其中e_need*m_int
可以根据数据大于或低于22。
我正在使用pyomo
中的以下方程式来完成:
m.C6 = ConstraintList()
for t in m.ts2:
m.C6.add(expr = m.char_power - m.var_E_need[0,t]*m_int <= 100*m.Y[t])
m.C6.add(expr = m.var_E_need[0,t]*m_int - m.char_power <= 100 * (1-m.Y[t]))
m.C6.add(expr = m.var_P_ch_max[0,t] <= m.var_E_need[0,t]*m_int )
m.C6.add(expr = m.var_P_ch_max[0,t] <= m.char_power)
m.C6.add(expr = m.var_P_ch_max[0,t] >= m.var_E_need[0,t]*m_int - 100*(1-m.Y[t]))
m.C6.add(expr = m.var_P_ch_max[0,t] >= m.char_power - 100*m.Y[t])
m.char_power = 22;我的
是boolean;
100在这种情况下是我的大`
当我手动替换y的值时,这些方程是有道理的: 当y = 0
我得到p_ch_max&lt; = 22
和p_ch_max&gt; = 22
它会使p_ch_max == 22
。 当y = 1
我得到p_ch_max&lt; = e_need*m_int
和p_ch_max&gt; = e_need*m_int*m_int
,它会产生p_ch_max = e_need = e_need = e_need *m_int
。
但是,当我在pyomo
中运行代码时,它说它是不可行的或无限的,我不明白为什么。还有其他方法吗?还是可以告诉我我是否做错了什么?
I am trying to minimize the following equation:
P_ch_max = min(22, E_need*m_int) where E_need*m_int
can be bigger or lower than 22 depending on the data.
I am using the following equations in pyomo
to do it:
m.C6 = ConstraintList()
for t in m.ts2:
m.C6.add(expr = m.char_power - m.var_E_need[0,t]*m_int <= 100*m.Y[t])
m.C6.add(expr = m.var_E_need[0,t]*m_int - m.char_power <= 100 * (1-m.Y[t]))
m.C6.add(expr = m.var_P_ch_max[0,t] <= m.var_E_need[0,t]*m_int )
m.C6.add(expr = m.var_P_ch_max[0,t] <= m.char_power)
m.C6.add(expr = m.var_P_ch_max[0,t] >= m.var_E_need[0,t]*m_int - 100*(1-m.Y[t]))
m.C6.add(expr = m.var_P_ch_max[0,t] >= m.char_power - 100*m.Y[t])
m.char_power = 22; m.Y
is a boolean;
100 is my big` in this case
When I substitute the values of Y manually, these equations make sense:
When Y=0
I get that P_ch_max<= 22
and P_ch_max>= 22
which would make P_ch_max == 22
.
When Y=1
I get that P_ch_max<= E_need*m_int
and P_ch_max>= E_need*m_int
which would make P_ch_max = E_need*m_int
.
However, when I run the code in pyomo
it says it's unfeasible or unbounded and I don't understand why. Is there any other way to do this? Or can you tell me if I am doing something wrong pls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
It's pretty difficult to unwind your equations and figure out why it is infeasible. But you can do a couple things rather quickly to tackle this.
首先,您可以开始“评论”约束,并查看是否可以获取模型呼吸(因此求解器不会抱怨不可行),然后从那里进行调查。
其次,如果您认为自己知道一个可行的解决方案(正如您在评论中提出的那样),则只需分配值,然后
display
您的模型就可以很快脱颖而出。违反哪些约束。例如:产量:
It's pretty difficult to unwind your equations and figure out why it is infeasible. But you can do a couple things rather quickly to tackle this.
First, you can start to "comment out" constraints and see if you can get the model breathing (such that the solver doesn't complain about infeasibility), and then investigate from there.
Second, if you think you know a feasible solution (as you suggest in your comment about plugging in), then just plug in your values by assigning them and then
display
your model and it should stand out very quickly which constraints are violated. For example:Yields: