Как я могу переписать свои ограничения, чтобы они были положительными полуопределенными в моем коде оптимизации? - PullRequest
2 голосов
/ 23 мая 2019

В настоящее время я пишу алгоритм оптимизации для рассадки пассажиров на Боинге 777x, но использую gurobi через python, но для выполнения квадратичной оптимизации мои ограничения должны быть положительной полуопределенной матрицей (Q).Как я могу переписать мои простые ограничения, чтобы быть положительно определенным или положительным полуопределенным?Любая помощь приветствуется!

Я уже пытался удалить и изменить ограничения безуспешно.

# !/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
...