# Formulating a MINLP for CPLEX in PYOMO

I am trying to do my first MINLP problem using PYOMO and CPLEX - although I am not committed to using CPLEX, but it was recommended to me. To my understanding you need to formulate your problem in terms of matricies. However, In my own problem I have an exponential term which is a function of three other variables - the equation is a type of growth function for context:

$$I^{(i,j)}_{\,t+1,pre} \!= R_t I^{(i,j)}_{\,t,pre}\;e^{-\beta\bigl(J^{(i,j)}_{\,t+1}+I^{(i,j)}_{t}+I^{(i,j)}_{\,t-1}\bigr)}$$

In PYOMO I could probably code the constraint something like the following:


# Define the index sets for the grid and time horizons.

# Defining the maximum value that the index can take. e.g. j = {1, 2, 3, ... , model.Jmax}
model.Imax = Param(within=NonNegativeIntegers) # Value = 10
model.Jmax = Param(within=NonNegativeIntegers) # Value = 10
model.Tmax = Param(within=NonNegativeIntegers) # Value = 7

# Constructing the actual indicies used for the problem.
model.Iset = RangeSet(1, model.Imax) #e.g i = {1, 2, 3, ... , model.Imax=10}
model.Jset = RangeSet(1, model.Jmax)
model.Tset = RangeSet(1, model.Tmax)

# Constraint
def Ipre_Recruitment(model):
return model.Ipre == model.R * exp([EXPRESSION])

model.Ipre_constraint = Constraint(rule = Ipre_Recruitment)


While the code is not by any means accurate, the idea is that I could more easily code up the constraint as it is in contrast to figuring out how to generate a matrix formulation.

The question I have then is if I am able to keep coding my MINLP in PYOMO in the manner that I have shown above, would you need to use a different solver to code it in this way, or do I need to restart somehow?

• The only nonlinearities CPLEX can handle are quadratics (and second order cone constraints). So unless you can reduce it to such a form by taking log, or something, you will need a different solver. – Mark L. Stone Aug 10 at 19:37
• Okay. But let's suppose that I find a solver that can handle the exponential function, call it SOLVR for the sake of a name. Would the way in which I go about writing the model in PYOMO be okay or would I need to explicitly define things in terms of a matrix. – D.Gray Aug 10 at 19:43
• I will leave that to someone knowledgeable in PYOMO. – Mark L. Stone Aug 10 at 19:44

As mentioned in the comments, CPLEX cannot handle MINLP problems which are not Mixed-Integer Second-order cones (MISOCP) and Mixed-integer quadratic or quadratically constrained programs (MIQP and MIQCP). Given that you have a general nonlinear constraint, you cannot write it in a matrix was, meaning that you cannot express the exponential constraint $$g(x)=\exp(x) \leq 0$$ as a matrix (in)equality $$Ax \leq b$$. Fortunately, Pyomo allows you to write down general nonlinear optimization problems using the expressions' syntax as you can check here.