0

Hi I'm trying to make a model with objective function to minimize cost of mode 2 usage( mode with using external resource). I confuse when I want to make a limitation total time <=21 the result is no value, but when I set the time <= 50 the result was came out, although the result when I running the model only spending time 25.

tuple Task {
  key int id;
  {int} succs;
  int RelDate;
}
{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..(maxint div 2)-1; 
dvar interval mode[m in Modes] optional  size m.pt;
dexpr int totaltime = sum(m in Modes) presenceOf(mode[m]) * ( m.pt); //boolean expression
//dexpr int totalExtCost = sum(m in Modes) presenceOf(mode[m])* (m.ExtCost * m.pt);


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 sum(m in Modes) (m.ExtCost * m.pt) * maxl (presenceOf(mode[m]));
//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 <= 285740966 in 0..NbDays-14) != presenceOf(mode[first(Modes)]);
  
//External resource's budget limitation
forall ( t in Tasks, m in Modes )
  totaltime <= 50;
//forall ( m in Modes )
  //totalExtCost <= 30000000;
 //Resource Usage
  forall (r in IntRes)
    IntResUsage[r] <= CapIntRes[r];
  forall (r in ExtRes)
    ExtResUsage[r] <= CapExtRes[r];    
Beta
  • 1
  • 1

2 Answers2

0

Could you simplify your model so that it illustrates your problem ? I do not see any value 50 or 25 in the model.

Also:

  • I do not see why you are using a “max” here:
minimize sum(m in Modes) (m.ExtCost * m.pt) * maxl (presenceOf(mode[m]));

  • I do not see why you post this constraint for each task and each mode (!). It is independent from the tasks and the modes: forall ( t in Tasks, m in Modes ) { totaltime <= 100; }

By the way, for readability reasons, you could also rewrite your expressions: “presenceOf(mode[m]) * ( m.pt)” as “sizeOf(mode[m])”. If the model duration is a constant, both formulations should be more or less similar from a performance perspective, but if the duration is a decision variable, the formulation with “sizeOf(model[m])” will definitively be better.

  • the first question it should be use the min? sorry because I still a newbie. For the second question I want to minimize the cost, it should be have a time limitation right? Btw I already edited my question – Beta Apr 21 '21 at 02:58
0

For the 'min', you should neither use the min or the max as your are dealing with a singleton, you directly use the presenceOf.

So I would simplify the formulation as follows:

dvar interval Tasks [t in Tasks] in t.RelDate..(maxint div 2)-1; 
dvar interval mode[m in Modes] optional  size m.pt;
dexpr int totaltime    = sum(m in Modes) sizeOf(mode[m]); 
dexpr int totalExtCost = sum(m in Modes) (m.ExtCost*sizeOf(mode[m]));

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 totalExtCost;
  
subject to {
 // Alternative mode of resource productivity in Cost's unit
  forall (t in Tasks)
    alternative(Tasks[t], all(m in Modes: m.taskId==t.id) mode[m]);
  
  // I have no hint what the constraints below are supposed to do !
  // forall (t in Tasks, m in Modes)
  //  (sum(t in Tasks) sum(m in Modes) m.costprod * m.pt <= 285740966 in 0..NbDays-14) != presenceOf(mode[first(Modes)]);
  
  // External resource's budget limitation
  totaltime <= 50;
  // totalExtCost <= 30000000;
  // Resource Usage
  forall (r in IntRes)
    IntResUsage[r] <= CapIntRes[r];
  forall (r in ExtRes)
    ExtResUsage[r] <= CapExtRes[r]; 
} 

Then I still do not understand the problem with limiting the "totalTime" to 50. It does not prevent to compute a solution with "totalTime=25" indeed, as 25<=50.

In fact I do not understand your problem. You seem to say that the problem with "totalTime<=21" is infeasible, and that when you post a constraint "totalTime<=50" it finds a solution where "totalTime=25". I don't see where is the problem here ...