The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

132 lines
3.5 KiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Dynamic Fault Trees"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Building DFTs\n",
"\n",
"[01-dfts.py](https://github.com/moves-rwth/stormpy/blob/master/examples/dfts/01-dfts.py)\n",
"\n",
"Dynamic fault trees can be loaded from either the Galileo format or from a custom JSON form.\n",
"A file containing the DFT in the Galileo format can be loaded via `load_dft_galileo_file(path)`.\n",
"The custom JSON format can be loaded from a file via `load_dft_json_file(path)` or directly from a string via `load_dft_json_string(path)`.\n",
"We start by loading a simple DFT containing an AND gate from JSON:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
">>> import stormpy\n",
">>> import stormpy.dft\n",
">>> import stormpy.examples\n",
">>> import stormpy.examples.files\n",
">>> path_json = stormpy.examples.files.dft_json_and\n",
">>> dft_small = stormpy.dft.load_dft_json_file(path_json)\n",
">>> print(dft_small)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next we load a more complex DFT from the Galileo format:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
">>> path_galileo = stormpy.examples.files.dft_galileo_hecs\n",
">>> dft = stormpy.dft.load_dft_galileo_file(path_galileo)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After loading the DFT, we can display some common statistics about the model:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
">>> print(\"DFT with {} elements.\".format(dft.nr_elements()))\n",
">>> print(\"DFT has {} BEs and {} dynamic elements.\".format(dft.nr_be(), dft.nr_dynamic()))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analyzing DFTs\n",
"\n",
"[01-dfts.py](https://github.com/moves-rwth/stormpy/blob/master/examples/dfts/01-dfts.py)\n",
"\n",
"The next step is to analyze the DFT via `analyze_dft(dft, formula)`.\n",
"Here we can use all standard properties as described in [Building properties](../getting_started.ipynb#building-properties).\n",
"In our example we compute the Mean-time-to-failure (MTTF):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
">>> formula_str = \"T=? [ F \\\"failed\\\" ]\"\n",
">>> formulas = stormpy.parse_properties(formula_str)\n",
">>> results = stormpy.dft.analyze_dft(dft, [formulas[0].raw_formula])\n",
">>> result = results[0]\n",
">>> print(\"MTTF: {:.2f}\".format(result))"
]
}
],
"metadata": {
"date": 1598178167.1422036,
"filename": "dfts.rst",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"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": "Dynamic Fault Trees"
},
"nbformat": 4,
"nbformat_minor": 4
}