在 CPLEX ILOG 中表达方程

问题描述

我目前正在 IBM ILOG Cplex 上进行项目编码。我一直在将数学模型转换为 CPLEX 中的约束。在这里,我想知道我们如何在 cplex 上编码这个约束,因为它有 3 个元素。我试过 OR 逻辑,但结果似乎错误 enter image description here

解决方法

或者在 OPL 中工作正常,但您将其写为 ||

参见示例 https://github.com/AlexFleischerParis/zooopl/blob/master/zoodisjunction.mod

int nbKids=300;
float costBus40=500;
float costBus30=400;
 
dvar int+ nbBus40;
dvar int+ nbBus30;
 
minimize
 costBus40*nbBus40  +nbBus30*costBus30;
 
subject to
{
 40*nbBus40+nbBus30*30>=nbKids;

//with nb buses 40 less than 3 or more than 7
(nbBus40<=3) || (nbBus40>=7);
}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...