Original Message:
Sent: Wed January 10, 2024 07:42 AM
From: Berkay Orkun Erkılınç
Subject: Constraint Programming
I want to convert my IP model into the Constraint Programming. I struggle with that. How can code that? I tried some methods. However It does not work.
The code:
// IBM ILOG CPLEX Constraint Programming Model for Job Scheduling
// Sets and Parameters
int J = ...; // Number of jobs
int K = ...; // Number of machines
int P = ...; // Number of positions (Assuming P = J)
range SJ = 1..J; // Set of jobs
range SK = 1..K; // Set of machines
range SP = 1..P; // Set of positions
int M = ...; // A large number for logical constraints
// Parameters
int Ajk[SJ][SK] = ...; // Machine eligibility
int Sijk[SK][SJ][SJ] = ...; // Setup times
int Ljk[SJ][SK] = ...; // Processing times
// Decision Variables
dvar boolean Xjkp[SJ][SK][SP];
dvar int+ Yj[SJ];
dvar int+ Cj[SJ];
dvar boolean Wjkpi[SJ][SK][SP][SJ];
dvar int+ totalCompletionTime; // Auxiliary variable for total completion time
// Objective Function
minimize totalCompletionTime;
subject to {
// Constraint 1: Each job is assigned exactly once
forall(j in SJ)
sum(k in SK, p in SP) Xjkp[j][k][p] == 1;
// Constraint 2: Machine eligibility
forall(j in SJ, k in SK, p in SP)
Xjkp[j][k][p] <= Ajk[j][k];
// Constraint 3: One job per machine position
forall(k in SK, p in SP)
sum(j in SJ) Xjkp[j][k][p] <= 1;
// Constraint 4: Sequential job positioning on each machine
forall(k in SK, p in 1..P-1)
sum(j in SJ) Xjkp[j][k][p] >= sum(j in SJ) Xjkp[j][k][p+1];
// Constraint 5: Job follow-up relationship
forall(k in SK, p in 1..P-1, j in SJ, i in SJ)
Xjkp[j][k][p] + Xjkp[i][k][p+1] - 1 <= Wjkpi[j][k][p][i];
// Constraint 6: Completion time and setup times
forall(i in SJ, j in SJ, k in SK)
Cj[j] + Sijk[k][i][j] <= Yj[i] + M * (1 - sum(p in SP) Wjkpi[j][k][p][i]);
// Constraint 7: Relation between completion and start times
forall(j in SJ)
Cj[j] >= Yj[j] + sum(k in SK, p in SP) Xjkp[j][k][p] * Ljk[j][k];
// Auxiliary Objective Constraint
totalCompletionTime == sum(j in SJ) Cj[j];
}
// Additional solver parameters
// Define as needed
Thank you.
------------------------------
Berkay Orkun Erkılınç
------------------------------