Originally posted by: **AndyHam**

Thanks for the help.

I put it into the problem.

I confirmed that CP results match with the manual calculation of $141.

I finally understood piecewise and Eval ^^

using CP;

int T=14;

int C[1..5][0..T] =

[

[10, 10, 10, 15, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 8],

[20, 20, 25, 27, 24, 20, 16, 16, 16, 16, 16, 16, 16, 16, 0],

[30, 35, 37, 39, 32, 28, 24, 24, 24, 24, 24, 24, 24, 24, 0],

[45, 47, 49, 47, 40, 36, 32, 32, 32, 32, 32, 32, 32, 32, 0],

[57, 59, 57, 55, 48, 44, 40, 40, 40, 40, 40, 40, 40, 40, 0]

];

pwlFunction Cost[i in 1..5] = piecewise(t in 0..T-1) { C[i][t+1]-C[i][t]-> t+1; 0}(0,C[i][0]);

dvar interval a[i in 1..5] size i;

minimize sum(i in 1..5) startEval(a[i], Cost[i]);

subject to {

startOf(a[1])==0;

startOf(a[2])==1;

startOf(a[3])==3;

startOf(a[4])==6;

startOf(a[5])==10;

}

#DecisionOptimization#OPLusingCPOptimizer