Beruflich Dokumente
Kultur Dokumente
} Design goals:
◦ Require minimal programming skills to get started
◦ Bring "feel" of a modeling language to the Python interface
◦ Allow for code that is easy to write and maintain
◦ Maintain unified design across all of our interfaces
◦ Remain lightweight and efficient (memory & CPU) when compared with
solver alone
◦ Support all solver and programming needs
} Python programs are typically stored in text files with .py extension
} To run a program:
◦ Windows
At a Command Prompt window, enter
gurobi [program_name]
◦ Linux/Mac
At a terminal, enter
gurobi.sh [program_name]
} Overloaded operators
◦ Basic arithmetic (+, -, ×, ÷)
◦ Constraint (≤, =, ≥)
# Add variables
x = m.addVar(vtype=GRB.BINARY)
y = m.addVar(vtype=GRB.BINARY)
z = m.addVar(vtype=GRB.BINARY)
# Add constraints
m.addConstr(x + 2*y + 3*z <= 4)
m.addConstr(x + y >= 1)
# Solve model
m.optimize()
Ex: ∑ j∈J
xij ≤ 5, ∀i ∈ I can be built with
for i in I:
m.addConstr(quicksum(x[i,j] for j in J) <= 5)
Optimize m.optimize()
http://pythonhosted.org/spyder
} New Conda package simplifies installation for the Anaconda Python distribution
$ conda config --add channels http://conda.anaconda.org/gurobi
$ conda install gurobi
http://www.jupyter.org
http://pandas.pydata.org
http://bokeh.pydata.org