Original Message:
Sent: Mon May 06, 2024 02:59 AM
From: Carlos Ferreiro
Subject: Iterate through scheduling jobs
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
Original Message:
Sent: Mon May 06, 2024 02:29 AM
From: Samuele Viaro
Subject: Iterate through scheduling jobs
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
------------------------------