I have to define float variables such as nbBus40 and nbBus30 for every node in OPL Cplex and the optimization problem is non-linear. I am writing the code and the error with the code.
using CP;
int nbKids=310;
float costBus40=500;
float costBus30=400;
int scale=100;
int num_Node = 13;
range Node = 1..num_Node;
dvar int+ scalenbBus40[Node];
dvar int+ scalenbBus30[Node];
*dexpr float nbBus40[Node]=scalenbBus40[Node]/scale;*
*dexpr float nbBus30[Node]=scalenbBus30[Node]/scale;*
minimize
sum (n in Node)(costBus40*nbBus40[n] + nbBus30*costBus30[n]);
subject to
{
forall (n in Node){
40*nbBus40[n]+nbBus30[n]*30>=nbKids;
}
}
The error with the italic part of the above code is that it Cannot use type range for int.
is wrong. You should write:
The following model works fine