Simulator

If we have a transition system, it might be nice to run a simulation. In this case, we have an MDP that models a hungry lion. Depending on the state it is in, it needs to decide whether it wants to ‘rawr’ or ‘hunt’ in order to prevent reaching the state ‘dead’.

[1]:
from stormvogel import *

lion = examples.create_lion_mdp()
show(lion)
Network
[1]:
<stormvogel.visualization.JSVisualization at 0x7f175c9729c0>

Now, let’s run a simulation of the lion! If we do not provide a scheduling function, then the simulator just does a random walk, taking a random choice each time.

[2]:
path = simulate_path(lion, steps=5, seed=1234)

We could also provide a scheduling function to choose the actions ourselves. This is somewhat similar to the bird API.

[3]:
def scheduler(s: State) -> Action:
    return Action("rawr")


path2 = stormvogel.simulator.simulate_path(
    lion, steps=5, seed=1234, scheduler=scheduler
)

We can also use the scheduler to create a partial model. This model contains all the states that have been discovered by the the simulation.

[4]:
partial_model = stormvogel.simulator.simulate(
    lion, steps=5, scheduler=scheduler, seed=1234
)
show(partial_model)
Network
[4]:
<stormvogel.visualization.JSVisualization at 0x7f1743af3800>