Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  solve a model several times

    Posted 08/12/15 01:12 PM

    Originally posted by: Cplex


    Hey guys,

     

    I have to solve my model (maximize the obejctive) several times. I habe to run several scenarios.

     

    My problem looks more or less like that:

     

    forall (k in K) {

         z[k] == 0;

                forall (l in K| l > k) {

                         z[l] == 0;

                            solve model

                               z[l] == 1;                                                   (after solving the model, before solving the model for the next k)

                               z[k] == 1; }}                                          

     

    I'm not sure how to implement that in ILOG.

    How can I do solve the model inside such a loop several times? Maybe I have to put any formulation like "solve model" inside a main block?

     

    Thanks in advance!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: solve a model several times

    Posted 08/18/15 04:00 AM

    Originally posted by: Cplex


    Is there nobody who is able to help me??
     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: solve a model several times

    Posted 08/18/15 12:02 PM

    Originally posted by: Cplex


    Now I tried it in a main block as follows:

     


    main {
     
      var K = 92;
     
       var sum = 0.0;
       
       
         // Create the model and solve it
         var cplex = new IloCplex();
         var source = new IloOplModelSource("KH 3.mod");
         var def = new IloOplModelDefinition(source);
         var opl = new IloOplModel(def, cplex);
         var data = new IloOplDataSource("KH 3.dat");
         opl.addDataSource(data);
         opl.generate();
         for(var k in 1..K){
           for(var l in 1..K| l > k){
                 for(var n in 1..K| n >l){
                   z[k] == 0;
                   z[l] == 0;
                   z[n] == 0;
                   cplex.solve();
                   if (cplex.solve()) {
                     writeln("OBJ = " + cplex.getObjValue());
                   } else {
                     writeln("No solution");
                 }}}}
       
         
         // Cleanup
         opl.end();
         data.end();
         def.end();
         source.end();
         cplex.end();
    }

     

    The model runs but then says that there's no solution. I attached both my model and my data file as well as the model file containing the main block.

     

    I really need some help in this case.

    Thanks!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer