From eeed265841f6c7fc7130eafad461af44a17d0951 Mon Sep 17 00:00:00 2001 From: Linus Heck Date: Thu, 7 Nov 2024 12:28:24 +0100 Subject: [PATCH] simulator notebook title --- docs/getting_started/simulator.ipynb | 131 +++++++++++++++++++++++++-- 1 file changed, 121 insertions(+), 10 deletions(-) diff --git a/docs/getting_started/simulator.ipynb b/docs/getting_started/simulator.ipynb index 0dbb8d1..00cd733 100644 --- a/docs/getting_started/simulator.ipynb +++ b/docs/getting_started/simulator.ipynb @@ -1,8 +1,16 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "8fe92ec7", + "metadata": {}, + "source": [ + "# The simulator" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "id": "a8ddc37c-66d2-43e4-8162-6be19a1d70a1", "metadata": {}, "outputs": [], @@ -13,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "id": "cab40f99-3460-4497-8b9f-3d669eee1e11", "metadata": {}, "outputs": [], @@ -86,10 +94,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "id": "eb0fadc0-7bb6-4c1d-ae3e-9e16527726ab", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ModelType.MDP with name None\n", + "\n", + "States:\n", + "State 0 with labels ['init'] and features {}\n", + "State 1 with labels ['carchosen'] and features {}\n", + "State 2 with labels ['open'] and features {}\n", + "State 3 with labels ['goatrevealed'] and features {}\n", + "State 4 with labels ['done'] and features {}\n", + "\n", + "Transitions:\n", + "0.3333333333333333 -> State 1 with labels ['carchosen'] and features {}\n", + "1.0 -> State 2 with labels ['open'] and features {}\n", + "1.0 -> State 3 with labels ['goatrevealed'] and features {}\n", + "1.0 -> State 4 with labels ['done'] and features {}\n" + ] + } + ], "source": [ "#we want to simulate this model. That is, we start at the initial state and then\n", "#we walk through the model according to transition probabilities.\n", @@ -109,12 +138,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "id": "59ac1e34-866c-42c4-b19b-c2a15c830e2e", "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ModelType.MDP with name None\n", + "\n", + "States:\n", + "State 0 with labels ['init'] and features {}\n", + "State 1 with labels ['carchosen'] and features {}\n", + "State 2 with labels ['open'] and features {}\n", + "State 3 with labels ['goatrevealed'] and features {}\n", + "State 4 with labels ['done'] and features {}\n", + "\n", + "Transitions:\n", + "0.3333333333333333 -> State 1 with labels ['carchosen'] and features {}\n", + "1.0 -> State 2 with labels ['open'] and features {}\n", + "1.0 -> State 3 with labels ['goatrevealed'] and features {}\n", + "1.0 -> State 4 with labels ['done'] and features {}\n" + ] + } + ], "source": [ "#it still chooses random actions but we can prevent this by providing a scheduler:\n", "taken_actions = {}\n", @@ -128,10 +178,63 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "id": "22871288-755c-463f-9150-f207c2f5c211", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0ad7293a022e4a848f6c2495654b8151", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9fdf09b8fabd407fa97bf7259246cc91", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8c7ab3e5bef84205968f7bd178c127de", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(Output(), Output()))" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#we can also visualize the partial model that we get from the simulator:\n", "show.show(partial_model)\n" @@ -139,10 +242,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "id": "34d0c293-d090-4e3d-9e80-4351f5fcba62", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "initial state --(action: empty)--> state: 2 --(action: open0)--> state: 7 --(action: empty)--> state: 17 --(action: stay)--> state: 33\n" + ] + } + ], "source": [ "#we can also use another simulator function that returns a path instead of a partial model:\n", "path = stormvogel.simulator.simulate_path(mdp, steps=4, scheduler=scheduler, seed=123456)\n",