Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

scalar in script

  • 1.  scalar in script

    Posted 03/09/14 02:32 PM

    Originally posted by: arjaree


    Hi,

    from BasketballScheduling example, if I have scalar data to pass on from 1st model to 2nd model, how can I do that please?

    Thank you so much.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: scalar in script

    Posted 03/10/14 11:09 AM

    Hi,

    in the documentation, you have the example

    For the following basic model:
    float maxOfx = ...;
    dvar float x;
    
    maximize x;
    subject to {
      x<=maxOfx; 
    }
    
    and the following data:
      maxOfx=10;
    
    Flow control script:
    main { 
      var source = new IloOplModelSource("basicmodel.mod");
      var cplex = new IloCplex();
      var def = new IloOplModelDefinition(source);
      var opl = new IloOplModel(def,cplex);
      var data = new IloOplDataSource("basicmodel.dat");
      opl.addDataSource(data);
      opl.generate();
      if (cplex.solve()) {
         writeln("OBJ = " + cplex.getObjValue());
      } else {
         writeln("No solution");
      }
      var opl2 = new IloOplModel(def,cplex);
      var data2= new IloOplDataElements();
      data2.maxOfx=11;
      opl2.addDataSource(data2);
      opl2.generate();
    
      if (cplex.solve()) {
         writeln("OBJ = " + cplex.getObjValue());
      } else {
         writeln("No solution");
      }
    
      opl.end();
      opl2.end();
      data.end(); 
      def.end(); 
      cplex.end(); 
      source.end(); 
    }
    

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer