Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| gurobi [2023/07/14 14:40] – [Interactive mode for testing short computation] admin | gurobi [2023/07/17 06:33] (Version actuelle) – supprimée admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Gurobi Optimizer ====== | ||
| - | ===== Installed version ===== | ||
| - | * 10.0.2 | ||
| - | *Available License : **Academic license - for non-commercial use only** | ||
| - | * You don't need to install or generate your own license file | ||
| - | |||
| - | |||
| - | ===== How to use gurobi ===== | ||
| - | |||
| - | ==== Interactive mode for testing short computation ==== | ||
| - | |||
| - | * Connect to shared node '' | ||
| - | * Always use WORK directory as working area <code bash>$ cd WORK</ | ||
| - | * Load goruby using '' | ||
| - | |||
| - | <WRAP center round important 60%> | ||
| - | * 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 : | ||
| - | <file python | ||
| - | # Solve the following MIP: | ||
| - | # maximize | ||
| - | # x + y + 2 z | ||
| - | # subject to | ||
| - | # x + 2 y + 3 z <= 4 | ||
| - | # x + | ||
| - | # x, y, z binary | ||
| - | |||
| - | import gurobipy as gp | ||
| - | |||
| - | # Create a new model | ||
| - | m = gp.Model() | ||
| - | |||
| - | # Create variables | ||
| - | x = m.addVar(vtype=" | ||
| - | y = m.addVar(vtype=" | ||
| - | z = m.addVar(vtype=" | ||
| - | |||
| - | # 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" | ||
| - | print(f" | ||
| - | |||
| - | </ | ||
| - | |||
| - | Just run : | ||
| - | <code bash> | ||
| - | $ guroby.sh mip.py | ||
| - | </ | ||
| - | ==== Batch mode for long computation==== | ||