Ceci est une ancienne révision du document !


Gurobi Optimizer

  • 10.0.2
  • Available License : Academic license - for non-commercial use only
  • You don't need to install or generate your own license file
  • Connect to shared node mesoshared.univ-fcomte.fr using SSH
  • Always use WORK directory as working area
    $ cd WORK
  • Load goruby using module command
    $ module load guroby/10.0.2
  • You don't need to setup any license.
  • You will use one provided by meso-admins
  • Please contact us if you noticed any problem

From now on you can use guroby directly.

Say you need to run this python program :

mip.py
# Solve the following MIP:
#  maximize
#        x +   y + 2 z
#  subject to
#        x + 2 y + 3 z <= 4
#        x +   y       >= 1
#        x, y, z binary
 
import gurobipy as gp
 
# Create a new model
m = gp.Model()
 
# Create variables
x = m.addVar(vtype="B", name="x")
y = m.addVar(vtype="B", name="y")
z = m.addVar(vtype="B", name="z")
 
# Set objective function
m.setObjective(x + y + 2 * z, gp.GRB.MAXIMIZE)
 
# Add constraints
m.addConstr(x + 2 * y + 3 * z <= 4)
m.addConstr(x + y >= 1)
 
# Solve it!
m.optimize()
 
print(f"Optimal objective value: {m.objVal}")
print(f"Solution values: x={x.X}, y={y.X}, z={z.X}")
  • gurobi.1689345019.txt.gz
  • Dernière modification : 2023/07/14 14:30
  • de admin