Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

CPLEX Error 5002: objective is not convex.

  • 1.  CPLEX Error 5002: objective is not convex.

    Posted Mon December 17, 2018 06:24 PM

    Originally posted by: Mili12


    Hi All,

    I'm trying to solve a simple non-convex QP with linear constraints in R using Rcplex and I'm getting the following error: CPLEX Error  5002: objective is not convex. Isn't Cplex supposed to deal with non-convex objectives? not sure how to fix this. Here is a sample that I ran: 

     

    ```r

    A = matrix(c(1,19,1,1),2,2,byrow = TRUE)
    B = matrix(c(2,11,2,2),2,2,byrow = TRUE)

    C = A + B

    D = array(0, dim = c(6,6))

    D[1:2,3:4] = C; D[3:4,1:2] = t(C)
    d = c(0,0,0,0,-1,-1)

    Avec = matrix(c(1,1,0,0,0,0,
                    0,0,1,1,0,0,
                    0,0,A[1,1],A[1,2],-1,0,
                    0,0,A[2,1],A[2,2],-1,0,
                    B[1,1],B[2,1],0,0,0,-1,
                    B[1,2],B[2,2],0,0,0,-1),6,6,byrow = TRUE)

    bvec = c(1,1,0,0,0,0)

    require(Rcplex)

    #control = list(method=4),
    lower = array(0, dim = 6)
    out <- Rcplex(cvec = d,Amat = Avec,bvec = bvec,Qmat = D, control = list(method=4),
                  objsense = "max",sense = c('E','E','L','L','L','L'), n = NA)

    ```

     

    This is the full error that I'm getting:

     

    CPLEX environment opened
    Rcplex: num variables=6 num constraints=6
    CPXPARAM_TimeLimit                               9.9999999999999995e+73
    CPXPARAM_QPMethod                                4
    CPXPARAM_MIP_Tolerances_AbsMIPGap                0
    CPXPARAM_MIP_Pool_RelGap                         0
    CPXPARAM_MIP_Pool_AbsGap                         0
    Number of nonzeros in lower triangle of Q = 4
    Using Approximate Minimum Degree ordering
    Total time for automatic ordering = 0.00 sec. (0.00 ticks)
    Summary statistics for factor of Q:
      Rows in Factor            = 4
      Integer space required    = 4
      Total non-zeros in factor = 10
      Total FP ops to factor    = 30
    CPLEX Error  5002: objective is not convex.
    QP with an indefinite objective can be solved
    to local optimality with optimality target 2,
    or to global optimality with optimality target 3.
    Presolve time = 0.00 sec. (0.00 ticks)
    Barrier time = 0.00 sec. (0.00 ticks)
    Error in Rcplex(cvec = d, Amat = Avec, bvec = bvec, Qmat = D, control = list(method = 4),  : 
      Failed to optimize problem.
    Closed CPLEX environment

     

     

    Any idea on how to fix this?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX Error 5002: objective is not convex.

    Posted Mon December 17, 2018 06:45 PM

    Originally posted by: EdKlotz


    From the Continuous optimization ->Solving problems with a quadratic objective (QP) -> Distinguishing between convex and nonconvex QPs

    section of the User Manual:

    >>>>>>>

     

    By default, CPLEX terminates if the quadratic objective term in a QP is found to be non PSD. In such a case, in order to instruct CPLEX not to terminate, you must set the optimality target parameter. The value that you set for that parameter depends on the type of results that you expect. If you would like CPLEX to compute a point that satisfies first-order optimality conditions (that is, a local optimum), then you set the parameter to the value CPX_SOLUTIONTARGET_FIRSTORDER. If you would like CPLEX to find a global optimum, then you set the parameter to the value CPX_SOLUTIONTARGET_OPTIMALGLOBAL.

     

    >>>>>>>>

     

    The output after the 5002 error above also provides this info:

     

    >>>>

    QP with an indefinite objective can be solved
    to local optimality with optimality target 2,
    or to global optimality with optimality target 3.

     

    >>>>>

     

    And searching this forum for error 5002 generates numerous threads; I'm sure some of them address this as well.

     

    The reasoning for this somewhat counterintuitive behavior of requiring the user to explicitly confirm that they want to solve a nonconvex QP is that, while CPLEX could quietly have gone ahead and invoked its global nonconvex solver, we have seen too many cases where a user inadvertently creates a nonconvex Q matrix when they intended to create a convex one.   So rather than let CPLEX quietly solve an unintended model we ask the user to explicitly confirm their Q matrix is nonconvex, and explicitly decide whether they want a local or global optimal solution.


    #CPLEXOptimizers
    #DecisionOptimization