I want to make, if total production task "i" * duration at day 15 <= not equal to our target then choose alternative 2,else choose alternative 1. I made the data on tuple. but I still confuse to determine for at day x the calculation must be more or less then the result. THis is my model.
Tuple Precedence {
key int id;
{int} succs;
int RelDate;
int VolCost;
}
{Precedence} Precedences = ...;
tuple Mode {
key int taskId;
key int id;
int pt;
int costprod;
int dmdIntRes [IntRes];
int dmdExtRes [ExtRes];
}
{Mode} Modes = ...;
dvar interval Tasks [p in Precedences]in p.RelDate..EndMax ; //in p.RelDate..EndMax in 0..EndMax
dvar interval mode[m in Modes] optional size m.pt;
//dvar boolean m1 [m in Modes];
cumulFunction IntResUsage[r in IntRes] =
sum (m in Modes: m.dmdIntRes[r]>0) pulse(mode[m], m.dmdIntRes[r]);
cumulFunction ExtResUsage[r in ExtRes] =
sum (m in Modes: m.dmdExtRes[r]>0) pulse(mode[m], m.dmdExtRes[r]);
execute {
cp.param.FailLimit = 10000;
}
minimize max(p in Precedences) endOf(Tasks[p]);
subject to {
forall (p in Precedences, m in Modes) {
alternative(Tasks[p], all(m in Modes: m.taskId==p.id) mode[m])
This is an example my tuple data for modes
Modes = {
< 0, 1, 3, 700000,[ 2 ], [ 0 ] >,
< 0, 2, 2, 1060000,[ 2 ], [ 1 ] >,
< 1, 1,24, 70313,[ 2 ], [ 0 ] >,
< 1, 2,20, 80357,[ 2 ], [ 1 ] >,
< 2, 1,24, 143750,[ 5 ], [ 0 ] >,
< 2, 2,20, 164286,[ 5 ], [ 1 ] >,
< 3, 1, 5, 1500000,[ 6 ], [ 0 ] >,
as said in How to make a if and else in alternative function in OPL?
you could rely on presenceOf
With your .dat
.mod
works and can help you with the syntax