Materials for a constraint programming course
This is a short course about constraint programming.
Windows users should first activate WSL using the official instructions (French version). Please install the most recent Ubuntu version (unless you have another version ready.)
You will need to set up by yourself the following pieces:
Visual Studio Code, then install the Python extension:
code --install-extension ms-python.python ms-toolsai.jupyter
Windows users should install Visual Studio Code in Windows (not WSL) then activate the Remote WSL extension:
code --install-extension ms-vscode-remote.remote-wsl
an Anaconda distribution, from the following link. In case the question arises, it is very likely that the best suited version for your needs is the 64 bits one. Anaconda is more than a Python distribution: it also provides additional dependencies you may need;
Windows users should install the Anaconda distribution within their Ubuntu subsystem.
the git
(or git.exe
for Windows users) program, for version control. Using Git falls out of scope of this seminar, but you are strongly encouraged to become proficient with it. You may find resources on GitHub Learning Lab, e.g. the following course for first-timers.
Try running git --version
. If necessary, install git
:
Operating system | Installation command |
---|---|
MacOS | brew install git |
Linux (Ubuntu) | sudo apt install git |
clone the resources for the course:
git clone https://github.com/xoolive/constraints
Windows users should install the dependencies within their Ubuntu subsystem.
You may move the folder at any time if you prefer to keep things sorted differently on your computer.
install the dependencies
cd constraints
pip install -r requirements.txt
A self-documented notebook is available in the notebook folder. The free and open-source facile
library is a basic wrapper around the OCaml facile
solver. You may find more powerful solvers in your future life but this one should do the job to introduce and illustrate the basic concepts of constraint programming in Python.
The notebook for the basic lab session is notebook/lab-session.ipynb
.
Run the following command (in WSL for Windows users):
jupyter lab
Projects should be run as Python scripts from Visual Studio Code.
Open the workspace file (with the WSL connector for Windows users), then access the project folder.
Details about projects are presented on this page.
In case you are stuck with your configuration for the first lab session only, you can fall back to a slightly less comfortable option with Google Colab:
insert a new cell at the top of the notebook with
!pip install 'facile>=1.5'
and execute it to install the library;
%load
commands for the solutions will not work: you will have to copy paste the solutions directly from each of these files.