Reference

The details of AISpace2.

Table of Contents

Common

User Guide

Main visualizations controls

You can resize the height of the visualization by dragging the resize handle () in the bottom right corner. The width of the visualization can be changed by resizing the window. In either case, the nodes will reposition themselves until they all fit on screen.

Visualization Options

Notes

CSP

User Guide

— the arc needs to be checked to see if it is arc consistent.

— the arc is arc consistent.

— the arc is not arc consistent.

You can click on any blue or red arc to perform arc consistency on that arc. Otherwise, a random arc is chosen when you step. After arc consistency is finished, and you are running a function that performs domain splitting (e.g. solve_one()), you can click a node to split its domain.

Supported Classes

Con_solver, SLSearcher

Included Problems

CSP 0
simple_csp1: A simple CSP.
CSP 1
simple_csp2: Another simple CSP.
CSP 2
extended_csp: A more complex CSP.
CSP Crossword 1
crossword1: A crossword that represents word positions as variables.
CSP Crossword 2
crossword2: Another crossword that represents word positions as variables.
CSP Crossword 2d
crossword2d: A crossword that represents squares as variables.

Relationship between AISpace2 and AIPython

AIPython is the Python code for the pseudocode found inside the accompanying textbook; AISpace2 takes the code from AIPython and enhances it to work inside Jupyter, allowing for rich visualizations to accompany code.

In order to make this possible, two things were changed from the code in AIPython to the code you see inside AISpace2. Everything else is identical.

  1. The additional of the @visualize decorator: All functions that you call directly on the instance to be visualized within a cell must have their definitions annotated with @visualize. For example, if we had the following class:

    class Example():
      def bar(self):
        print('bar')
      
      def foo(self):
        self.bar()
        print('foo')
    

    and there was a cell inside Jupyter like this:

    e = Example()
    e.foo()
    

    Then foo would have to be annotated, because it is called directly on the instance inside a cell; but bar wouldn't need to be annotated, because it is only called indirectly by foo. Annotating foo is as simple as adding a single line right above the declaration:

    @visualize
    def foo(self):
      self.bar()
      print('foo')
    

    On the other hand, if you also wanted to call e.bar() directly (either in the same cell or another), you would have to also add @visualize to bar as well.

    The reason why this is necessary is to support interacting with visualizations. AISpace2 needs to know which functions will drive the visualization, so that it can set things up correctly.

  2. Change in imports: Displayable subclasses inherit from aipython.utilities.Displayable in AIPython, but inherit from aispace2.jupyter.* inside AISpace2 (where * depends on the algorithm being visualized). The @visualize decorator can also be imported from the same package.

    The reason why this change is necessary is that these specialized Displayable classes have hooks that allow it to be displayed inside Jupyter.