docplex 模型尚未解决 错误

发布于 2025-01-13 02:41:55 字数 678 浏览 1 评论 0原文

大家好,提前感谢您的关注,

我正在尝试建模并求解混合整数模型,其中目标函数和所有约束都是线性的,并且只有一个非线性约束。 与此约束相关的相关变量定义如下:

p_pg = mdl.continuous_var_dict(utility_key, name='p')

u_pg = mdl.continuous_var_dict(utility_key, name='u')

其中“_”后面的 p 和 g 是索引

该非线性约束的数学表达式如下:

p_pg = (exp(u_pg)) / (Σ p∈p exp (u_pg) + exp (0))对于所有 p, g

我试图通过使用 docplex 在 python 中添加此约束,如下所示:

mdl.add_constraints(p_pg[plan,egment] == (exp(u_pg[plan,egment]) / (mdl.sum(exp( u_pg[s, segment]) 对于范围内的 s(1, p+1)) + exp(0)))对于范围内的计划(1, p+1) 对于范围内的段(1, g+1))

I出现以下错误: 模型尚未解决

应该注意的是,我也尝试了 mdl.add_quadratic_constraints 并且得到了相同的错误。

我不明白为什么当我尝试添加约束时会出现此错误。

感谢您提前的支持

Hello everyone and thank you in advance for your attention,

I am trying to model and solve a Mixed-integer model in which the objective function and all constraints are linear and I only have one nonlinear constraint.
The relevant variables related to this constraint are defined as follow:

p_pg = mdl.continuous_var_dict(utility_key, name='p')

u_pg = mdl.continuous_var_dict(utility_key, name='u')

where p and g after "_" are indices

The mathematical expression of this non-linear constraint is as follows:

p_pg = (exp(u_pg)) / (Σ p∈p exp (u_pg) + exp (0)) for all p, g

I am trying to add this constraint in python by using docplex as follow:

mdl.add_constraints(p_pg[plan, segment] == (exp(u_pg[plan, segment]) / (mdl.sum(exp(u_pg[s, segment]) for s in range(1, p+1)) + exp(0)))for plan in range(1, p+1) for segment in range(1, g+1))

I get the following error:
Model has not been solved yet

It should be noted that I also tried the mdl.add_quadratic_constraints and I get the same error.

I do not understand why I should get this error when I am trying to add constraints.

Thank you for your kind support in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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