BDD_test
Module summary
Tests some key procedures for BDD
.
(In the implementation details below, click on class/function names for additional documentation and links to the source code.)
❖❖❖
Implements functions (outside the classes above):
|
creates a simple 4-var BDD |
|
Quickly tests the load-save functionality (for visual inspection). |
Tests the BDD creation and rendering code. |
|
Tests intersection function. |
|
|
|
|
quick test of swap and sift operations |
|
Tests align_to operation (random instances). |
Tests intersection function, |
|
Tests that load/save functionality works as intended. |
|
|
Tests if |
Tests load/save for a specific situation. |
|
|
Tests the shortest path procedure (with Gurobi model) |
Tests |
|
Tests swap operation for weighted diagrams (random instances). |
❖❖❖
Implementation details
❖❖❖
Functions
- BDD_test.save_load(bdd)[source]
Quickly tests the load-save functionality (for visual inspection).
must result in two equivalent graphs (BDDs) on the screen
- BDD_test.test_intersect(i)[source]
Tests intersection function,
BDD.intersect()
.
- BDD_test.test_random_swapping(test_inst)[source]
Tests if
BDD.BDD.swap()
work correctly (random problems).Generates a random BDD, makes some random swaps (or sifts), and then checks that the function encoded by the BDD remained the same (that is, every set of var values result in the same terminal node for the original BDD and for the randomly changed BDD).
- Parameters
N – no. of variables in the diagram
m – no. of consecutive test swaps per BDD
p – BDD expansion prob parameter
mode –
swaps
orsifts
, determines what kind of events are to be generated
Notes
- Arguments are packed into a single tuple (for compatibility)
with
pytest
module.
- Involves brute-force enumaration of all the 2^n possible decisions
(concerning all vars), so choose
n
wisely (<=8 seems OK)
Example
test_random_swapping((8,20,0.8,sys.argv[1]))
- BDD_test.test_shortest_path(test_inst)[source]
Tests the shortest path procedure (with Gurobi model)