{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"wrappers\")\n",
"from modelverse import *\n",
"\n",
"import uuid\n",
"\n",
"init()\n",
"username = str(uuid.uuid4())\n",
"password = str(uuid.uuid4())\n",
"login(username, password)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"model_add(\"~/formalisms/PetriNets\", \"formalisms/SimpleClassDiagrams\", \"\"\"\n",
" include \"primitives.alh\"\n",
" \n",
" SimpleAttribute Natural {\n",
" name = \"Natural\"\n",
" constraint = $\n",
" String function constraint(value : Element):\n",
" if (is_physical_int(value)):\n",
" if (integer_gt(value, 0)):\n",
" return \"OK\"!\n",
" else:\n",
" return \"Natural must be non-negative\"!\n",
" else:\n",
" return \"Natural is not an integer value\"!\n",
" $\n",
" }\n",
" SimpleAttribute String{\n",
" name = \"String\"\n",
" }\n",
" \n",
" Class Place {\n",
" name = \"MYPLACE\"\n",
" name : String\n",
" tokens : Natural\n",
" }\n",
" \n",
" Class Transition {\n",
" name = \"Transition\"\n",
" name : String\n",
" }\n",
" \n",
" Association P2T (Place, Transition) {\n",
" name = \"P2T\"\n",
" weight : Natural\n",
" }\n",
" \n",
" Association T2P (Transition, Place) {\n",
" name = \"T2P\"\n",
" weight : Natural\n",
" }\n",
" \"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from IPython.display import SVG, display\n",
"svg = SVG()\n",
"svg.data = show(\"~/formalisms/PetriNets\")\n",
"display(svg)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"attr_assign(\"~/formalisms/PetriNets\", \"Place\", \"name\", \"Place\")\n",
"attr_assign(\"~/formalisms/PetriNets\", \"Natural\", \"name\", \"Natural\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}