User Tools

Site Tools


Using Numberjack

Numberjack is a modelling package written in Python for constraint programming.

Numberjack let's you specify Constraint Satisfaction Problems very easily using Python. Numberjack then interfaces with multiple state of the art solvers to solve the problem and return the solution as a python object.

We will be using Numberjack for some of the assignments in the course.

Make sure to update your VM to install Numberjack. This update will take a significant amount of time this time (think about 10 min).

sudo apt-get update
sudo update_intro_to_autonomy

(Make sure that you run the apt-get update command first, otherwise the VM update may fail)

Numberjack is very easy to use, but we have included an example notebook to get you started.

Open the notebook(s) in the NumberjackExamples folder inside the example_notebooks folder in jupyter. You will find multiple example problems there.

If you want to learn more about Numberjack, you can also check its documentation page. In particular check the Global Constraints page to see the kind of constraints that Numberjack lets you specify very easily.

Installing Numberjack from Source

For some students, Numberjack is not installing SCIP correctly when running sudo update_intro_to_autonomy. To verify that this is your problem, run the following code in a Jupyter notebook and make sure you do not see SCIP in the list:

import Numberjack

If you are experiencing this issue, we can fix it by installing Numberjack from source.

1. Go to, click 'Clone or download' and then 'Download ZIP'. Save the file.

2. Go to wherever you saved the .zip file and extract the contents.

3. Open a terminal and navigate to the folder Numberjack-master you just extracted. For example, cd ./Downloads/Numberjack-master/.

4. Run the following commands:

source /opt/16.410-psets/bin/activate
export ZIBPATH='/usr/local/src/scipoptsuite-3.2.0'
sudo chown -R student:student /usr/local/src/scipoptsuite-3.2.0
python build

This may take a while.

5. Verify that when this is finished, you see the message Successfully built solver interfaces for Mistral, Mistral2, MipWrapper, SatWrapper, MiniSat, Walksat, SCIP (note SCIP is installed).

6. Verify that Python can see SCIP in this installation of Numberjack with the following commands in the terminal:

import Numberjack

7. Exit ipython (hit CTRL-D twice).

8. Run the following commands (still from the Numberjack-master folder):

sudo rm -rf /opt/16.410-psets/local/lib/python2.7/site-packages/Numberjack
sudo cp -r ./Numberjack /opt/16.410-psets/local/lib/python2.7/site-packages/Numberjack

9. Verify that SCIP is now present in the list of solvers when Numberjack is run from the jupyter notebook. You will need to restart the notebook kernel.

numberjack.txt · Last modified: 2016/11/04 18:44 by aytonb