docplex 模型尚未解决 错误
大家好,提前感谢您的关注,
我正在尝试建模并求解混合整数模型,其中目标函数和所有约束都是线性的,并且只有一个非线性约束。 与此约束相关的相关变量定义如下:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论