Skip to content

Commit ba1cd39

Browse files
authored
Binder notebook (#1)
Created Binder support for starter project. Added Jupyter notebook, created Dockerfile and updated README.
1 parent 5ef650f commit ba1cd39

File tree

3 files changed

+130
-1
lines changed

3 files changed

+130
-1
lines changed

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM movesrwth/stormpy:1.6.0
2+
MAINTAINER Matthias Volk <[email protected]>
3+
4+
5+
##########
6+
# Create user
7+
##########
8+
9+
ARG NB_USER=jovyan
10+
ARG NB_UID=1000
11+
ENV USER ${NB_USER}
12+
ENV NB_UID ${NB_UID}
13+
ENV HOME /home/${NB_USER}
14+
15+
RUN adduser --disabled-password \
16+
--gecos "Default user" \
17+
--uid ${NB_UID} \
18+
${NB_USER}
19+
20+
# Change the owner of the virtual environment
21+
WORKDIR /opt
22+
USER root
23+
RUN chown -R ${NB_UID} venv
24+
USER ${NB_USER}
25+
26+
WORKDIR ${HOME}
27+
# Add missing path
28+
ENV PATH="$HOME/.local/bin:$PATH"
29+
30+
31+
##########
32+
# Install dependencies
33+
##########
34+
35+
RUN pip install --no-cache-dir notebook==5.7.9
36+
37+
##########
38+
# Copy files for notebooks
39+
##########
40+
41+
# tests
42+
RUN mkdir notebooks
43+
COPY /examples notebooks/examples
44+
COPY *.ipynb notebooks/
45+

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# storm-project-starter-python
22
Starter project for the Python API of Storm via Stormpy
33

4+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/m-hannah/storm-project-starter-python/master?filepath=notebooks%2Fstormpy_starter.ipynb)
5+
46
## Getting Started
57
Before starting, make sure that Storm and stormpy are installed. If not, see the [documentation](https://moves-rwth.github.io/stormpy/installation.html) for details on how to install stormpy.
68

@@ -24,4 +26,4 @@ The answer should be yes.
2426

2527
## What is next?
2628
You are all set to implement your own tools and algorithms on top of stormpy.
27-
Feel free to contribute your new algorithms to stormpy, such that others can enjoy them.
29+
Feel free to contribute your new algorithms to stormpy, such that others can enjoy them.

stormpy_starter.ipynb

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import stormpy as sp"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"def check(path_to_model, property_str):\n",
19+
" program = sp.parse_prism_program(path_to_model)\n",
20+
" props = sp.parse_properties(property_str, program)\n",
21+
" model = sp.build_model(program, props)\n",
22+
" result = sp.model_checking(model, props[0])\n",
23+
" return result.at(model.initial_states[0]) > 0.5"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"#### Call function (first property)"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"res = check(\"examples/die.pm\", \"examples/die.pctl\")\n",
40+
"print(\"Result > 0.5? \" + (\"yes\" if res else \"no\"))"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"#### Call function (second property)"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"res = check(\"examples/die.pm\", \"examples/die2.pctl\")\n",
57+
"print(\"Result > 0.5? \" + (\"yes\" if res else \"no\"))"
58+
]
59+
}
60+
],
61+
"metadata": {
62+
"kernelspec": {
63+
"display_name": "Python 3",
64+
"language": "python",
65+
"name": "python3"
66+
},
67+
"language_info": {
68+
"codemirror_mode": {
69+
"name": "ipython",
70+
"version": 3
71+
},
72+
"file_extension": ".py",
73+
"mimetype": "text/x-python",
74+
"name": "python",
75+
"nbconvert_exporter": "python",
76+
"pygments_lexer": "ipython3",
77+
"version": "3.8.2"
78+
}
79+
},
80+
"nbformat": 4,
81+
"nbformat_minor": 4
82+
}

0 commit comments

Comments
 (0)