Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  multiple resolutions

    Posted 08/27/14 07:35 AM

    Originally posted by: medistif@hotmail.fr


    Hello,

    I have a model in cplex (concert technology, c++), i want to launch several resolutions, so i want to do it with a "for" loop  and in change a parameter in each iteration.

    cplex.extract(model);
          
          if(cplex.solve()){
            
              env.out() << cplex.getStatus() << endl;
          
          for(int i = 0; i < k ; i++) {
              
             env.out() << "  " << cplex.getValue(var[i]) << "";
          }
          env.out() << endl;
          
          }
    

    so what have i to put inside for start for example five resolution (all of this code ) ? 

    thank you for your answers.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: multiple resolutions

    Posted 08/27/14 07:45 AM

    Do you want to solve the same model 5 times with different parameter settings or do you want to solve 5 different models?

    In case you want to solve the same model with 5 different parameters settings it is as simple as

    for (int round = 0; round < 5; ++round) {
       cplex.clearModel();
       cplex.extract(model);
       cplex.setParam(...); // Your parameter changes here.
       if ( cplex.solve() ) { ... }
    }

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: multiple resolutions

    Posted 08/27/14 08:07 AM

    Originally posted by: medistif@hotmail.fr


    Yes i want to solve the same model 5 times with different parameter in each iteration. so i will try your example, i want just to know if i would like to change an parameter for example param1 = 0, i have to do it in this line: cplex.setParam(...); ? or can i juste make 

    for (int round = 0; round < 5; ++round) {
       cplex.clearModel();
       cplex.extract(model);
       param1 = 0; //*********changing param1 ? **********//
       cplex.setParam(...); // Your parameter changes here.
       if ( cplex.solve() ) { ... }
    }
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: multiple resolutions

    Posted 08/27/14 11:06 AM

    You need to change parameters using cplex.setParam(...);

    You probably also want to call cplex.setDefaults() at the beginning of the loop to reset all parameters to their default values (I forgot to mention that before).


    #CPLEXOptimizers
    #DecisionOptimization