非恒定表达式无法乘以 - 纸浆包装

发布于 2025-01-20 00:17:22 字数 620 浏览 3 评论 0原文

我正在研究一个优化问题,我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文