Skip to content

Commit a982dd1

Browse files
pomdp observations in visualization
1 parent 7e25dc8 commit a982dd1

File tree

10 files changed

+301
-61
lines changed

10 files changed

+301
-61
lines changed

docs/getting_started/model.html

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<iframe
3-
id="modellPtmSPREUD"
3+
id="modelMWfHVKBFQh"
44
width="820"
55
height="620"
66
frameborder="0"
@@ -27,16 +27,34 @@
2727
&lt;div id=&quot;mynetwork&quot;&gt;&lt;/div&gt;
2828
&lt;script type=&quot;text/javascript&quot;&gt;
2929
30-
var nodes = new vis.DataSet([{ id: 0, label: `init`, group: &quot;states&quot; },
31-
{ id: 1, label: `carchosen`, group: &quot;states&quot; },
32-
{ id: 2, label: `open`, group: &quot;states&quot; },
33-
{ id: 3, label: `goatrevealed`, group: &quot;states&quot; },
34-
{ id: 4, label: `done`, group: &quot;states&quot; },
30+
var nodes = new vis.DataSet([{ id: 0, label: `nijmegen`, group: &quot;states&quot; },
31+
{ id: 1, label: `eindhoven`, group: &quot;states&quot; },
32+
{ id: 2, label: `aachen`, group: &quot;states&quot; },
33+
{ id: 3, label: `saw nijmegen`, group: &quot;states&quot; },
34+
{ id: 4, label: `saw eindhoven`, group: &quot;states&quot; },
35+
{ id: 5, label: `saw aachen`, group: &quot;states&quot; },
36+
{ id: 10000000000, label: `walk`, group: &quot;actions&quot; },
37+
{ id: 10000000001, label: `stay put`, group: &quot;actions&quot; },
38+
{ id: 10000000002, label: `walk`, group: &quot;actions&quot; },
39+
{ id: 10000000003, label: `stay put`, group: &quot;actions&quot; },
40+
{ id: 10000000004, label: `walk`, group: &quot;actions&quot; },
41+
{ id: 10000000005, label: `stay put`, group: &quot;actions&quot; },
3542
]);
36-
var edges = new vis.DataSet([{ from: 0, to: 1, label: &quot;1/3&quot; },
37-
{ from: 1, to: 2, label: &quot;1&quot; },
38-
{ from: 2, to: 3, label: &quot;1&quot; },
39-
{ from: 3, to: 4, label: &quot;1&quot; },
43+
var edges = new vis.DataSet([{ from: 0, to: 10000000000 },
44+
{ from: 10000000000, to: 3, label: &quot;1&quot; },
45+
{ from: 0, to: 10000000001 },
46+
{ from: 10000000001, to: 0, label: &quot;1&quot; },
47+
{ from: 3, to: 0, label: &quot;1&quot; },
48+
{ from: 1, to: 10000000002 },
49+
{ from: 10000000002, to: 4, label: &quot;1&quot; },
50+
{ from: 1, to: 10000000003 },
51+
{ from: 10000000003, to: 1, label: &quot;1&quot; },
52+
{ from: 4, to: 1, label: &quot;1&quot; },
53+
{ from: 2, to: 10000000004 },
54+
{ from: 10000000004, to: 5, label: &quot;1&quot; },
55+
{ from: 2, to: 10000000005 },
56+
{ from: 10000000005, to: 2, label: &quot;1&quot; },
57+
{ from: 5, to: 2, label: &quot;1&quot; },
4058
]);
4159
var options = {
4260
&quot;__fake_macros&quot;: {

docs/getting_started/pomdp.ipynb

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "8013f1f2-f771-43b4-ba2a-c584d05d21b2",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import stormvogel.model\n",
11+
"from stormvogel.layout import Layout\n",
12+
"from stormvogel.show import show"
13+
]
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"id": "dbc502e0-a2f6-49c8-b9b1-638666906e27",
18+
"metadata": {},
19+
"source": [
20+
"The scenario is as follows. You are dropped in some city, but you are not sure which city. By walking and seeing landmarks, you learn where you are."
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": 2,
26+
"id": "887c917f-6df3-4379-b1e0-9471d76b0180",
27+
"metadata": {},
28+
"outputs": [
29+
{
30+
"data": {
31+
"application/vnd.jupyter.widget-view+json": {
32+
"model_id": "76eca30fd0d2467ca33df54cf6c1dbb9",
33+
"version_major": 2,
34+
"version_minor": 0
35+
},
36+
"text/plain": [
37+
"Output()"
38+
]
39+
},
40+
"metadata": {},
41+
"output_type": "display_data"
42+
},
43+
{
44+
"data": {
45+
"text/html": [
46+
"<script>fetch('http://127.0.0.1:8890/kWbJuvBmZs/MESSAGE/' + 'test message')</script>"
47+
],
48+
"text/plain": [
49+
"<IPython.core.display.HTML object>"
50+
]
51+
},
52+
"metadata": {},
53+
"output_type": "display_data"
54+
},
55+
{
56+
"data": {
57+
"text/html": [
58+
"<script>fetch('http://127.0.0.1:8890/kWbJuvBmZs/MESSAGE/' + 'test message')</script>"
59+
],
60+
"text/plain": [
61+
"<IPython.core.display.HTML object>"
62+
]
63+
},
64+
"metadata": {},
65+
"output_type": "display_data"
66+
},
67+
{
68+
"data": {
69+
"application/vnd.jupyter.widget-view+json": {
70+
"model_id": "5091be68b3b748299cb3b6e3eaf58ff4",
71+
"version_major": 2,
72+
"version_minor": 0
73+
},
74+
"text/plain": [
75+
"Output()"
76+
]
77+
},
78+
"metadata": {},
79+
"output_type": "display_data"
80+
},
81+
{
82+
"data": {
83+
"application/vnd.jupyter.widget-view+json": {
84+
"model_id": "4619d769b6fa4739aa6bb8400100ff2e",
85+
"version_major": 2,
86+
"version_minor": 0
87+
},
88+
"text/plain": [
89+
"HBox(children=(Output(), Output()))"
90+
]
91+
},
92+
"metadata": {},
93+
"output_type": "display_data"
94+
}
95+
],
96+
"source": [
97+
"pomdp = stormvogel.model.new_pomdp(create_initial_state=False)\n",
98+
"\n",
99+
"nijmegen = pomdp.new_state(\"nijmegen\")\n",
100+
"eindhoven = pomdp.new_state(\"eindhoven\")\n",
101+
"aachen = pomdp.new_state(\"aachen\")\n",
102+
"cities = [nijmegen, eindhoven, aachen]\n",
103+
"\n",
104+
"saw_nijmegen = pomdp.new_state(\"saw nijmegen\")\n",
105+
"saw_eindhoven = pomdp.new_state(\"saw eindhoven\")\n",
106+
"saw_aachen = pomdp.new_state(\"saw aachen\")\n",
107+
"saw_cities = [saw_nijmegen, saw_eindhoven, saw_aachen]\n",
108+
"\n",
109+
"walk = pomdp.new_action(\"walk\")\n",
110+
"stay_put = pomdp.new_action(\"stay put\")\n",
111+
"\n",
112+
"for city, saw_city in zip(cities, saw_cities):\n",
113+
" city.set_transitions([\n",
114+
" (walk, saw_city),\n",
115+
" (stay_put, city)\n",
116+
" ])\n",
117+
" saw_city.set_transitions([(1, city)])\n",
118+
"\n",
119+
"# We add an observation to the saw states.\n",
120+
"for saw_city in saw_cities:\n",
121+
" saw_city.set_observation(saw_city.id)\n",
122+
"\n",
123+
"vis = show(pomdp, show_editor=True)"
124+
]
125+
},
126+
{
127+
"cell_type": "code",
128+
"execution_count": null,
129+
"id": "b76ee6e4-156e-4a02-81b9-e150f5903df4",
130+
"metadata": {},
131+
"outputs": [],
132+
"source": []
133+
}
134+
],
135+
"metadata": {
136+
"kernelspec": {
137+
"display_name": "Python 3 (ipykernel)",
138+
"language": "python",
139+
"name": "python3"
140+
},
141+
"language_info": {
142+
"codemirror_mode": {
143+
"name": "ipython",
144+
"version": 3
145+
},
146+
"file_extension": ".py",
147+
"mimetype": "text/x-python",
148+
"name": "python",
149+
"nbconvert_exporter": "python",
150+
"pygments_lexer": "ipython3",
151+
"version": "3.12.3"
152+
}
153+
},
154+
"nbformat": 4,
155+
"nbformat_minor": 5
156+
}

docs/getting_started/study.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<iframe
3-
id="studyhIHuBBbPjQ"
3+
id="studyfhiOLrpNPp"
44
width="820"
55
height="620"
66
frameborder="0"
@@ -30,11 +30,11 @@
3030
var nodes = new vis.DataSet([{ id: 0, label: `init`, group: &quot;states&quot;, x: 5, y: -186 },
3131
{ id: 1, label: `studied`, group: &quot;states&quot;, x: 98, y: 11 },
3232
{ id: 2, label: `didn&#x27;t study
33-
R: 15`, group: &quot;states&quot;, x: -120, y: -7 },
33+
R: 15`, group: &quot;states&quot;, x: -120, y: -7 },
3434
{ id: 3, label: `pass test
35-
R: 100`, group: &quot;states&quot;, x: 0, y: 99 },
35+
R: 100`, group: &quot;states&quot;, x: 0, y: 99 },
3636
{ id: 4, label: `fail test
37-
R: 0`, group: &quot;states&quot;, x: -24, y: 37 },
37+
R: 0`, group: &quot;states&quot;, x: -24, y: 37 },
3838
{ id: 5, label: `end`, group: &quot;states&quot;, x: -62, y: 182 },
3939
{ id: 10000000000, label: `study`, group: &quot;actions&quot;, x: 119, y: -118 },
4040
{ id: 10000000001, label: `don&#x27;t study`, group: &quot;actions&quot;, x: -122, y: -141 },
@@ -139,10 +139,13 @@
139139
&quot;fractions&quot;: true,
140140
&quot;digits&quot;: 5
141141
},
142-
&quot;results_and_rewards&quot;: {
142+
&quot;state_properties&quot;: {
143143
&quot;show_results&quot;: true,
144-
&quot;resultSymbol&quot;: &quot;\u2606&quot;,
145-
&quot;show_rewards&quot;: true
144+
&quot;result_symbol&quot;: &quot;\u2606&quot;,
145+
&quot;show_rewards&quot;: true,
146+
&quot;rewards_symbol&quot;: &quot;\u20ac&quot;,
147+
&quot;show_observations&quot;: true,
148+
&quot;observations_symbol&quot;: &quot;\u0298&quot;
146149
},
147150
&quot;layout&quot;: {
148151
&quot;randomSeed&quot;: 5
@@ -195,7 +198,12 @@
195198
},
196199
&quot;width&quot;: 800,
197200
&quot;height&quot;: 600,
198-
&quot;physics&quot;: true
201+
&quot;physics&quot;: true,
202+
&quot;results_and_rewards&quot;: {
203+
&quot;show_results&quot;: true,
204+
&quot;resultSymbol&quot;: &quot;\u2606&quot;,
205+
&quot;show_rewards&quot;: true
206+
}
199207
};
200208
//js
201209
var container = document.getElementById(&quot;mynetwork&quot;);

docs/getting_started/study.ipynb

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"outputs": [],
1717
"source": [
1818
"import stormvogel.model\n",
19-
"import stormvogel.visualization\n",
2019
"from stormvogel.layout import Layout\n",
2120
"from stormvogel.show import show"
2221
]
@@ -154,7 +153,7 @@
154153
},
155154
{
156155
"cell_type": "code",
157-
"execution_count": 9,
156+
"execution_count": 10,
158157
"id": "0df1511e-565d-45d0-93a8-adafbfaaaefa",
159158
"metadata": {
160159
"scrolled": true
@@ -165,7 +164,7 @@
165164
"text/html": [
166165
"\n",
167166
" <iframe\n",
168-
" id=\"studyhIHuBBbPjQ\"\n",
167+
" id=\"studyfhiOLrpNPp\"\n",
169168
" width=\"820\"\n",
170169
" height=\"620\"\n",
171170
" frameborder=\"0\"\n",
@@ -195,11 +194,11 @@
195194
" var nodes = new vis.DataSet([{ id: 0, label: `init`, group: &quot;states&quot;, x: 5, y: -186 },\n",
196195
"{ id: 1, label: `studied`, group: &quot;states&quot;, x: 98, y: 11 },\n",
197196
"{ id: 2, label: `didn&#x27;t study\n",
198-
"R: 15`, group: &quot;states&quot;, x: -120, y: -7 },\n",
197+
"\u20ac\tR: 15`, group: &quot;states&quot;, x: -120, y: -7 },\n",
199198
"{ id: 3, label: `pass test\n",
200-
"R: 100`, group: &quot;states&quot;, x: 0, y: 99 },\n",
199+
"\u20ac\tR: 100`, group: &quot;states&quot;, x: 0, y: 99 },\n",
201200
"{ id: 4, label: `fail test\n",
202-
"R: 0`, group: &quot;states&quot;, x: -24, y: 37 },\n",
201+
"\u20ac\tR: 0`, group: &quot;states&quot;, x: -24, y: 37 },\n",
203202
"{ id: 5, label: `end`, group: &quot;states&quot;, x: -62, y: 182 },\n",
204203
"{ id: 10000000000, label: `study`, group: &quot;actions&quot;, x: 119, y: -118 },\n",
205204
"{ id: 10000000001, label: `don&#x27;t study`, group: &quot;actions&quot;, x: -122, y: -141 },\n",
@@ -304,10 +303,13 @@
304303
" &quot;fractions&quot;: true,\n",
305304
" &quot;digits&quot;: 5\n",
306305
" },\n",
307-
" &quot;results_and_rewards&quot;: {\n",
306+
" &quot;state_properties&quot;: {\n",
308307
" &quot;show_results&quot;: true,\n",
309-
" &quot;resultSymbol&quot;: &quot;\\u2606&quot;,\n",
310-
" &quot;show_rewards&quot;: true\n",
308+
" &quot;result_symbol&quot;: &quot;\\u2606&quot;,\n",
309+
" &quot;show_rewards&quot;: true,\n",
310+
" &quot;rewards_symbol&quot;: &quot;\\u20ac&quot;,\n",
311+
" &quot;show_observations&quot;: true,\n",
312+
" &quot;observations_symbol&quot;: &quot;\\u0298&quot;\n",
311313
" },\n",
312314
" &quot;layout&quot;: {\n",
313315
" &quot;randomSeed&quot;: 5\n",
@@ -360,7 +362,12 @@
360362
" },\n",
361363
" &quot;width&quot;: 800,\n",
362364
" &quot;height&quot;: 600,\n",
363-
" &quot;physics&quot;: true\n",
365+
" &quot;physics&quot;: true,\n",
366+
" &quot;results_and_rewards&quot;: {\n",
367+
" &quot;show_results&quot;: true,\n",
368+
" &quot;resultSymbol&quot;: &quot;\\u2606&quot;,\n",
369+
" &quot;show_rewards&quot;: true\n",
370+
" }\n",
364371
"};\n",
365372
" //js\n",
366373
"var container = document.getElementById(&quot;mynetwork&quot;);\n",
@@ -416,6 +423,14 @@
416423
"source": [
417424
"vis = show(mdp, layout=Layout(\"layouts/pinkgreen.json\"), name=\"study\", save_and_embed=True)"
418425
]
426+
},
427+
{
428+
"cell_type": "code",
429+
"execution_count": null,
430+
"id": "393f4c6e-8204-42fc-8e0d-b2b8f232294a",
431+
"metadata": {},
432+
"outputs": [],
433+
"source": []
419434
}
420435
],
421436
"metadata": {

stormvogel/layouts/default.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,13 @@
8787
"fractions": true,
8888
"digits": 5
8989
},
90-
"results_and_rewards": {
90+
"state_properties": {
9191
"show_results": true,
92-
"resultSymbol": "\u2606",
93-
"show_rewards": true
92+
"result_symbol": "\u2606",
93+
"show_rewards": true,
94+
"reward_symbol": "\u20ac",
95+
"show_observations": true,
96+
"observation_symbol": "\u0298"
9497
},
9598
"layout": {
9699
"randomSeed": 5

stormvogel/layouts/explore.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,13 @@
8787
"fractions": true,
8888
"digits": 5
8989
},
90-
"results_and_rewards": {
90+
"state_properties": {
9191
"show_results": true,
92-
"resultSymbol": "\u2606",
93-
"show_rewards": true
92+
"result_symbol": "\u2606",
93+
"show_rewards": true,
94+
"reward_symbol": "\u20ac",
95+
"show_observations": true,
96+
"observation_symbol": "\u0298"
9497
},
9598
"layout": {
9699
"randomSeed": 5

0 commit comments

Comments
 (0)