- I have the following indexes:
- k: index for days: k ∈ {1, ..., K=365}
- i: index for tasks: i ∈ {1, ..., N=200}
- j: index for the j^th time of task i: j ∈ {1, ..., Fi}
With F_i is a decision variable indicating the Number of repetitions of task i
- And 2 constraints involving Fi and j: 2 constraints here
Is there a way to write this model in CPLEX? I cannot use Constraints Programming since there are float values.
Here is my sample code
int NumbDay = ...;
int NumbTask = ...;
range Day = 1 .. NumbDay;
range Task = 1 .. NumbTask;
dvar int F [Task];
range Repetition = [1..F[Task]]; //Error: Decision variable (or expression) "F" not allowed.
float TotalFH [Day]=...;
float TimeIntervalFH [Task]=...;
float TotalFC [Day]=...;
float TimeIntervalFC [Task]=...;
float TotalDY [Day]=...;
float TimeIntervalDY [Task]=...;
float Manhour [Task]=...;
float NumberOfDaysScheduled =...;
float MinimumNumberOfRepetitions [Task] =...;
dvar float r [Task][Repetition];
dvar float e [Task][Repetition];
dvar float o [Task][Repetition];
dvar float q [Task][Repetition];
dvar float n [Task][Repetition];
dvar float m [Task][Repetition];
dvar float W [Day];
dvar boolean X [Day][Task][Repetition];
execute PRE_PROCESSING {
cplex.epgap = 0.1;
cplex.tilim = 100;
}
// Objective: first criterion for minimize the total of the squared differences between the “Average manhour per day” and “Total manhour load of day k”
// second criterion for minimize the total differences of the time we execute the task and the due date of those tasks
dexpr float e1 = sum(k in Day)(((sum(k in Day, i in Task, j in Repetition) Manhour[i]*X[i][j][k])/365) - W [Day])^2; //Cannot use type range for int.
dexpr float e2 = sum(i in Task, j in Repetition)q[i][j]*n[i][j]*m[i][j];
// trying to minimize the total of the squared differences between the “Average manhour per day” and “Total manhour load of day k” first
minimize staticLex(e1, e2);
subject to {
constraint_1:
forall (i in Task){
F [i] >= MinimumNumberOfRepetitions [i];
}
constraint_2:
forall (k in Day){
sum(i in Task, j in Repetition) Manhour[i]*X[i][j][k] == W [k];
}
constraint_3:
forall (i in Task, j in Repetition){
sum(k in Day) X[i][j][k] == 1;
}
....