schedulingcplexjob-schedulingconstraint-programmingcp-optimizer

How to get current time in CP when using Intervals for scheduling


I am trying to schedule tasks in different machines. These machines have dynamique available ressources, for example:

machine 1: max capacity 4 core.

At T=t1 => available CPU = 2 core;

At T=t2 => available CPU = 1 core;

Each interval has a fixed time (Ex: 1 minute).

So in CPLEX, I have a cumulFunction to sum the used ressource in a machine :

cumulFunction cumuls[host in Hosts] = 
   sum(job in Jobs) pulse(itvs[task][host], requests[task]);

Now the problem is in the constraint:

forall(host in Hosts) {
    cumuls[host] <= ftoi(available_res_function[host](**<<Current Period>>**));
}

I can't find a way to get the current period so that I could compare the used ressources to the available in that specefic period.

PS: available_res_function is a stepFunction of the available ressources.

Thank you so much for your help.


Solution

  • What you can do is to add a set of pulse in your cumul function.

    For instance, in the sched_cumul function you could change:

    cumulFunction workersUsage = 
       sum(h in Houses, t in TaskNames) pulse(itvs[h][t],1); 
    

    into

    cumulFunction workersUsage = 
       sum(h in Houses, t in TaskNames) pulse(itvs[h][t],1)+pulse(1,40,3);
    

    if you want to mention that 3 workers less are available between time 1 and 40.