2

I'm currently writing an optimization algorithm for a seating layout on a boeing 777x but using gurobi through python, but in order to do the quadratic optimization, my constraints need to be a positive semi-definite matrix (Q). How can I rewrite my simple constraints to be positive definite or positive semi-definite? Any help is welcome!

I have already tried deleting and altering the constraints to no success.

# !/usr/bin/python
from gurobipy import *

# Create the model to be used in the terminal
m = Model("777x Optimization")

# Name and Create the variables
x1 = m.addVar(name="First-Class Seat Pitch [in]")
x2 = m.addVar(name="First-Class Seat Width [in]")
x3 = m.addVar(name="First-Class Seat Thickness [in]")
x4 = m.addVar(name="Premium-Economy Seat Pitch [in]")
x5 = m.addVar(name="Premium-Economy Seat Width [in]")
x6 = m.addVar(name="Premium-Economy Seat Thickness [in]")
x7 = m.addVar(name="Number of First-Class Rows")
x8 = m.addVar(name="Number of Premium-Economy Rows")
x9 = m.addVar(name="Number of First-Class Seats Per Row")
x10 = m.addVar(name="Number of Premium-Economy Seats per Row")

# Set objective: f(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)
obj = x7*(x1+x2+x3) + x8*(x4+x5+x6)
m.setObjective(obj, GRB.MINIMIZE)

# Add constraints
# m.addConstr((x7*x1*x2)+(x4*x5*x8) <= 342625, "Area Constraint")
m.addConstr(-1512*x8*x10 - 5410*x7*x9 <= -202182, "Ticket Revenue     Constraint")
m.addConstr(0.25*-x5 + 0.35*-x6 +0.4*-x4 <= -18.6975, "Premium-    Economy Comfort Level Constraint")
m.addConstr(0.25*-x2 + 0.35*-x3 +0.4*-x1 <= -29.16, "First-Class     Economy Comfort Constraint")
m.addConstr(-x8*x10 + 1.4*x7*x9 <= 0 , "Ratio of First Class to     Economy Class Seats Constraint")
m.addConstr(-x1 <= -57, "Minimum First-Class Pitch Constraint")
m.addConstr(-x2 <= -25, "Minimum First-Class Width Constraint")
m.addConstr(-x3 <= -3, "Minimum First-Class Thickness Constraint")
m.addConstr(-x4 <= -36, "Minimum Premium-Economy Pitch Constraint")
m.addConstr(-x5 <= -18.5, "Minimum Premium-Economy Width Constraint")
m.addConstr(-x6 <= -1.5, "Minimum Premium-Economy Thickness Constraint")
m.addConstr(x7*x1 + x8*x4 <= 1470, "Rows Constraint")
m.addConstr(x9*x2 <= 163.128, "Seats Per Row Constraint First-Class")
m.addConstr(x10*x5 <= 163.128, "Seats Per Row Constraint Premium-Economy")
m.optimize()

for v in m.getVars():
     print('%s %g' % (v.varName, v.x))

print('Obj: %g' % obj.getValue())



GurobiError: Q matrix is not positive semi-definite (PSD)

Optimize a model with 8 rows, 10 columns and 12 nonzeros
Model has 6 quadratic objective terms
Model has 5 quadratic constraints
Coefficient statistics:
  Matrix range     [2e-01, 1e+00]
  QMatrix range    [1e+00, 5e+03]
  Objective range  [0e+00, 0e+00]
  QObjective range [2e+00, 2e+00]
  Bounds range     [0e+00, 0e+00]
  RHS range        [2e+00, 6e+01]
  QRHS range       [2e+02, 2e+05]
Presolve removed 8 rows and 2 columns
LarrySnyder610
  • 2,277
  • 12
  • 24
  • 1
    Some of the quadratic constraints in your model are not convex, so your `Q` matrix is not positive semidefinite. You won't be able to "trick" it into being PSD by rewriting the constraints. – LarrySnyder610 May 23 '19 at 01:34
  • So if I change these non-convex constraints to convex constraints (by replacing them), the entire Q matrix will become positive semi-definite? Or can I restrict the bounds of the non-convex quadratic equations to regions of convexity? – Engineering45 May 23 '19 at 05:41
  • 1
    This is a tiny problem, so you could feed this easily into a global solver (e.g. Antigone, Baron or Couenne). – Erwin Kalvelagen May 23 '19 at 06:49
  • I agree. Just to add to @ErwinKalvelagen's point, those solvers can handle nonconvex problems. They are generally much slower than convex solvers like Gurobi, but since your problem is very small, they have a chance of working. I don't know offhand whether these solvers can handle *general* integer (x = 0, 1, 2, 3, 4...) variables -- do you know Erwin? – LarrySnyder610 May 23 '19 at 11:59
  • 1
    Yes, these global solvers can handle general integers and more general non-linear expressions. I think the model still needs some work. (I suspect the model will select only one class and not a mix). Of course, a scalar model with x1,x2,x3 is not really what we want to see. – Erwin Kalvelagen May 23 '19 at 12:18
  • @ErwinKalvelagen, I finally obtained a license for BARON and it worked. Thanks a ton for the suggestion, you really helped me out! – Engineering45 May 27 '19 at 20:40

0 Answers0