{"id":15009852,"url":"https://github.com/jack0chan/pyuppaal","last_synced_at":"2025-08-19T05:32:38.400Z","repository":{"id":57917777,"uuid":"497193120","full_name":"Jack0Chan/PyUPPAAL","owner":"Jack0Chan","description":"PyUPPAAL is a python package basically for reflecting UPPAAL's model editing, verification, and counter-example parsing operations into scripts. ","archived":false,"fork":false,"pushed_at":"2025-03-12T13:35:41.000Z","size":41201,"stargazers_count":40,"open_issues_count":7,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-03T04:48:35.112Z","etag":null,"topics":["python3","uppaal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jack0Chan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-28T02:37:05.000Z","updated_at":"2025-06-18T11:13:29.000Z","dependencies_parsed_at":"2023-02-19T05:00:37.203Z","dependency_job_id":"59b8ded5-ee37-4d43-9e59-6f7cf30e9c25","html_url":"https://github.com/Jack0Chan/PyUPPAAL","commit_stats":{"total_commits":146,"total_committers":5,"mean_commits":29.2,"dds":0.410958904109589,"last_synced_commit":"a78a24516b00f02afb7cc7b5ce2edd3287bf22d6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Jack0Chan/PyUPPAAL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jack0Chan%2FPyUPPAAL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jack0Chan%2FPyUPPAAL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jack0Chan%2FPyUPPAAL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jack0Chan%2FPyUPPAAL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jack0Chan","download_url":"https://codeload.github.com/Jack0Chan/PyUPPAAL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jack0Chan%2FPyUPPAAL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271104516,"owners_count":24699920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python3","uppaal"],"created_at":"2024-09-24T19:28:53.357Z","updated_at":"2025-08-19T05:32:33.383Z","avatar_url":"https://github.com/Jack0Chan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\n[![Documentation Status](https://readthedocs.org/projects/pyuppaal/badge/?version=latest)](https://pyuppaal.readthedocs.io/en/latest/?badge=latest) \n[![PyPI version](https://badge.fury.io/py/pyuppaal.svg)](https://badge.fury.io/py/pyuppaal)\n![](https://img.shields.io/badge/test-passing-brightgreen)\n[![Licence](https://img.shields.io/github/license/jack0chan/pyuppaal)](https://opensource.org/licenses/mit-license.php)\n![](https://img.shields.io/badge/platform-Windows,%20Linux,%20Darwin-blue) \n\n`PyUPPAAL` is a python package developed basically for reflecting UPPAAL's model editing, verification, and counter-example parsing operations into scripts. Implementing iterative model checking workflow is a typical application of pyuppaal, such as CEGAR, CEGIS, fault diagnosis, risk analysis, ect. We will add references and case studies for these problems. Some function have been implemented such as `find_all_patterns()`, `fault_diagnosability()`, `fault_identification()`, and `fault_tolerance()`.\n\nNotice: \n\n- report issues / requirements at: [github-issues](https://github.com/Jack0Chan/PyUPPAAL/issues).\n- more demos for basic \u0026 advanced usage will come soon.\n- [todo] Support for *SMC* analyzing.\n\nDemos are provided to help users get familiar with `PyUPPAAL`:\n\n\n\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo4-Scripted%20Model%20Construction.ipynb\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme3.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo5-Trace%20Parser.ipynb\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme4.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo1-PipeNet.ipynb\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme5.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo2-Pedestrian.ipynb\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme6.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo3-Fault%20Diagnosis.ipynb\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme7.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme1.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/readme2.png\" width=\"270px\" alt=\"\"\u003e\n\u003c/a\u003e\n\n# Quickstart\n\n## 1. Installation\n\n`pip install pyuppaal`\n\n## 2. Before Coding\n\n1. Be sure to set the `verifyta_path` in your first line of code, which serves as model checking engine: [Download UPPAAL4.x/5.x](https://uppaal.org/downloads/).\n2. You should activate UPPAAL, e.g., verify a model with UPPAAL GUI before use pyuppaal, to make sure that you have UPPAAL backend actiavted.\n\n`pyuppaal.set_verifyta_path(\"your/path/to//verifyta.exe\")`\n\n\n## 3. Load, Edit, and Verify a Model\n\n1. Firstly we load the model [demo.xml](https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/demo.xml) shown below. \n2. Then you can verify, and return the verify results as terminal outputs, or parsed SimTrace.\n3. In this demo, we just edit the `queries` of the `.xml` model, and we also provide a demo showing how to edit the template, locations, edges, etc.: [Demo-Scripted Model Construction](https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo4-Scripted%20Model%20Construction.ipynb).\n\n\u003cimg src=https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/demo.png width=250 /\u003e\n\n\n```python\nimport pyuppaal\nfrom pyuppaal import UModel\n\nprint(f\"pyuppaal version: {pyuppaal.__version__}\\n\")\npyuppaal.set_verifyta_path(r\"C:\\Users\\10262\\Documents\\GitHub\\cav2024\\bin\\uppaal64-4.1.26\\bin-Windows\\verifyta.exe\")\n\numodel = UModel('demo.xml') # load the model\numodel.queries = ['E\u003c\u003e P1.pass']\n\n# verify and return the terminal result.\nprint(f\"======== terminal res ========\\n{umodel.verify()}\")\n\n# verify and return the parsed trace as simulation trace: SimTrace.\nsimulation_trace = umodel.easy_verify() \nprint(\"======== parsed res ========\") \nprint(f\"untime pattern: {simulation_trace.untime_pattern}\")\nprint(f\"full trace: {simulation_trace}\")\n```\n\n    pyuppaal version: 1.2.1\n    \n    ======== terminal res ========\n    Writing example trace to demo-1.xtr\n    Options for the verification:\n      Generating shortest trace\n      Search order is breadth first\n      Using conservative space optimisation\n      Seed is 1713425560\n      State space representation uses minimal constraint systems\n    \u001b[2K\n    Verifying formula 1 at /nta/queries/query[1]/formula\n    \u001b[2K -- Formula is satisfied.\n    \n    ======== parsed res ========\n    untime pattern: ['a', 'b']\n    full trace: State [0]: ['P1.start']\n    global_variables [0]: None\n    Clock_constraints [0]: [t(0) - P1.t ≤ 0; P1.t - t(0) ≤ 10; ]\n    transitions [0]: a: P1 -\u003e ; P1.start -\u003e P1._id2;\n    -----------------------------------\n    State [1]: ['P1._id2']\n    global_variables [1]: None\n    Clock_constraints [1]: [t(0) - P1.t ≤ -10; ]\n    transitions [1]: b: P1 -\u003e ; P1._id2 -\u003e P1.pass;\n    -----------------------------------\n    State [2]: ['P1.pass']\n    global_variables [2]: None\n    Clock_constraints [2]: [t(0) - P1.t ≤ -10; ]\n    \n    \n\n## 4. Find all patterns\n\nNow we want find all possible patterns that leads to `P1.pass`. The red line is pattern1, and the green line is pattern2.\n\n\u003cimg src=https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/demo_patterns.png width=250 /\u003e\n\n\n```python\nfor i, st in enumerate(umodel.find_all_patterns()):\n    print(f'pattern{i+1}: ', st.untime_pattern)\n```\n\n    pattern1:  ['a', 'b']\n    pattern2:  ['c', 'd']\n    \n\n## 4. Verify with Multi-threads\n\n\n```python\nimport pyuppaal as pyu\nimport time\nimport multiprocessing.dummy as mp\n\nprint(pyu.__version__)\n# set verifyta path\npyu.set_verifyta_path(r\"C:\\Users\\10262\\Documents\\GitHub\\cav2024\\bin\\uppaal64-4.1.26\\bin-Windows\\verifyta.exe\")\n\nmodel_path_list = ['demo.xml', 'demo_new.xml'] * 100\ntrace_path_list = ['demo_trace.xtr', 'demo_new_grace.xtr'] * 100\n# for loop\nt0 = time.time()\nfor model, trace in zip(model_path_list, trace_path_list):\n    pyu.Verifyta().verify(model_path=model, trace_path=trace)\nprint(f'Verify with for loop, time usage {time.time() - t0}')\n\n# multi-threads\nt0 = time.time()\n# pyu.Verifytaeasy_verify(model_path=model_path_list, trace_path=trace_path_list, num_threads=20)\np = mp.Pool()\np.starmap(pyu.Verifyta().verify, zip(model_path_list, trace_path_list))\nprint(f'Verify with multi-threads, time usage {time.time() - t0}')\n\n```\n\n    1.2.1\n    Verify with for loop, time usage 9.384526014328003\n    Verify with multi-threads, time usage 1.61281418800354\n    \n\n## 5. Get Communication Graph\n\nFor models with multiple processes, you can use `umod.get_communication_graph()` method to visualize the sturcture of your UPPAAL model.\n\nAn example communication graph of a complex model in [Demo_PipeNet](https://pyuppaal.readthedocs.io/en/latest/Demo1-PipeNet.html#visualize-the-architecture) is shown below:\n\n[![](https://mermaid.ink/img/pako:eNpVjs0KwjAQhF-l7Lk56DEHT714UUGPC7JttjaQpCHdiFL67kYo_pxmmG8GZoZuNAwaboniUF0aDCcb-cCCYR9iLnJsJ053TmuglH3LtSXnlNp92qtRih9WtoV8d39o84OgBs_JkzXlwYyhqhBkYM8IuljDPWUnCBiWUqUs4_kZOtCSMteQoyHhxlL57kH35CZeXq-ESg8?type=jpg)](https://mermaid.live/edit#pako:eNpVjs0KwjAQhF-l7Lk56DEHT714UUGPC7JttjaQpCHdiFL67kYo_pxmmG8GZoZuNAwaboniUF0aDCcb-cCCYR9iLnJsJ053TmuglH3LtSXnlNp92qtRih9WtoV8d39o84OgBs_JkzXlwYyhqhBkYM8IuljDPWUnCBiWUqUs4_kZOtCSMteQoyHhxlL57kH35CZeXq-ESg8)\n\n## 6. Backup of old docs\n\nDemos are provided to help users get familiar with `PyUPPAAL` (can not be rendered by github):\n\u003cdiv style=\"display: flex; flex-wrap: wrap; align-items: flex-start;\"\u003e\n    \u003cdiv style=\"margin: 10px; width: 300px;\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/pipeNetPatterns.png\" style=\"width: 300px; height: 200px; object-fit: cover;\"\u003e\n        \u003ch5 style=\"margin: 0 0 4px 0; font-size: 14px;\"\u003e\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo1-PipeNet.ipynb\"\u003eDemo-PipeNet\u003c/a\u003e\u003c/h5\u003e\n        \u003cp style=\"margin: 0; font-size: 14px;\"\u003eThis demo demonstrates how to\u003c/p\u003e\n        \u003col style=\"margin: 0; padding-left: 20px; font-size: 14px;\"\u003e\n            \u003cli\u003eLoad and verify a model.\u003c/li\u003e\n            \u003cli\u003eModel the input \u0026 observation sequence.\u003c/li\u003e\n            \u003cli\u003eBuild communication graph.\u003c/li\u003e\n            \u003cli\u003eFind all patterns.\u003c/li\u003e\n        \u003c/ol\u003e\n    \u003c/div\u003e\n    \u003cdiv style=\"margin: 10px; width: 300px;\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/scripted_model_building_receiver.png\" style=\"width: 300px; height: 200px; object-fit: cover;\" alt=\"描述2\"\u003e\n        \u003ch5 style=\"margin: 0 0 4px 0; font-size: 14px;\"\u003e\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo4-Scripted%20Model%20Construction.ipynb\"\u003eDemo-Scripted Model Construction\u003c/a\u003e\u003c/h5\u003e\n        \u003cp style=\"margin: 0; font-size: 14px;\"\u003eThis demo constructs a model solely with PyUPPAAL APIs, including:\u003c/p\u003e\n        \u003col style=\"margin: 0; padding-left: 20px; font-size: 14px;\"\u003e\n            \u003cli\u003eConstruct \u003ccode\u003eTemplate\u003c/code\u003e with \u003ccode\u003eEdge\u003c/code\u003e, \u003ccode\u003eLocation\u003c/code\u003e.\u003c/li\u003e\n            \u003cli\u003eSet \u003ccode\u003eDeclarations\u003c/code\u003e, \u003ccode\u003eSystems\u003c/code\u003e, \u003ccode\u003eQueries\u003c/code\u003e.\u003c/li\u003e\n            \u003cli\u003eVerify the constructed model.\u003c/li\u003e\n        \u003c/ol\u003e\n    \u003c/div\u003e\n    \u003cdiv style=\"margin: 10px; width: 300px;\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/pedestrian_overall.png\" style=\"width: 300px; height: 200px; object-fit: cover;\" alt=\"描述3\"\u003e\n        \u003ch5 style=\"margin: 0 0 4px 0; font-size: 14px;\"\u003e\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo2-Pedestrian.ipynb\"\u003eDemo-Pedestrain\u003c/a\u003e\u003c/h5\u003e\n        \u003cp style=\"margin: 0; font-size: 14px;\"\u003eThis demo shows how to identify all event sequences that could result in a fault state, and see you can get ALL possible patterns only with PyUPPAAL \u003ccode\u003efind_all_patterns()\u003c/code\u003e.\u003c/p\u003e\n    \u003c/div\u003e\n    \u003cdiv style=\"margin: 10px; width: 300px;\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/npn_monitors.png\" style=\"width: 300px; height: 200px; object-fit: cover;\" alt=\"描述3\"\u003e\n        \u003ch5 style=\"margin: 0 0 4px 0; font-size: 14px;\"\u003e\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo5-Trace%20Parser.ipynb\"\u003eDemo-Trace Parser\u003c/a\u003e\u003c/h5\u003e\n        \u003cp style=\"margin: 0; font-size: 14px; font-size: 14px;\"\u003eIn this demo, you will learn how to model the \u003ccode\u003einput\u003c/code\u003e and \u003ccode\u003eobservations\u003c/code\u003e events of a descrete event system (DES), and how to extract information from parsed counter example.\u003c/p\u003e\n    \u003c/div\u003e\n    \u003cdiv style=\"margin: 10px; width: 300px;\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/Jack0Chan/pyuppaal/main/src/test_demos/figs/diagnosis_identification.png\" style=\"width: 300px; height: 200px; object-fit: cover;\" alt=\"描述3\"\u003e\n        \u003ch5 style=\"margin: 0 0 4px 0; font-size: 14px;\"\u003e\u003ca href=\"https://github.com/Jack0Chan/PyUPPAAL/blob/main/src/test_demos/Demo3-Fault%20Diagnosis.ipynb\"\u003eDemo-Fault Identification and Diagnosability\u003c/a\u003e\u003c/h5\u003e\n        \u003cp style=\"margin: 0; font-size: 14px;\"\u003eIn this demo, you will analyze the identification and diagnosability of certain fault, wich advanced methods of \u003ccode\u003epyuppaal\u003c/code\u003e.\u003c/p\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjack0chan%2Fpyuppaal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjack0chan%2Fpyuppaal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjack0chan%2Fpyuppaal/lists"}