Categories
Mastering Development

How to make a rigid alternative constraint based on earn value

i want to make a rescheduling model. I have 2 modes in tuple, I declare it using ID, I want to make a constraint if the costprod * duration in present’s mode in day 1-7 <= earn value than choose mode 2. But I think something missing in model. but I didn’t know where is it. i think it will be need a constraint like at day 1 = earn value (0) and the end day = total earn value. I stuck on this part

range IntRes= 0..NbIntRes-1;
range ExtRes=0..NbExtRes-1;

int CapIntRes[IntRes]=...;
int CapExtRes[ExtRes]=...;

tuple Task {
  key int id;
  {int}   succs;
  int RelDate;
  int DueDate;
}
{Task} Tasks = ...;

tuple Mode {
  key int taskId;
  key int id;
  int pt;
  int costprod;
  int dmdIntRes [IntRes];
  int dmdExtRes [ExtRes]; 
  int ExtCost;
}
{Mode} Modes = ...;

dvar interval Taskss [t in Tasks] in t.RelDate..t.DueDate   ; 
dvar interval mode[m in Modes] optional  size m.pt;
dexpr int totalExtCost = sum(m in Modes) presenceOf(mode[m])* (m.ExtCost * m.pt); //boolean expression


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(t in Tasks) endOf(Taskss[t]);

  
subject to {
 //Alternative mode of resource productivity in Cost's unit
  forall (t in Tasks, m in Modes) {
 // if(m.costprod *m.pt == 0 && 0 <= 559717712) presenceOf(mode[first(Modes)]);
  
    alternative(Taskss[t], all(m in Modes: m.taskId==t.id) mode[m]);
}
 forall (t in Tasks, m in Modes)
  (sum(t in Tasks)sum(m in Modes) m.costprod * m.pt <= 559717712 in 0..NbDays-14) != presenceOf(mode[first(Modes)]);
  
  
//External resource's budget limitation
 forall ( m in Modes)
  totalExtCost <= 20000000;

This one the data

NbDays= 21;
NbTask= 10;
NbIntRes= 1;
NbExtRes= 1;
CapIntRes= [25];
CapExtRes= [15];

Tasks={
  < 0, {5, 6 },1, 5>,//first mobilization
  < 1, { 5, 6 },2,10 >,
  < 2, { 5, 6 },2,10>,
  < 3, { 5, 6 },2,15>,
  < 4, { 5, 6 },2,15>,
  < 5, {6},4,21>,
  < 6, {7},4 ,21>,
  < 7, {8},5,10>,
  < 8, {9},15,21>,
  < 9, { },17,21 >,//end mobilization
 };

Modes = {
  < 0, 1, 3,   700000,[ 2 ], [ 0 ],0 >,
  < 0, 2, 2,  1060000,[ 2 ], [ 1 ],300000 >,
  < 1, 1, 4,  1920000,[ 6 ], [ 0 ],0 >,
  < 1, 2, 3,  2600000,[ 6 ], [ 2 ],600000 >,
  < 2, 1, 4,   880000,[ 4 ], [ 0 ],0 >,
  < 2, 2, 3,  1140000,[ 4 ], [ 1 ],300000 >,
  < 3, 1, 4,  2580000,[ 6 ], [ 0 ],0 >,
  < 3, 2, 3,  3480000,[ 6 ], [ 2 ],600000 >,
  < 4, 1, 4, 22500000,[ 9 ], [ 0 ],0 >,
  < 4, 2, 3, 32900000,[ 9 ], [ 4 ],12000000 >,
  < 5, 1,15,  8400000,[ 7 ], [ 0 ],0 >,
  < 5, 2,11, 11100000,[ 7 ], [ 2 ],600000 >,
  < 6, 1,15,276000000,[12 ], [ 0 ],0 >,
  < 6, 2,12,348000000,[12 ], [ 3 ],900000 >,
  < 7, 1, 2, 36800000,[ 8 ], [ 0 ],0 >,
  < 7, 2, 1, 60300000,[ 8 ], [ 5 ],1500000 >,
  < 8, 1, 6, 33800000,[ 6 ], [ 0 ],0 >,
  < 8, 2, 4, 46600000,[ 6 ], [ 3 ],900000 >,
  < 9, 1, 3,   700000,[ 2 ], [ 0 ],0 >,
  < 9, 2, 2,  1060000,[ 2 ], [ 1 ],300000 >,
};

Leave a Reply

Your email address will not be published. Required fields are marked *