Skip to content

Instantly share code, notes, and snippets.

@abelsiqueira
Created April 25, 2018 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abelsiqueira/c47af3df4b6398247c69d38dda7f3d5e to your computer and use it in GitHub Desktop.
Save abelsiqueira/c47af3df4b6398247c69d38dda7f3d5e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from gurobipy import *
m = Model("minex")
x = m.addVar(name="x", vtype=GRB.CONTINUOUS, lb=0.0)
y = m.addVar(name="y", vtype=GRB.CONTINUOUS, lb=0.0)
m.setObjective(0.0 * x, GRB.MINIMIZE)
m.addConstr(y >= 2, "c0")
m.addConstr(x <= 1, "c1")
m.addQConstr(y*y <= x*x, "c2")
m.optimize()
print(gurobipy.gurobi.version())
print(m.status)
Academic license - for non-commercial use only
Optimize a model with 2 rows, 2 columns and 2 nonzeros
Model has 1 quadratic constraint
Coefficient statistics:
Matrix range [1e+00, 1e+00]
QMatrix range [1e+00, 1e+00]
Objective range [0e+00, 0e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 2e+00]
Presolve removed 2 rows and 0 columns
Presolve time: 0.00s
Barrier solved model in 0 iterations and 0.00 seconds
Model is infeasible
(7, 5, 2)
3
Academic license - for non-commercial use only
Optimize a model with 2 rows, 2 columns and 2 nonzeros
Model has 1 quadratic constraint
Coefficient statistics:
Matrix range [1e+00, 1e+00]
QMatrix range [1e+00, 1e+00]
Objective range [0e+00, 0e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 2e+00]
Presolve removed 2 rows and 2 columns
Presolve time: 0.00s
Presolve: All rows and columns removed
Barrier solved model in 0 iterations and 0.00 seconds
Optimal objective 0.00000000e+00
(8, 0, 0)
13
Freed default Gurobi environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment