Originally posted by: AndyHam
Hi Philippe,
Thanks for the advice. I tried the first option. It worked well for the specific purpose.
Let me explain the ultimate purpose of measuring the traveled distance over time.
Actually, it was for the battery level of an electric vehicle.
Over the time, the vehicle needs to visit one of charging stations located at different nodes.
The CP code would look like the following. However, there are several errors:
(1) we cannot use sizeOf(a) as h in stepAtEnd(a, h)
(2) heightAtEnd should be determined by collectively considering two different activities (itvJ2T and itvR2T: one for energy consumption and the other for recharging)
============================================
cumulFunction cumBattery[t in Trucks]= step(0, 100) // initial battery level
- sum(j in Jobs) stepAtEnd (itvJ2T[j,t], 0,3600) //energy consumption
+ sum(r in Jobs) stepAtEnd (itvR2T[r][t],ChargingRate*sizeOf(itvR2T[r][t])); //energy recharging
forall(j in Jobs,t in Trucks)
heightAtEnd(itvJ2T[j,t],cumBattery[t]) ==ConsumptionRate* DistMatrixById[j.id][typeOfNext(seqTrk[t], itvJ2T[j][t], j.id, j.id)];
forall(t in Trucks)
0 <= cumBattery[t] <= MaxLevel;
============================================
If you can suggest the solution for me, I will be very thankful ^^
Andy
#DecisionOptimization#OPLusingCPOptimizer