Building a CSP


This notebook helps to construct a CSP visually. You can export the CSP and run various CSP algorithms on it afterwards. You can create new nodes and edges, remove existing ones, and change the names and domains of variable nodes. Right now we only support numerical domains.

You can run each cell by selecting it and pressing Ctrl+Enter in Windows or Shift+Return in MacOS. Alternatively, you can click the Play button in the toolbar, to the left of the stop button. For more information, check out our AISpace2 Tutorial.

Feel free to modify our codes either in this notebook or somewhere outside (e.g. python files in /aipython/). If you want to modify our codes outside, you might find this helpful for how your changes can take effect.

You need to run the following command to import our pre-defined problems.

In [ ]:
# Run this to import pre-defined problems
from aipython.cspProblem import csp_empty, csp_simple1, csp_simple2, csp_simple3, csp_extended1, csp_extended2, csp_extended3, csp_crossword1, csp_crossword2, csp_crossword3, csp_crossword2d, csp_five_queens, csp_eight_queens

In [ ]:
from aispace2.jupyter.csp import CSPBuilder

builder = CSPBuilder(csp_simple1)

# Visualization options
# For more explanation please visit: https://aispace2.github.io/AISpace2/tutorial.html#tutorial-common-visualization-options
builder.text_size = 13 # The fontsize of the text
builder.line_width = 2.0 # The thickness of edges

Obtaining the CSP

The following method enerates the Python code that, once run, constructs a CSP.

In [ ]:

In [ ]: