# Decision Optimization

View Only

## Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.->.

• #### 1.  Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.->.

Posted Mon March 06, 2023 05:16 AM
Edited by Portia Melita Mon March 06, 2023 09:17 AM

Hi everyone,

I am currently trying to solve this problem but I always got error. Could anyone please help me to solve the problem! I added the initualize n[i][j]==1 but it also didn't work. Thank you!

``````// Sets

range A = 1..2;
range B = 1..2;

// Parameters
float S[A] = [10, 12];
float K[A] = [200, 300];
float u[A]= [1,1.5];
float hp = 0.5;
float D = 2000;

// Variables
dvar float+ Q[A][B];
dvar float n[A][B] in 0..100;

// Objective
minimize
sum(i in A, j in B) n[i][j]*S[i] + (hp*sum(i in A, j in B) Q[i][j])/2 + sum(i in A, j in B)n[i][j]*Q[i][j]*u[i];

// Constraints
subject to {
sum(i in A, j in B) n[i][j]*Q[i][j] <= D;
forall(i in A)
sum(j in B) Q[i][j] <= K[i];
}
``````

------------------------------
Hang Vu
------------------------------

• #### 2.  RE: Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.->.

IBM Champion
Posted Mon March 06, 2023 11:08 AM

Your first constraint, in which you multiply the decision variables n and Q, makes the feasible region nonconvex, which leads to the error. If n is actually a decision variable, as opposed to a parameter, and is actually continuous rather than integer, then you will have to find a different solver. If n is an integer decision variable, then it would be possible (but cumbersome) to linearize the first constraint by converting n to a bunch of binary variables.

------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
------------------------------

• #### 3.  RE: Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.->.

Posted Wed March 08, 2023 12:44 AM
Edited by Hang Vu Wed March 08, 2023 12:52 AM

Thank you professor Rubin for the advice!

My objective function contains non-linear part too. Is it fine to go with either two ways that you recommended?

I am too new to this problem. Could you please kindly share to me the related materials or textbook about converting them to linear?

Thank you again, professor Rubin!

------------------------------
Hang Vu
------------------------------

• #### 4.  RE: Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.->.

IBM Champion
Posted Wed March 08, 2023 11:09 AM

CPLEX can contend with the nonlinear objective (although it may not find a guaranteed optimal solution), but it cannot contend with the nonlinear constraint. Unfortunately, I do not know of any learning materials specific to linearization of nonlinear constraints, but I can say that versions of the question occur regularly on Operations Research Stack Exchange. If your n variable is integer, I suggest searching there using the keywords "linearize" and "product". If n is not integer-valued, then you can ask there for recommendations regarding NLP solvers.

------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
------------------------------

• #### 5.  RE: Exception from IBM ILOG CPLEX: CPLEX Error 5002: 'q1' is not convex.->.

Posted Wed March 08, 2023 11:24 PM

Thank you so much for sharing and advising, professor Rubin!

Hope you have a great day.

------------------------------
Hang Vu
------------------------------