Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Adding constraints to model

    Posted 06/15/12 06:27 PM

    Originally posted by: akshuneya


    Hello all,
    Does anyone know how to add constraints to existing model?
    My solution method is,
    1) Solve Model 1.
    2) Solve Model 2.
    3) Based on solution of (2) add constraint to Model 1.
    4) Repeat the process of (1)-(3).
    I tried using method given in,
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14590431&#14590431
    But the when I run my script, it is giving me error saying I can’t add constraint to Model1 as it is not the active model (because just before adding constraint I had solved Model2).

    Does anyone have solution to this problem?
    I am using CPLEX 12.4 and modeling with IDE.

    Thank you!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Adding constraints to model

    Posted 06/16/12 09:10 AM
    Hi,

    could the following code help you?

    dvar float+ Gas;
    dvar float+ Chloride;
     
     
    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
      ctMaxTotal2:    
        3 * Gas + 4 * Chloride <= 180;
      ctMaxChloride:  
        Chloride <= 40;
       ctVide:
         Gas<=infinity;
    }
     
     main
     {
       thisOplModel.generate();
       cplex.solve();
       writeln(thisOplModel.Gas," ",thisOplModel.Chloride);
       
       var model2=thisOplModel;
       var cplex2=cplex;
       model2.ctVide.UB=5;
       model2.ctVide.setCoef(thisOplModel.Gas,-1);
       model2.ctVide.setCoef(thisOplModel.Chloride,1);
       cplex2.solve();
       writeln(model2.Gas," ",model2.Chloride);
     
      var cplex3=new IloCplex();;
       var model3=new IloOplModel(thisOplModel.modelDefinition,cplex3);;
       model3.generate();
       cplex3.solve();
       writeln(model3.Gas," ",model3.Chloride);
       
       
       
     }
    


    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Adding constraints to model

    Posted 06/18/12 06:46 PM

    Originally posted by: SystemAdmin


    Thanks!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer