Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Help to retrive the intermediate values of IloNumVarArray

    Posted 02/14/14 02:30 PM

    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


  • 2.  Re: Help to retrive the intermediate values of IloNumVarArray

    Posted 02/18/14 12:52 AM

    You cannot use an IloNumVar as an index into an array.

    One way to work around your problem would be the following:

    1. Instead of using an ILOINT variable Alloc[v2] that can range from through m-1 use an array of m ILOBOOL variables and add the constraint that they must sum to 1 (so that v2 is allocated in exactly one slot):
        IloArray<IloNumVarArray> Alloc(env);
        for (int i = 0; i < n; ++i) {
           IloNumVarArray array(env, m, 0, 1, ILOBOOL);
           IloExpr sum(env);
           for (IloInt j = 0; j < array.getSize(); ++j)
              sum += array[j];
           model.add(sum == 1);
           sum.end();
        }
    2. Instead of using exec_time[v2][Alloc[v2]] you can now use
        IloExpr exec_time_v2(env);
        for (IloInt j = 0; j < Alloc[v2].getSize(); ++j)
           exec_time_v2 += Alloc[v2][j] * exec_time[v2][j];

        model.add(ExecST[v1] >= ExecST[v2] + exec_time_v2;
        exec_time_v2.end();

      exec_time_v2 is exactly the exec_time in the slot to which v2 is allocated (only this slot as Alloc[v2][j] != 0).

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Help to retrive the intermediate values of IloNumVarArray

    Posted 02/19/14 02:04 PM

    Originally posted by: Almakhawi


    hello,

     

    thanks so much.. your idea did work

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Help to retrive the intermediate values of IloNumVarArray

    Posted 02/19/14 06:17 AM

    Originally posted by: Almakhawi


    Hello,

    thank you so much , your idea did work.. 


    #CPLEXOptimizers
    #DecisionOptimization