Originally posted by: Almakhawi
Hello,
I m new to cplex, i would like to do program for scheduling n job on m machines with cplex and C++
i want to formulate the job dependencies constraints, this menas if job1 depends on job2 , job1 start time must be greater equal job2 start time + the computation time of job2 on that machine pointed by alloc matrix.
NumMatrix jobDep(env, n); // Matrix for Job Dependencies
jobDep[0] = IloNumArray(env,n 0, 0, 0, 0 ); // in this example n = 4
jobDep[1] = IloNumArray(env,n, 0, 0, 0, 0 );
jobDep[2] = IloNumArray(env,n, 1, 1, 0, 0 );
jobDep[3] = IloNumArray(env,n, 0, 0, 1, 0 );
NumMatrix exec_time(env,n); // execution time of each node on each machine
// adding values for the matrix of the computation time
exec_time[0] = IloNumArray(env,m, 1,3); // in this example m=2
exec_time[1] = IloNumArray(env,m,16,8);
exec_time[2] = IloNumArray(env,m,2,1);
exec_time[3] = IloNumArray(env,m,2,4);
IloNumVarArray ExecST(env, n, 0, 20, ILOINT); // Startime for Jobs where cV is the number of jobs
IloNumVarArray Alloc(env, n, 0, m-1, ILOINT); // Allocation matrix where cP is the number of machines
// job dependencies test
for (int v1=0;v1<n;v1++) {
for (int v2=0;v2<n;v2++) {
if (jobDep[v1][v2]==1){
model.add(Alloc[v1]==Alloc[v2]); // this means if two jobs allocated to the same machine because every machine have differen exec time
model.add(ExecST[v1] >= ExecST[v2] + exec_time[v2][Alloc[v2]]); // want to use the intermediate value of Alloc[v2] as index for exec_time[v2][ Alloc[v2] ]
}
}
}
in the previous code Alloc[v2] will takes values from 0 to m-1 i need to retrive i would like to use the intermediate values as index of the column in the exec_time[v2][ Alloc[v2]] ..
in other form .. i want to use the intermediate value of Alloc[v2] as index for the matrix exec_time [v2][ Alloc[v2] ];
any one have an idea?
#CPLEXOptimizers#DecisionOptimization