display_level2 or lower.
display()statement has executed. Useful to stop auto solving.
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.
sleep_time: The time, in seconds, between each step when stepping or auto solving. Defaults to
line_width: The thickness of edges, in pixels. Defaults to
display()call is the
display_level, which, depending on the step button, controls when execution pauses. You can safely change the
display_levelto adjust the amount of detail you receive.
display()call, so modifying them may break the visualization.
— a start node.
— a regular node.
— a goal node.
— the nodes at the end of each path on the frontier are highlighted in green.
— the neighbouring nodes of the current path are highlighted in blue.
— the path being expanded is highlighted in red. The last node on this path is highlighted in red; the rest are highlighted in gray.
True, shows the cost of each edge along the line. Defaults to
True, show the node's heuristic value (h-value) inside the node. Defaults to
layout_method: Controls how the nodes in the graph are positioned. Either
"force", which is a general graph layout algorithm that works on graphs of all types, or
"tree", if you know the resulting graph is always tree-shaped. Defaults to
search()can only be run again
— 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.
you can click a node to split its domain.
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.
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()
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 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
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.
Change in imports:
Displayable subclasses inherit from
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.