Decision Optimization

 View Only
  • 1.  Iterate through scheduling jobs

    Posted Mon May 06, 2024 02:30 AM

    Hello, 
    the scheduling model I wrote cannot be solved to optimality due to the large number of constraints and variables. Therefore I have decided to proceed by scheduling a subset of jobs at every iteration, save the solution and use it in the next iteration. 
    In my .mod file I have 

    {int} J = {1,2};
    dvar float+ t[j in J, i in I]; 

    and all the constraints go over the set J.
    then the simplified version of my .cpp file, where I believe there is the issue, is

    IloOplRunConfiguration rc(env,"./dynamic.mod",/dynamic.dat");
    IloInt job=3;
    while (job <= jobMax) 
      {
        rc.getOplModel().generate();
        rc.getCplex().solve();
        rc.getOplModel().getElement("J").asIntSet().add(job);
        job++;
      }

    Before saving the solution at each iteration I wanted to test this...which it does not work! It returns an error the first time I tried to add a job to the set of jobs J

    I also tried to iterate as in the example mulprod_main.cpp without any luck...

    Any ideas??

    Thanks

    Sam



    ------------------------------
    Samuele Viaro
    ------------------------------


  • 2.  RE: Iterate through scheduling jobs

    Posted Mon May 06, 2024 09:14 AM

    Hello Samuele,

                   First, I think that you have to put J = {1,2}; in your .dat file and {int} J = ...; in your .mod file.

    And after, you can retry to use the mulprod_main.cpp, i-e create an

    IloOplRunConfiguration rcIteration(rc.getOplModel().getModelDefinition(), dataElements); in your loop.

    Where dataElements  is defined as follow: IloOplDataElements dataElements = rc.getOplModel().makeDataElements(); before your loop.

    Best regards



    ------------------------------
    Thierry Sola
    ------------------------------



  • 3.  RE: Iterate through scheduling jobs
    Best Answer

    Posted Mon May 13, 2024 05:20 AM

    Thank you a lot...I made it work!



    ------------------------------
    Samuele Viaro
    ------------------------------



  • 4.  RE: Iterate through scheduling jobs

    Posted Mon May 06, 2024 09:48 AM

    The problem seems to be in the way you're trying to modify the set J after generating the model. In CPLEX, once a model has been generated, it cannot be directly modified. Instead, you would have to regenerate the model with the new set J.

    Here's an example of how you could do it:

    IloInt job=3;
    while (job <= jobMax) 
    {
      rc.end();
      rc = IloOplRunConfiguration(env,"./dynamic.mod",/dynamic.dat");
      rc.getOplModel().getElement("J").asIntSet().add(job);
      rc.getOplModel().generate();
      rc.getCplex().solve();
      job++;
    }
    

    In this code, rc.end(); ends the current configuration before creating a new one with the updated set J. Then, the model is generated and solved as before.

    I hope this helps."



    ------------------------------
    Carlos Ferreiro
    ------------------------------



  • 5.  RE: Iterate through scheduling jobs

    Posted Mon May 13, 2024 05:21 AM

    Thank you a lot...I made it work!



    ------------------------------
    Samuele Viaro
    ------------------------------