Decision Optimization

Decision Optimization

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


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

populatebynonzero when each constraint does not include all decision var.

  • 1.  populatebynonzero when each constraint does not include all decision var.

    Posted 02/13/11 08:24 AM

    Originally posted by: mkmk


    In the example lpex1.c, the constraints include all the decision variables

    Maximize
    obj: x1 + 2 x2 + 3 x3
    Subject To
    c1: - x1 + x2 + x3 <= 20
    c2: x1 - 3 x2 + x3 <= 30
    Bounds
    0 <= x1 <= 40

    When implementing populatebynonzero, it defines all the rowlist, collist, and vallist as following.

    rowlist[0] = 0; collist[0] = 0; vallist[0] = -1.0;
    rowlist[1] = 0; collist[1] = 1; vallist[1] = 1.0;
    rowlist[2] = 0; collist[2] = 2; vallist[2] = 1.0;
    rowlist[3] = 1; collist[3] = 0; vallist[3] = 1.0;
    rowlist[4] = 1; collist[4] = 1; vallist[4] = -3.0;
    rowlist[5] = 1; collist[5] = 2; vallist[5] = 1.0;

    IF the equation is

    Maximize
    obj: x1^2 + 2 x2 + 3 x3
    Subject To
    c1: x2 + x3 <= 20
    c2: x1 - 3 x2 <= 30
    Bounds
    0 <= x1 <= 40

    then how can I define rowlist, collist, and vallist?

    can I just leave the non-included decision variables blank? or ignore them??

    rowlist[0] = 0; collist[0] = 1; vallist[0] = 1.0;
    rowlist[1] = 0; collist[1] = 2; vallist[1] = 1.0;
    rowlist[2] = 1; collist[2] = 0; vallist[2] = 1.0;
    rowlist[3] = 1; collist[3] = 1; vallist[3] = -3.0;

    Thanks much for your help!!
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: populatebynonzero when each constraint does not include all decision var.

    Posted 02/13/11 03:12 PM

    Originally posted by: SystemAdmin


    Yes, you have the right idea. Sparse matrix entry is fundamental to CPLEX's API, otherwise handling of problems with thousands of variables and constraints would be close to impractical. A few notes on the specifics of your problem modifications:

    1) Adjust the dimension of the function call that passes the arrays to CPLEX:
    status = CPXchgcoeflist (env, lp, 4, rowlist, collist, vallist);

    2) CPLEX solves quadratic models only if they are convex, so the objective function as you modified it should have a negative coefficient for a maximization problem, -1 rather than 1.

    3) Using the C API, there is a convention that quadratic coefficients are to be divided by 2 by the solution algorithms, so this is reflected in the following call that can be added after the CPXchgcoeflist() call in this example program:
    status = CPXchgqpcoef (env, lp, 0, 0, -2);

    For other approaches to dealing with quadratic formulations, consult the quadratic examples provided alongside the lpex1.c you are working from, and review the User's Manual section on quadratic models.
    #CPLEXOptimizers
    #DecisionOptimization