I need to program a model in python to solve it with gurobi. The model contains a square root: Σ(hza*√(SI+T-R)) (this is the objective function)
Because Gurobi doesn't support square roots I transformed the objective function as followed: Σ(hza*Z) (objective function)
SI+T-R<=Z*Z (extra constrain)
Z>=0 (extra constrain)
But now Gurobi still gives an error :GurobiError: Q matrix is not positive semi-definite (PSD)
How do I get Gurobi to solve this model? The code: (start with line 143 till line 199)
#create objective
for j in intermediateStage:
for d in demandStage:
m.setObjective(quicksum(h[d]*Z*VarDemand[d]*Z2[d] for d in demandStage)+quicksum(h[j]*Z*Z1[j]*Var[j] for j in intermediateStage),GRB.MINIMIZE)
#addconstraints
for j in intermediateStage:
m.addConstr(R[j]-SI[j]<=T[j])
for d in demandStage:
m.addConstr(R[d]-SI[d]<=T[d])
for k in supplyStage:
m.addConstr(R[k]-SI[k]<=T[k])
for j in intermediateStage:
m.addQConstr(SI[j]+T[j]-R[j]<=Z1[j]*Z1[j])
for d in demandStage:
m.addQConstr(SI[d]+T[d]-R[d]<=Z2[d]*Z2[d])
for k in supplyStage:
for j in intermediateStage:
m.addConstr(R[k]-SI[j]<=0)
for j in intermediateStage:
for d in demandStage:
m.addConstr(R[j]-SI[d]<=0)
for d in demandStage:
m.addConstr(R[d]<=E[d])
for k in supplyStage:
m.addConstr(SI[k]==0)
for k in supplyStage:
m.addConstr(SI[k]>=0)
for k in supplyStage:
m.addConstr(R[k]>=0)
for d in demandStage:
m.addConstr(SI[d]>=0)
for d in demandStage:
m.addConstr(R[d]>=0)
for d in demandStage:
m.addConstr(Z2[d]>=0)
for j in intermediateStage:
m.addConstr(SI[j]>=0)
for j in intermediateStage:
m.addConstr(R[j]>=0)
for j in intermediateStage:
m.addConstr(Z1[j]>=0)
m.optimize()
print SI[j]
print R[j]
Traceback (most recent call last): File "C:\gurobi600\win32\examples\python\safetyStock.py", line 230, in safetystock(demand,intermediate,alfa) File "C:\gurobi600\win32\examples\python\safetyStock.py", line 192, in safetystock m.optimize() File "model.pxi", line 536, in gurobipy.Model.optimize (../../src/python/gurobipy.c:37543) GurobiError: Q matrix is not positive semi-definite (PSD)