Last active
April 25, 2018 10:47
-
-
Save abelsiqueira/569b3bf8de7e7976d3656a8ee960891c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
13 | |
Freed default Gurobi environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from gurobipy import * | |
# Create a new model | |
m = Model("soc3") | |
# Create variables | |
x = m.addVar(name="x") # x >= 0 by default | |
y = m.addVar(name="y") | |
# Set objective: x | |
obj = 0.0*x | |
m.setObjective(obj, GRB.MINIMIZE) | |
# Add constraint: y >= 2 | |
m.addConstr(y >= 2, "c0") | |
# Add constraint: x <= 1 | |
m.addConstr(x <= 1, "c1") | |
# Add constraint: y^2 <= x^2 # x >= 0 implicitly | |
m.addQConstr(y*y <= x*x, "c2") | |
m.optimize() | |
print(m.status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment