Skip to content

Commit

Permalink
added rectangle diams
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitish Bhupathi Raju authored and Nitish Bhupathi Raju committed Jan 19, 2025
1 parent 7dacc12 commit 03c5a86
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions verse/utils/star_diams.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from matplotlib.patches import Ellipse
from z3 import *
from verse.utils.star_manhattan import *
from verse.utils.fixed_points import *

import numpy as np
from scipy.integrate import ode
from verse import BaseAgent, Scenario
from verse.analysis.analysis_tree import AnalysisTree
from verse.analysis import AnalysisTreeNode, AnalysisTree


def over_approx_rectangle(trace, time_horizon, time_step):
Expand Down Expand Up @@ -61,6 +68,23 @@ def time_step_diameter(trace, time_horizon, time_step):
#print(diameters)
return diameters

def manhattan(a, b):
return sum(abs(val1-val2) for val1, val2 in zip(a,b))

def time_step_diameter_rect(tree: AnalysisTree, time_horizon, time_step):
time_steps = np.linspace(0, time_horizon, int(time_horizon/time_step) + 1, endpoint= True)
diameters = []
for i in range(len(time_steps) - 1):
curr_diam = []
reach_tubes = reach_at_fix(tree, time_steps[i] - time_step*.05, time_steps[i+1] + time_step*.05)
nodes = list(reach_tubes.keys())
for node in nodes:
if reach_tubes[node] is not None:
curr_diam.append(manhattan(reach_tubes[node][0], reach_tubes[node][1]))
if len(curr_diam) > 0:
diameters.append(max(curr_diam))
return diameters

### assuming mode is not a parameter
def reach_star(traces, t_l: float = 0, t_u: float = None) -> Dict[str, List[StarSet]]:
reach = {}
Expand Down

0 comments on commit 03c5a86

Please sign in to comment.