Decision Optimization

 View Only
Expand all | Collapse all

Cplex parallel optimization using IloOplExec() in a main{}

  • 1.  Cplex parallel optimization using IloOplExec() in a main{}

    Posted Sun February 19, 2023 07:53 PM

    Hi everyone,

    I recently set up a Cplex sequential model that calls data from a database, does an annual optimization and publishes in the database when it's over. So I have a main.mod that iterates over the years :

    main {

          var source = new IloOplModelSource("MyModel.mod");

          var cplex = new IloCplex();

          var def = new IloOplModelDefinition(source);




          for(var k=2023;k<=2024;k++)


          var opl = new IloOplModel(def,cplex);

          var dataParam= new IloOplDataElements();



          writeln("ResolutionYear : " + dataParam.ResolutionYear);

          var data = new IloOplDataSource("Parameters.dat");

          var data2 = new IloOplDataSource("LectureBD.dat");

          var data3 = new IloOplDataSource("PublicationBD.dat");





          if (cplex.solve()) { 


             writeln("OBJ = " + cplex.getObjValue());

          } else {

             writeln("No solution");





    Now, in order to reduce the computation time, I would like to run the annual optimization in parallel. I've read this thread ( about using the command IloOplExec() but I don't manage to include it to my main.mod. I think that all the problem revolves around the fact that the parameter "ResolutionYear" is used in the "LectureBD.dat" (to read the data from the database") but I didn't manage to make solve that problem.

    Does anyone have an idea that could solve my issue ?

    Thank you for your help

    Grégoire Turzo

  • 2.  RE: Cplex parallel optimization using IloOplExec() in a main{}

    Posted Mon February 20, 2023 02:34 AM


    to do that // run I used to use IloOplExec but with recent versions IloOplExec waits for the process to end so I moved to writing a shell script from OPL and then execute that script from OPL.

    See in how to with OPL

    [Alex] [Fleischer]
    [Data and AI Technical Sales]