Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Quadratic Constraints in Java Concert 12.1

    Posted 02/03/12 10:45 AM

    Originally posted by: nynoles


    Hello,

    I am currently using Java Concert 12.1 and am interested in adding quadratic constraints to my mathematical program and can't seem to find either the interface IloLQNumExpr or something that will allow me to add quadratic terms to my constraints. Thanks in advance for your help.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Quadratic Constraints in Java Concert 12.1

    Posted 02/03/12 11:07 AM

    Originally posted by: SystemAdmin


    You can use cplex.prod() to create products of variables as in this code snippet:
    import ilog.cplex.*;
    import ilog.concert.*;
     
    public final class QuadCons {
       public static void main(String[] args) {
          try {
             IloCplex cplex = new IloCplex();
             IloNumVar x = cplex.numVar(0, 1, "x");
             IloNumVar y = cplex.numVar(0, 1, "y");
             IloNumVar z = cplex.numVar(0, 1, "z");
             // Add constraint 2x^2 + 3xy + 4z <= 5
             cplex.addLe(cplex.sum(cplex.sum(cplex.prod(2, cplex.prod(x, x)),
                                             cplex.prod(3, cplex.prod(x, y))),
                                   cplex.prod(4, z)),
                         5);
             cplex.exportModel("model.lp");
             cplex.end();
          } catch (IloException e) {
             System.err.println(e.getMessage());
             e.printStackTrace();
             System.exit(-1);
          }
       }
    }
    

    Or switch to CPLEX 12.3 or later, support for quadratic expressions was improved for this version.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Quadratic Constraints in Java Concert 12.1

    Posted 02/03/12 11:35 AM

    Originally posted by: nynoles


    Thank you very much. I tried updating to 12.3 but was having some trouble with the install. I will have to do this for now and try the install again at another time.
    #CPLEXOptimizers
    #DecisionOptimization