CPLEX OPL 语法

CPLEX OPL Syntax

那些圈起来的约束怎么写

在 CPLEX OPL 中?

您最多可以使用。 请参阅 https://github.com/AlexFleischerParis/zooopl/blob/master/zoomax.mod

中的小示例
int nbKids=300;

{int} buses={30,40,50};


dvar int+ nbBus[buses];
dvar int maxNbOfBusesGivenSize;

    
minimize maxNbOfBusesGivenSize;
     
subject to
{
 // logical constraint
 // maxNbOfBusesGivenSize is the max of all nbBus
 maxNbOfBusesGivenSize==max(i in buses) nbBus[i];
 sum(i in buses) i*nbBus[i]>=nbKids;
}

execute DISPLAY_After_SOLVE
{
  writeln("The max number of buses is ",maxNbOfBusesGivenSize);
  writeln("nbBus = ",nbBus);
}

/*

gives

The max number of buses is 3
nbBus =  [3 3 3]

*/