Browse Source

fixed engines notebook and binder badge

refactoring
hannah 4 years ago
committed by Matthias Volk
parent
commit
f5668000b9
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 2
      doc/source/conf.py
  2. 4
      doc/source/doc/building_models.ipynb
  3. 188
      doc/source/doc/engines.ipynb

2
doc/source/conf.py

@ -248,7 +248,7 @@ nbsphinx_prolog = """
.. raw:: html .. raw:: html
<div class="admonition note"> <div class="admonition note">
Interactive online version:
Interactive version:
<span style="white-space: nowrap;"><a href="https://mybinder.org/v2/gh/m-hannah/stormpy/master?filepath={{ docname }}"><img alt="Binder badge" src="https://mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a>.</span> <span style="white-space: nowrap;"><a href="https://mybinder.org/v2/gh/m-hannah/stormpy/master?filepath={{ docname }}"><img alt="Binder badge" src="https://mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a>.</span>
</div> </div>
""" """

4
doc/source/doc/building_models.ipynb

@ -4,9 +4,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Building Models\n",
"\n",
"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/m-hannah/stormpy/master?filepath=notebooks%2Fbuilding_models.ipynb)"
"# Building Models"
] ]
}, },
{ {

188
doc/source/doc/engines.ipynb

@ -22,24 +22,51 @@
"source": [ "source": [
"## Sparse engine\n", "## Sparse engine\n",
"\n", "\n",
"In all of the examples so far we used the default sparse engine:\n",
"\n",
"In all of the examples so far we used the default sparse engine:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> import stormpy.examples\n", ">>> import stormpy.examples\n",
">>> import stormpy.examples.files\n", ">>> import stormpy.examples.files\n",
" >>> prism_program = stormpy.parse_prism_program(stormpy.examples.files.prism_dtmc_die)\n",
">>> prism_program = stormpy.parse_prism_program(stormpy.examples.files.prism_dtmc_die)\n",
">>> properties = stormpy.parse_properties('P=? [F \"one\"]', prism_program)\n", ">>> properties = stormpy.parse_properties('P=? [F \"one\"]', prism_program)\n",
">>> sparse_model = stormpy.build_sparse_model(prism_program, properties)\n", ">>> sparse_model = stormpy.build_sparse_model(prism_program, properties)\n",
">>> print(type(sparse_model))\n",
"<class 'stormpy.storage.storage.SparseDtmc'>\n",
">>> print(type(sparse_model))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> print(\"Number of states: {}\".format(sparse_model.nr_states))\n", ">>> print(\"Number of states: {}\".format(sparse_model.nr_states))\n",
"Number of states: 13\n",
">>> print(\"Number of transitions: {}\".format(sparse_model.nr_transitions))\n",
"Number of transitions: 20The model checking was also done in the sparse engine:\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> print(\"Number of transitions: {}\".format(sparse_model.nr_transitions))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> sparse_result = stormpy.check_model_sparse(sparse_model, properties[0])\n", ">>> sparse_result = stormpy.check_model_sparse(sparse_model, properties[0])\n",
">>> initial_state = sparse_model.initial_states[0]\n", ">>> initial_state = sparse_model.initial_states[0]\n",
">>> print(sparse_result.at(initial_state))\n",
"0.16666666666666666"
">>> print(sparse_result.at(initial_state))"
] ]
}, },
{ {
@ -49,29 +76,89 @@
"## Symbolic engine\n", "## Symbolic engine\n",
"\n", "\n",
"Instead of using the sparse engine, one can also use a symbolic representation in terms of binary decision diagrams (BDDs).\n", "Instead of using the sparse engine, one can also use a symbolic representation in terms of binary decision diagrams (BDDs).\n",
"To use the symbolic (dd) engine, we use the symbolic versions for the building and model checking:\n",
"\n",
"To use the symbolic (dd) engine, we use the symbolic versions for the building and model checking:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> symbolic_model = stormpy.build_symbolic_model(prism_program, properties)\n", ">>> symbolic_model = stormpy.build_symbolic_model(prism_program, properties)\n",
">>> print(type(symbolic_model))\n",
"<class 'stormpy.storage.storage.SymbolicSylvanDtmc'>\n",
">>> print(\"Number of states: {}\".format(symbolic_model.nr_states))\n",
"Number of states: 13\n",
">>> print(\"Number of transitions: {}\".format(symbolic_model.nr_transitions))\n",
"Number of transitions: 20\n",
">>> print(type(symbolic_model))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> print(\"Number of states: {}\".format(symbolic_model.nr_states))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> print(\"Number of transitions: {}\".format(symbolic_model.nr_transitions))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> symbolic_result = stormpy.check_model_dd(symbolic_model, properties[0])\n", ">>> symbolic_result = stormpy.check_model_dd(symbolic_model, properties[0])\n",
">>> print(symbolic_result)\n",
"[0, 1] (range)We can also filter the computed results and only consider the initial states:\n",
"\n",
">>> print(symbolic_result)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also filter the computed results and only consider the initial states:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> filter = stormpy.create_filter_initial_states_symbolic(symbolic_model)\n", ">>> filter = stormpy.create_filter_initial_states_symbolic(symbolic_model)\n",
">>> symbolic_result.filter(filter)\n", ">>> symbolic_result.filter(filter)\n",
">>> print(symbolic_result.min)\n",
"0.16666650772094727It is also possible to first build the model symbolically and then transform it into a sparse model:\n",
"\n",
">>> print(type(symbolic_model))\n",
"<class 'stormpy.storage.storage.SymbolicSylvanDtmc'>\n",
">>> print(symbolic_result.min)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is also possible to first build the model symbolically and then transform it into a sparse model:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> print(type(symbolic_model))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> transformed_model = stormpy.transform_to_sparse_model(symbolic_model)\n", ">>> transformed_model = stormpy.transform_to_sparse_model(symbolic_model)\n",
">>> print(type(transformed_model))\n",
"<class 'stormpy.storage.storage.SparseDtmc'>"
">>> print(type(transformed_model))"
] ]
}, },
{ {
@ -82,15 +169,28 @@
"\n", "\n",
"A third possibility is to use the hybrid engine, a combination of sparse and dd engines.\n", "A third possibility is to use the hybrid engine, a combination of sparse and dd engines.\n",
"It first builds the model symbolically.\n", "It first builds the model symbolically.\n",
"The actual model checking is then performed with the engine which is deemed most suitable for the given task.\n",
"\n",
">>> print(type(symbolic_model))\n",
"<class 'stormpy.storage.storage.SymbolicSylvanDtmc'>\n",
"The actual model checking is then performed with the engine which is deemed most suitable for the given task.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> print(type(symbolic_model))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> hybrid_result = stormpy.check_model_hybrid(symbolic_model, properties[0])\n", ">>> hybrid_result = stormpy.check_model_hybrid(symbolic_model, properties[0])\n",
">>> filter = stormpy.create_filter_initial_states_symbolic(symbolic_model)\n", ">>> filter = stormpy.create_filter_initial_states_symbolic(symbolic_model)\n",
">>> hybrid_result.filter(filter)\n", ">>> hybrid_result.filter(filter)\n",
">>> print(hybrid_result)\n",
"0.166667"
">>> print(hybrid_result)"
] ]
} }
], ],
@ -98,12 +198,24 @@
"date": 1598178167.148, "date": 1598178167.148,
"filename": "engines.rst", "filename": "engines.rst",
"kernelspec": { "kernelspec": {
"display_name": "Python",
"language": "python3",
"display_name": "Python 3",
"language": "python",
"name": "python3" "name": "python3"
}, },
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
},
"title": "Engines" "title": "Engines"
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 4 "nbformat_minor": 4
}
}
Loading…
Cancel
Save