Originally posted by: SystemAdmin
[dgravot@noos.fr said:]
Hello,
You can calculate the resource usage at any time point of your horizon, and then minimize it through the max or the sum over the horizon.
a MILP approach :
int numJobs = ...;
range Jobs = 1..numJobs;
int numPeriods = ...;
range Periods = 1..numPeriods;
int earliestStart[Jobs] = ...;
int latestStart[Jobs] = ...;
int serviceTime[Jobs] = ...;
dvar int startJob[Jobs][Periods] in 0..1;
dvar int+ resUsage[Periods];
minimize
sum(t in Periods) resUsage[t];
subject to {
forall(t in Periods)//each job j that begins from t-serviceTime[j]+1 till t use one unit of resource at time t
resUsage[t] == sum(j in Jobs,t2 in maxl(0,t-serviceTime[j]+1)..t) startJob[j][t2];
forall (j in Jobs)
{
sum (t in Periods: earliestStart[j]<=t<=latestStart[j]) startJob[j][t]==1;<br /> forall(t in Periods : earliestStart[j]>t || t>latestStart[j]) startJob[j][t]==0;
}
};
then a CP approach is more elegant and less consuming since you don't need to sample the horizon, creating far more less variables. However, you probably have to write a script around this model in order to iterate over a parameter in order to minimize the resource usage. Indeed minimize a "cumulFunction" is not allowed.
using CP;
int numJobs = ...;
range Jobs = 1..numJobs;
int numPeriods = ...;
int earliestStart[Jobs] = ...;
int latestStart[Jobs] = ...;
int serviceTime[Jobs] = ...;
dvar interval job[j in Jobs] size serviceTime[j];
cumulFunction resUsage = sum(j in Jobs) pulse(job[j],1);
int boundValue = ...;//to be decreased in a loop
subject to {
resUsage <= boundValue;<br />
forall(j in Jobs)
earliestStart[j] <= startOf(job[j]) <= latestStart[j];<br />};
#DecisionOptimization#MathematicalProgramming-General