MATLAB with Gurobi¶
In order to use MATLAB with Gurobi, you need to load both a MATLAB module and a Gurobi module (with prerequisites).
This means you have to start MATLAB from a terminal.
Note
You can use MATLAB and Gurobi together either
- by submitting a job to the batch system with the “batch” command inside MATLAB (GUI or shell)
- by submitting a job to the batch system with a batch script
- by creating a “parpool” with the Kebnekaise cluster
Loading the modules¶
- In a Linux terminal, check which MATLAB version you want:
- Load the version you picked. In this example version 2023a
- Find a compatible version of Gurobi (one that is compiled with the same GCC compiler version).
- Load one of them. Here version 11.0.1
Running jobs from inside MATLAB¶
Note
This assumes you have done the Configuration and setup for MATLAB
- Start MATLAB in the terminal where you loaded the modules. Here
- This starts the MATLAB GUI. If you want to run in a shell, instead do this:
- The following commands are done inside MATLAB
- If you have not added your job settings, do so now - follow the link and go to item 3 on that page.
- You can now start a MATLAB script or function with Gurobi commands in with
where
myFcn
is a command or serial MATLAB program. Preface with@
if a command.numOutput
is the number of output expected{input1, input2, input3, ...}
are the inputs'Pool'
is the parallel poolnWorkers
are how many workers
- Remember that there needs 1 more core than nWorkers