非恒定表达式无法乘以 - 纸浆包装
我正在研究一个优化问题,我正在使用 PuLP 线性编程包。 请在下面找到我的线性规划模型参数:
#model
model = LpProblem(name="variable_rate", sense = LpMaximize)
# Defining variable
var_rate = LpVariable.dicts("variable_rate", len, lowBound=10, upBound=26, cat='integer')
expression = variable_x*var_rate*var_rate #part of the expression
我收到错误 TypeError: Non-constant statements can be multiplied
因此,如果我的表达式涉及 LpVariable
的乘法,我会得到这个错误。我读到 PuLP 是一个线性编程包,仅接受 LpVariable
内的加法或减法。 但我的表达式中需要有那个乘法因子。有没有办法可以用 PuLP 解决这个问题,或者您是否建议任何其他优化包。
先感谢您。
I am working on an optimisation problem for which I am using PuLP linear programming package.
Please find my linear programming model parameters below:
#model
model = LpProblem(name="variable_rate", sense = LpMaximize)
# Defining variable
var_rate = LpVariable.dicts("variable_rate", len, lowBound=10, upBound=26, cat='integer')
expression = variable_x*var_rate*var_rate #part of the expression
I get the error TypeError: Non-constant expressions cannot be multiplied
So, if my expression involves multiplication of the LpVariable
, I get this error. I read that PuLP is a linear programming package and accepts only addition or subtraction within the LpVariable
.
But I need to have that multiplication factor in my expression. Is there a way I can solve this problem with PuLP or do you suggest any other optimisation package.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论