Decision Optimization

Decision Optimization

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


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

Quadratic constraints in CPLEX callable library

  • 1.  Quadratic constraints in CPLEX callable library

    Posted 01/16/09 06:03 AM

    Originally posted by: SystemAdmin


    [Alimorad said:]

    Dear all

    I have problem to write quadratic constraints like below in CPLEX callable library:

    x1 + x2 - 0.001x1^2 - 0.002x2^2 + 0.0004x1*x2 >=150

    Please help me.
    your consideration will be highly appriciated

    Ali
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Quadratic constraints in CPLEX callable library

    Posted 02/25/09 12:25 AM

    Originally posted by: SystemAdmin


    [EdKlotz said:]

    I have problem to write quadratic constraints like below in CPLEX callable library:

    x1 + x2 - 0.001x1^2 - 0.002x2^2 + 0.0004x1*x2 >=150



    What exactly do you need help with?  Your constraint appears to have a positive
    semi definite quadratic constraint matrix, so CPLEX should solve it without any
    trouble.  If you are asking how to specify such a constraint using CPLEX's
    C API, you need to translate the algebraic expression into matrix form
    x'Qx.  In your example above, this means a Q matrix of


    -.001  .0002
    .0002  -.002

    You can then use a routine like CPXaddqconstr, where you specify the entries
    of Q in triplet notation, specifying the row index column index, and numeric value of Q.  In other words, for the small Q matrix above, going through by column
    rather than row, we have

    quadrow[0] = 0; quadcol[0] = 0; quadval[0] = -.001;  /* Q(0,0) /
    quadrow[1] = 1; quadcol[1] = 0; quadval[0] = .0002;  /
    Q(1,0) /
    quadrow[2] = 0; quadcol[2] = 1; quadval[2] = .0002;  /
    Q(0,1) /
    quadrow[3] = 1; quadcol[3] = 1; quadval[3] = -.002;  /
    Q(1,1) */

    More generally, to translate a quadratic expression from algebraic into matrix form,
    compute the Hessian matrix associated with the algebraic expression.  So, if
    the algebraic quadratic expression is given by q(x), then, letting d denote partial
    differentiation,

    Q(i,j) = 2*d/dxj (d/dxi (q(x))

    Finally, if you find that approach cumbersome, consider using the object oriented
    APIs CPLEX supports for C++, Java or C#.  They allow you to express the quadratic
    expressions of constraints or objectives in the algebraic form you describe above.
    Unless you need the additional levels of control offered by the C API for customizing
    your optimization, you probably are better off taking advantage of the greater expressiveness of the object oriented APIs.
             






    #DecisionOptimization
    #MathematicalProgramming-General