Originally posted by: ChrisBr
Hello Hadi,
You can model such kind of expression by using an auxiliary dvar as following:
cumulFunction level[r in resources] = sum (m in Modes: m.dmdRenewable[r]>0) pulse(mode[m], m.dmdRenewable[r]) )
dvar int overflow[resources] in 0..1;
forall (r in resources) {
level[r] <= minCapRenewableRsrc[r]+overflow[r]*(maxCapRenewableRsrc[r]-minCapRenewableRsrc[r]);
penalty[r] == 1000*overflow[r];
}
In this sample, you can also directly use 1000*overflow[r] in the cost expression.
An other way to model such idea depending on other things you want to do is to use an optional interval variable (useMin) that will have to be absent if more than minCapRenewableRsrc[r] units or resource is used at some point:
cumulFunction level[r in resources] = sum (m in Modes: m.dmdRenewable[r]>0) pulse(mode[m], m.dmdRenewable[r]) )
dvar interval useMin[r in resources] optional in 0..horizon size horizon;
cumulFunction useMinLevel[r in resources] = pulse(useMin[r], maxCapRenewableRsrc[r]-minCapRenewableRsrc[r]);
forall (r in resources) {
level[r] + useMinLevel[r] <= maxCapRenewableRsrc[r];
penalty[r] == 1000*(1-presenceOf(useMin[r]));
}
I hope this helps,
Chris.
#DecisionOptimization#OPLusingCPOptimizer