# User:Jarle Pahr/Gurobi

Notes on Gurobi optimizer:

Gurobi optimizer reference manual: http://www.gurobi.com/documentation/5.5/reference-manual/refman

Gurobi optimizer quick start: http://www.gurobi.com/documentation/5.5/quick-start-guide/quickstart

Quick start guide Python Interface: http://www.gurobi.com/documentation/5.5/quick-start-guide/node93

The Gurobi Python Interface for Python Users: http://www.gurobi.com/documentation/5.5/quick-start-guide/node39

Python reference manual: http://www.gurobi.com/documentation/5.5/reference-manual/node541

Python commands and examples:

```import gurobipy as gurobi
```
``` m = gurobi.Model("mip1")
```
```x = m.addVar(vtype=gurobi.GRB.BINARY, name = "x")
y = m.addVar(vtype=gurobi.GRB.BINARY, name = "y")
z = m.addVar(vtype=gurobi.GRB.BINARY, name = "z")
m.update()
m.setObjective(x + y + 2 * z, gurobi.GRB.MAXIMIZE)
m.addConstr(x + 2 * y + 3 * z <=4, "c0")
m.update()
m.optimize()
for v in m.getVars():
```

print v.varName, v.x

```print 'Obj:', m.objVal
```

Using Gurobi to solve an FBA problem:

# Python functions and methods

Model.getVarByName() : http://www.gurobi.com/documentation/5.5/reference-manual/node581

• Used to manually update the model after changes.
• The model is automatically updated before optimization.

Model.optimize(): http://www.gurobi.com/documentation/5.5/reference-manual/node584

Objects:

• Add one linear expression into another.

# Attributes

A Gurobi model consists of decision variables (objects of class Var), an objective function

Gurobi model attributes: http://www.gurobi.com/documentation/5.5/reference-manual/node680

• Oldest