Quantcast
Channel: Yet Another Math Programming Consultant
Viewing all articles
Browse latest Browse all 809

Non-convex quadratic models

$
0
0

Some non-convex quadratic models I


The new version of Gurobi v 9 introduced support for non-convex quadratic models. Cplex already supported some classes of such models (such as non-convex QPs). Here are just some models we can now try to solve with these solvers.

It is noted that you need to specify a solver option for Cplex and Gurobi to accept most non-convex models, Some models can be reformulated by the solver, but "real" con-convex models require the option OptimalityTarget 3 (Cplex) or NonConvex 2 (Gurobi).

1a. Largest Empty Rectangle


Given is an area with \(n\) points:

n=50 random points

The problem is to find the largest empty rectangle, i.e., without any points inside. The solution looks like:

Largest empty rectangle

The idea behind the model below, it that a data point \(p_i\) must be either left, right, below or above the rectangle. So it the coordinates of the rectangle are denoted by \(r_{x,lo},r_{x,up},r_{y_lo},r_{y_up}\), then at least one of the following constraints must hold: \[\begin{align} & p_{i,x} \le r_{x,lo} \\& p_{i,y} \le r_{y,lo} \\ & p_{i,x} \ge r_{x,up} \\& p_{i,y} \ge r_{y,up}\end{align}\] The complete mathematical model to find this rectangle can be stated as:

Smallest empty rectangle
\[\begin{align} \max\> & \color{darkred}{\mathit{area}} = \prod_c (\color{darkred}r_{c,up}-\color{darkred}r_{c,lo}) \\ & \color{darkblue}p_{i,c} \le \color{darkred}r_{c,lo}+\color{darkblue}M_c(1-\color{darkred}\delta_{i,c,lo}) && \forall i,c\\ & \color{darkblue}p_{i,c} \ge \color{darkred}r_{c,up}-\color{darkblue}M_c(1-\color{darkred}\delta_{i,c,up}) && \forall i,c\\ & \sum_{c,s} \color{darkred}\delta_{i,c,s} \ge 1 && \forall i \\ & \color{darkblue} L_c \le \color{darkred}r_{c,lo} \le \color{darkred}r_{c,up}\le \color{darkblue} U_c \\ & \color{darkred}\delta_{i,c,s} \in \{0,1\} \end{align} \]
\[\begin{align} & i = \{1,\dots,n\}\\ & c = \{x,y\}\\ & s = \{lo,up\} \\ & \color{darkblue} L_c = 0 \\ & \color{darkblue} U_c = 1 \\ & \color{darkblue} M_c = \color{darkblue}U_c-\color{darkblue}L_c \end{align}\]


For the 2d case, the objective can be written as \[\min\> \mathit{area} = (r_{x,up}-r_{x,lo})\cdot (r_{y,up}-r_{y,lo})\] The outer area is a given rectangle with limits \(L_x, U_x, L_y, U_x\). I used here the unit box: \(L_x=L_y = 0\) and \(U_x=U_y = 1\). The big-M constants \(M_x, M_y\) need tight values. We can use the area dimensions for that. For a formulation without big-M constraints, we can implement implications using indicator constraints: \[\begin{align} & \delta_{i,c,lo}=1 \implies p_{i,c} \le r_{i,c,lo} \\ &\delta_{i,c,up}=1 \implies p_{i,c} \ge r_{i,c,up}\end{align}\]

The problem is not convex because of the objective. It is noted that we can simplify the objective a bit by writing \[\begin{align}\max\>&\mathit{area} =  \mathit{side}_x \cdot \mathit{side}_y\\ & \mathit{side}_c = r_{c,up} - r_{c,lo}\end{align}\] This is a small problem with just 4 continuous quadratic variables and \(n\times 4\) binary variables. Gurobi or Cplex solve this model very quickly.

This problem can also be solved with available global solvers. Both Antigone and Baron have no problems with it. I also tried the open-source solver Couenne. That was a surprise:


               S O L V E      S U M M A R Y

MODEL m OBJECTIVE area
TYPE MIQCP DIRECTION MAXIMIZE
SOLVER COUENNE FROM LINE 49

**** SOLVER STATUS 1 Normal Completion
**** MODEL STATUS 1 Optimal
**** OBJECTIVE VALUE 0.0121


---- 50 VARIABLE area.L = 0.012

---- 50 VARIABLE r.L coordinates of rectangle

lo up

x 0.9390.982
y 0.7201.000

This is obviously a bad solution. I don't know what is going on here.

1b. 3d largest box 


It is easy to make a 3d version of the model above. Just replace \(c = \{x,y\}\) by \(c = \{x,y,z\}\). Unfortunately, there is one complication: now the model has an objective that is no longer quadratic. However, this can be fixed by chaining: \[\begin{align} \max\>&\mathit{volume} = \mathit{area}\cdot \mathit{side}_{z}\\ & \mathit{area} = \mathit{side}_{x} \cdot \mathit{side}_{y} \\ & \mathit{side}_c = r_{c,up}-r_{c,lo} && \forall c \end{align}\]

A solution can look like:


----     52 VARIABLE area.L                =        0.340
VARIABLE volume.L = 0.146

---- 52 VARIABLE r.L coordinates of 3D box

lo up

x 0.6080.998
y 0.0910.963
z 0.1400.571

Note that Cplex can not handle this problem: Cplex allows non-convexities in the objective only (apart for some cases where it can reformulate things).

3d version: largest box not clashing with given points



2. Hostile Brothers Problem



A father is facing the following problem. He has has a plot of land. And he has \(n\) sons, who don't get along at all. In order to minimize friction, he wants to build a house for each of his sons, such that the minimum distance between them is maximized. The mathematical model can look like:


Hostile Brothers Problem
\[\begin{align} \max\> & \color{darkred}z \\ & \color{darkred}z \le \sum_{c} (\color{darkred}x_{i,c}-\color{darkred}x_{j,c})^2&& \forall i\lt j\\ & \color{darkred}x_{i,c} \in [\color{darkblue}L,\color{darkblue}U]\end{align} \]

Here \(i\) indicates the point, \(i \in \{1,\dots,n\}\) and \(c\) is the coordinate. For a 2D problem, we have \(c \in \{x,y\}\).

When we use \(n=50\) random points, Gurobi is not able to even come close to proven optimality, I used a time limit of 2 hours, and the final gap is enormous:


156030713547850.404874216530.019350.671733371%   3327171s
15620851356368 cutoff 2830.019350.671733371% 3327177s
15630231356980 cutoff 2850.019350.671733371% 3327180s
156456513580710.019372489300.019350.671733371% 3327190s
156572013592050.600714815100.019350.671733371% 3327196s
15673351359826 cutoff 2720.019350.671733371%3327200s


Cutting planes:
RLT:
1312

Explored
1567341 nodes (520860935 simplex iterations) in 7200.00 seconds
Thread count was
8 (of 16 available processors)

Partly this is because the best-found solution (0.01935) has as an objective close to zero. But mainly: this is a very difficult job for Gurobi. Even when the problem is relatively small: just 100 continuous variables,

By inspecting the solution, we see this solution is not very good at all:

Solution found by Gurobi after 2 hours (obj=0.01935)


We can try to improve performance by noticing there is much symmetry in the model. The same solution can be obtained by just renumbering the points. To break symmetry, I added the constraint: \[\sum_c x_{i,c} \ge \sum_c x_{i-1,c}\] This was not very successful:


297897224071710.017081308130.008850.642717159%   2227180s
298110924092320.527206423780.008850.642717159% 2227185s
298464824115000.2039910721560.008850.642717159% 2227191s
298630224128110.1222012717210.008850.642717159% 2227195s
298785224138790.0694217517280.008850.642717159% 2227200s

Explored 2988184 nodes (662244035 simplex iterations) in 7200.01 seconds
Thread count was 8 (of 16 available processors)

So we see:

  • The best-found solution is worse than before
  • The best possible solution is better than before
  • The relative gap is worse
As an alternative, let's try Baron on this model. We see:


  Iteration    Open nodes         Time (s)    Lower bound      Upper bound
*
115.540.905387E-032.00000
1110.470.905387E-032.00000
*
6437.400.204312E-011.72727
*
6438.310.221058E-011.72727
*
10678.260.228371E-011.72727
*
10680.090.238434E-011.72727
2614111.460.238434E-011.72727
3920144.680.238434E-011.72727
5227176.200.238434E-011.72727
6433200.010.238434E-011.72727

I.e. Baron finds a much better solution very quickly (but is far from getting the gap close to zero).

Another approach is to use a multi-start approach with a local NLP solver. Generate a random starting point, solve, and repeat. When I do this 20, I see when I use the CONOPT NLP solver:



----     57 PARAMETER objs  objective values of NLP solver

cycle1 0.02751, cycle2 0.02669, cycle3 0.02705, cycle4 0.02041, cycle5 0.02620, cycle6 0.01235
cycle7 0.02675, cycle8 0.02590, cycle9 0.02660, cycle10 0.02679, cycle11 0.02558, cycle12 0.02644
cycle13 0.02622, cycle14 0.02625, cycle15 0.02620, cycle16 0.02749, cycle17 0.02742, cycle18 0.02692
cycle19 0.02675, cycle20 0.02688, best 0.02751

This is the best we have seen so far. By accident, the best results were found in the first cycle. The results look like:

Best solution with Multi-start Conopt (obj=0.02751)

This solution looks much better than the one Gurobi found. In addition, CONOPT needs only 30 seconds to solve these 20 problems.

Conclusion:

  • Cplex cannot solve this problem
  • Gurobi finds a solution with objective 0.01935 (time limit: 2 hours)
  • Baron finds a solution of 0.02384 in 100 seconds
  • Conopt finds a solution of 0.02751 in a loop that takes 30 seconds  
Even though this is a non-convex quadratic problem, it makes sense to look beyond quadratic solvers.




Viewing all articles
Browse latest Browse all 809

Trending Articles