diff --git a/setup.py b/setup.py index a827ce14a8c425ea2095437f67ef0339dd7d9f3b..b40e6e4e0447c6dbc5a86944d6f06df19e820a88 100644 --- a/setup.py +++ b/setup.py @@ -8,33 +8,34 @@ setup( author='Yangge Li, Katherine Braught, Haoqing Zhu', maintainer='Yangge Li, Katherine Braught, Haoqing Zhu', maintainer_email='{li213, braught2, haoqing3}@illinois.edu', - license='Apache-2.0', packages=find_packages(exclude=["tests", "demo"]), python_requires='>=3.8', install_requires=[ - "numpy~=1.22.1", - "scipy~=1.8.1", - "matplotlib~=3.4.2", - "polytope~=0.2.3", - "pyvista~=0.32.1", - "networkx~=2.2", - "sympy~=1.6.2", - "six~=1.14.0", - "astunparse~=1.6.3", - "treelib~=1.6.1", - "z3-solver~=4.8.17.0", - "igraph~=0.9.10", - "plotly~=5.8.0", - "beautifulsoup4~=4.11.1", - "lxml~=4.9.1", + "numpy", + "scipy", + "matplotlib", + "polytope", + "pyvista", + "networkx", + "sympy", + "six", + "astunparse", + "treelib", + "z3-solver", + "igraph", + "plotly", + "beautifulsoup4", + "lxml", "torch", - "tqdm" + "tqdm", + "intervaltree", + "Pympler" + "nbformat", ], classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering', - 'License :: OSI Approved :: Apache License 2.0', 'Programming Language :: Python :: 3.8', ] ) diff --git a/tutorial/Verse_Tutorial.ipynb b/tutorial/Verse_Tutorial.ipynb index 146ca1abbe2f2779259335fa6ead2835abe195dc..bd804b60da6c091a3c061aeee7ff7ac0da993647 100644 --- a/tutorial/Verse_Tutorial.ipynb +++ b/tutorial/Verse_Tutorial.ipynb @@ -145,9 +145,8 @@ "metadata": {}, "outputs": [], "source": [ - "dl = In[2]+\"\\n\"+In[3]+\"\\n\" + In[4]\n", "from tutorial_agent import Agent1\n", - "car = Agent1('car', code=dl)" + "car = Agent1('car', file_name=\"dl_sec1.py\")" ] }, { @@ -367,16 +366,6 @@ " return output" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "cb17f4b1", - "metadata": {}, - "outputs": [], - "source": [ - "dl = In[12]+\"\\n\"+In[13]" - ] - }, { "cell_type": "markdown", "id": "7c927d21", @@ -393,9 +382,9 @@ "outputs": [], "source": [ "from tutorial_agent import Agent1\n", - "car1 = Agent1('car1', code=dl)\n", + "car1 = Agent1('car1', file_name=\"dl_sec2.py\")\n", "car1.set_initial([[0,-0.5,0,2],[1,0.5,0,2]], (AgentMode.Normal, TrackMode.T0))\n", - "car2 = Agent1('car2', code=dl)\n", + "car2 = Agent1('car2', file_name=\"dl_sec2.py\")\n", "car2.set_initial([[15,-0.5,0,1],[16,0.5,0,1]], (AgentMode.Normal, TrackMode.T0))" ] }, @@ -563,16 +552,6 @@ " return output" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "ab2fa45a", - "metadata": {}, - "outputs": [], - "source": [ - "dl = In[21]+\"\\n\"+In[22]" - ] - }, { "cell_type": "markdown", "id": "361154ca", @@ -589,9 +568,9 @@ "outputs": [], "source": [ "from tutorial_agent import Agent1\n", - "car1 = Agent1('car1', code=dl)\n", + "car1 = Agent1('car1', file_name=\"dl_sec3.py\")\n", "car1.set_initial([[0,-0.5,0,2],[1,0.5,0,2]], (AgentMode.Normal, TrackMode.T0))\n", - "car2 = Agent1('car2', code=dl)\n", + "car2 = Agent1('car2', file_name=\"dl_sec3.py\")\n", "car2.set_initial([[15,-0.5,0,1],[16,0.5,0,1]], (AgentMode.Normal, TrackMode.T0))\n", "scenario.add_agent(car1)\n", "scenario.add_agent(car2)\n", @@ -756,9 +735,11 @@ } ], "metadata": { + "interpreter": { + "hash": "04a7a195f934deca871ac715d77171c6df8c591438a5013fd2b54f1822da2e09" + }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", + "display_name": "Python 3.8.10 64-bit ('venv': venv)", "name": "python3" }, "language_info": { diff --git a/tutorial/dl_sec1.py b/tutorial/dl_sec1.py new file mode 100644 index 0000000000000000000000000000000000000000..15aab7d1878f8b99803230dec5d538637b4c153e --- /dev/null +++ b/tutorial/dl_sec1.py @@ -0,0 +1,27 @@ +from enum import Enum, auto + +class AgentMode(Enum): + Normal = auto() + Brake = auto() + +class TrackMode(Enum): + T0 = auto() + +class State: + x:float + y:float + theta:float + v:float + agent_mode:AgentMode + track_mode:TrackMode + + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): + pass + +import copy +def decisionLogic(ego:State, track_map): + output = copy.deepcopy(ego) + if ego.agent_mode == AgentMode.Normal: + if ego.x > 10: + output.agent_mode = AgentMode.Brake + return output \ No newline at end of file diff --git a/tutorial/dl_sec2.py b/tutorial/dl_sec2.py new file mode 100644 index 0000000000000000000000000000000000000000..954b280ebcd95e9230181240c846abfebac4317b --- /dev/null +++ b/tutorial/dl_sec2.py @@ -0,0 +1,28 @@ +from enum import Enum, auto + +class AgentMode(Enum): + Normal = auto() + Brake = auto() + +class TrackMode(Enum): + T0 = auto() + +class State: + x:float + y:float + theta:float + v:float + agent_mode:AgentMode + track_mode:TrackMode + + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): + pass + +from typing import List +import copy +def decisionLogic(ego:State, others: List[State], track_map): + output = copy.deepcopy(ego) + if ego.agent_mode == AgentMode.Normal: + if any( other.x-ego.x< 8 and other.x-ego.x>0 for other in others): + output.agent_mode = AgentMode.Brake + return output \ No newline at end of file diff --git a/tutorial/dl_sec3.py b/tutorial/dl_sec3.py new file mode 100644 index 0000000000000000000000000000000000000000..3e5f72481d0ac9cdd21e48f5ce37566ad08f0218 --- /dev/null +++ b/tutorial/dl_sec3.py @@ -0,0 +1,33 @@ +from enum import Enum, auto + +class AgentMode(Enum): + Normal = auto() + Brake = auto() + +class TrackMode(Enum): + T0 = auto() + +class State: + x:float + y:float + theta:float + v:float + agent_mode:AgentMode + track_mode:TrackMode + + def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): + pass + +from typing import List +import copy +def decisionLogic(ego:State, others: List[State], track_map): + output = copy.deepcopy(ego) + if ego.agent_mode == AgentMode.Normal: + if any( other.x-ego.x< 8 and other.x-ego.x>0 for other in others): + output.agent_mode = AgentMode.Brake + + ### Adding safety assertions + assert not any(other.x-ego.x<1.0 and other.x-ego.x>-1.0 for other in others), 'Seperation' + ########## + + return output \ No newline at end of file diff --git a/verse/analysis/verifier.py b/verse/analysis/verifier.py index 737312ef0c49c73bfd3f5ccbf6d6b8da50527001..6684e6f89e502ae760193b2af59514757d9eff91 100644 --- a/verse/analysis/verifier.py +++ b/verse/analysis/verifier.py @@ -10,7 +10,6 @@ import numpy as np from verse.analysis.analysis_tree import AnalysisTreeNode, AnalysisTree from verse.analysis.dryvr import calc_bloated_tube, SIMTRACENUM from verse.analysis.mixmonotone import calculate_bloated_tube_mixmono_cont, calculate_bloated_tube_mixmono_disc -from verse.analysis.NeuReach.NeuReach_onestep_rect import postCont from verse.analysis.incremental import ReachTubeCache, TubeCache, convert_reach_trans, to_simulate, combine_all from verse.analysis.utils import dedup from verse.parser.parser import find @@ -193,6 +192,7 @@ class Verifier: lane_map = lane_map ) elif reachability_method == "NeuReach": + from verse.analysis.NeuReach.NeuReach_onestep_rect import postCont cur_bloated_tube = postCont( mode, inits[0],