How to write the following constraint in cplex?
the cost for full truck load is $700
and the cost of fractional truck load is \$800 *fraction up to $700
Operations Research Stack Exchange is a question and answer site for operations research and analytics professionals, educators, and students. It only takes a minute to sign up.
Sign up to join this communityHow to write the following constraint in cplex?
the cost for full truck load is $700
and the cost of fractional truck load is \$800 *fraction up to $700
//the cost for full truck load is $700
// the cost of fractional truck load is $800 *fraction up to 700
float truckCost=700;
float truckPartialCost=800;
range r=1..3;
float values[r]=[5,6.5,6.9];
dvar float nbTruck[r];
dvar float cost[r];
// computation
dvar int intNbTruck[r];
dvar float floatNbTruck[r] in 0..0.99;
subject to
{
forall(i in r)
{
nbTruck[i]==values[i];
nbTruck[i]==intNbTruck[i]+floatNbTruck[i];
cost[i]==intNbTruck[i]*truckCost+minl(truckCost,floatNbTruck[i]*truckPartialCost);
}
}
execute
{
writeln(cost);
}
gives
[3500 4600 4900]
Nb: Some more info here