Skip to content

TBMT42 Labs: General info and optional getting started exercise

The exercises in this course will primarily be done in Python, but some sections will also be done in MATLAB. Both the Python and MATLAB parts will require that you have a valid C++ compiler installed if you want to work locally on your computer. Note that you should be able to use the same compiler for both Python and MATLAB (if installed as in the Python instructions). For the python parts, you can choose to either run the lab locally or via the cloud service Google Colab, that offers a online Python environment.

The Python parts will mostly use a package that we have developed: SUND.

We have put together a collection of the software needed and the steps to install both Python and MATLAB here:

Quick installation of most relevant Python packages (if you are already familiar with Python and pip)

We do recommend uv as the package manger of choice (see installation instructions for uv).

uv init .
uv add matplotlib scipy numpy python-dateutil sund
pip install matplotlib scipy numpy python-dateutil sund

Try to install a simple model

Save this simple model file and add the file to your working repository. Now try to install the model using SUND to see that everything works as intended. First, start python by calling python in your terminal (note that mac users might need to call python3 instead).

uv run python
python

Secondly, run the following bash commands to try to install the "simple_model".

import sund
sund.install_model('simple_model.txt')

If everything worked you should get the print out Model 'simple_model' successfully installed.

  • Install MATLAB (remember to install a compiler if you didn't do it in the first step)
    • For this course, you need the following MATLAB/MathWorks toolboxes: Global optimization toolbox and Statistics and Machine Learning Toolbox.
  • An editor/IDE that you like writing code in. We like Visual Studio Code (VS Code) if you have no other preference

If you feel like you need to freshen up your coding knowledge, before or during the lab exercise, we recommend that you check out Google's Python class. If you are having troubles with how to use SUND, we recommend that you check our introductory SUND exercise.