Gurobi: Difference between revisions

Jump to navigation Jump to search
117 bytes added ,  3 years ago
Marked this version for translation
mNo edit summary
(Marked this version for translation)
Line 127: Line 127:
packages like NumPy, Matplotlib, Pandas and others, we need to create a [[Python#Creating_and_using_a_virtual_environment|virtual Python environment]] in which we can install both <code>gurobipy</code> and e.g. <code>pandas</code>.  Before we start, we need to decide which combination of versions for Gurobi and Python to use.  For example compare the python versions supported by the gurobi 8.11 and 9.0.1 modules:
packages like NumPy, Matplotlib, Pandas and others, we need to create a [[Python#Creating_and_using_a_virtual_environment|virtual Python environment]] in which we can install both <code>gurobipy</code> and e.g. <code>pandas</code>.  Before we start, we need to decide which combination of versions for Gurobi and Python to use.  For example compare the python versions supported by the gurobi 8.11 and 9.0.1 modules:


<!--T:201-->
{{Commands|prompt=[name@server ~] $
{{Commands|prompt=[name@server ~] $
|module load StdEnv/2016  (not needed for gurobi>9.0.2)
|module load StdEnv/2016  (not needed for gurobi>9.0.2)
Line 205: Line 206:
Python scripts can now import both Pandas and Gurobi:
Python scripts can now import both Pandas and Gurobi:


<!--T:202-->
{{Commands|prompt=[name@server ~] $
{{Commands|prompt=[name@server ~] $
| cat my_gurobi_script.py
| cat my_gurobi_script.py
Line 217: Line 219:
Once created we can activate our Gurobi environment at any time with:
Once created we can activate our Gurobi environment at any time with:


<!--T:203-->
{{Commands|prompt=[name@server ~] $
{{Commands|prompt=[name@server ~] $
| module load gurobi/9.0.1
| module load gurobi/9.0.1
Line 226: Line 229:
Note that we now use <code>python</code> instead of <code>gurobi.sh</code>!  This is an example job script that we can use:
Note that we now use <code>python</code> instead of <code>gurobi.sh</code>!  This is an example job script that we can use:


<!--T:204-->
{{File
{{File
   |name=gurobi-py_example.sh
   |name=gurobi-py_example.sh
Line 235: Line 239:
#SBATCH --mem-per-cpu=1000M  # memory per CPU (in MB)
#SBATCH --mem-per-cpu=1000M  # memory per CPU (in MB)


<!--T:205-->
module load StdEnv/2016.4
module load StdEnv/2016.4
module load gurobi/9.0.1
module load gurobi/9.0.1


<!--T:206-->
source ~/env_gurobi/bin/activate
source ~/env_gurobi/bin/activate


<!--T:207-->
# Create environment file in current directory setting the number of threads:
# Create environment file in current directory setting the number of threads:
echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env
echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env


<!--T:208-->
python  my_gurobi_script.py
python  my_gurobi_script.py
}}
}}
Line 248: Line 256:
== Using Gurobi with Jupyter notebooks == <!--T:200-->
== Using Gurobi with Jupyter notebooks == <!--T:200-->


<!--T:209-->
Various topics can be found by visiting [https://support.gurobi.com/ support.gurobi.com] and searching for <I>Jupyter notebooks</I>. "The article titled Where can I learn more about building optimization models?" provides several examples.  Information specific to using Gurobi with Jupyter notebooks on Compute Canada systems will be added to this wiki section in the future as required.
Various topics can be found by visiting [https://support.gurobi.com/ support.gurobi.com] and searching for <I>Jupyter notebooks</I>. "The article titled Where can I learn more about building optimization models?" provides several examples.  Information specific to using Gurobi with Jupyter notebooks on Compute Canada systems will be added to this wiki section in the future as required.


rsnt_translations
56,430

edits

Navigation menu