1

I want to limit the whole run time to be 1800 s for the given configuration which consists of main problem through which sub-problems:1 & 2 are called. In addition to this, can you please tell me how to set the time limit differently for different sub models? For example if I want to limit the run time of Sub-Problem 1 to 500 s and Sub-Problem 2 to 800 s. I used the line- execute{ cplex.tilim=1800;} as shown in the code description but the program runs for more than 1800 s.




 //-----------------Main-problem.mod-------------------------------
 //variables definition here

 execute {cplex.tilim= 1800;}
 Objective function;

 subject to {
     Constraints:1-7
       }

 execute FillDuals {
     Dual of constraint 1;
         }       
 }   

 main{
 thisOplModel.settings.mainEndEnabled = true;
 thisOplModel.generate();
 var masterDef = thisOplModel.modelDefinition;
 var masterCplex = cplex;
 var masterData = thisOplModel.dataElements;
 var masterOpl = new IloOplModel(masterDef,masterCplex);
 masterOpl.addDataSource(masterData);
 masterOpl.generate();
 masterCplex.solve();
 masterOpl.postProcess();

 //\**************Calling Sub-Problem 1*********************************
 var SubSource1 = new IloOplModelSource("Sub-Problem1.mod");
 var Sub1Def = new IloOplModelDefinition(SubSource1);
 var Sub1Def = thisOplModel.modelDefinition;
 var Sub1Cplex = cplex;
 var Sub1Data = thisOplModel.dataElements;
 var Sub1Opl = new IloOplModel(Sub1Def,Sub1Cplex);
 Sub1Opl.addDataSource(Sub1Data);
 Sub1Opl.generate();
 Sub1Cplex.solve();
 //\****************************************************************

 //\*******************Calling Sub-Problem2*********************************
 var SubSource2 = new IloOplModelSource("Sub-Problem2.mod");
 var Sub2Def = new IloOplModelDefinition(SubSource2);
 var Sub2Def = thisOplModel.modelDefinition;
 var Sub2Cplex = cplex;
 var Sub2Data = thisOplModel.dataElements;
 var Sub2Opl = new IloOplModel(Sub2Def,Sub2Cplex);
 Sub1Opl.addDataSource(Sub2Data);
 Sub2Opl.generate();
 Sub2Cplex.solve();
 //\****************************************************************

 } //end of main

 //--------------------Sub-Problem1.mod------------------------
 variables and constants definition;
 Objective function;
 subject to {
     Constraints:
       }
 //SubOpl1 doesnt have main function main{}

  //-------------------Sub-Problem2.mod----------------------
 variables and constants definitions;
 Objective function;
 subject to {
     Constraints:
       }
 //SubOpl2 doesnt have main function main{}
 //-------------------------------------------------------

sam
  • 31
  • 3

1 Answers1

1

You may set the time limit as you did in the preprocess but you can also do that in the main block:

You could change

Sub1Opl.generate();
Sub1Cplex.solve();

into

Sub1Opl.generate();
Sub1Cplex.tilim=60;
Sub1Cplex.solve();

if you need Sub1CPLEX to stop after 60s.

NB: That time limit applies to the cplex solve so if you need to have a total 1800s time limit for many solves, you need to use a smaller time limit for each solve.

halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thank you Mr. Alex for the information. So, if the configuration is to run for 1800s, the only way is to set the limit for sub problems to smaller values, right? – sam Mar 27 '19 at 20:58
  • I don't see any other way. – Xavier Nodet Apr 05 '19 at 00:35
  • If this answer has solved your question please consider [accepting it](https://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Xavier Nodet Apr 05 '19 at 00:36