diff --git a/demo/vehicle/controller/inc-expr-fsw4.py b/demo/vehicle/controller/inc-expr-fsw4.py index 3e166c6e1fbfafec62a1e284061292d98ca9fd62..647a54fd1104f508e5c3e6132b5798abcdb61f45 100644 --- a/demo/vehicle/controller/inc-expr-fsw4.py +++ b/demo/vehicle/controller/inc-expr-fsw4.py @@ -52,13 +52,13 @@ def controller(ego:State, others:List[State], lane_map): output = copy.deepcopy(ego) if ego.vehicle_mode == VehicleMode.Normal: # Switch left if left lane is empty - if car_front(ego, others, lane_map, 4, 3): + if car_front(ego, others, lane_map, 4.5, 3): if lane_map.has_left(ego.lane_mode) and \ not car_left(ego, others, lane_map): output.vehicle_mode = VehicleMode.SwitchLeft # Switch right if right lane is empty - if car_front(ego, others, lane_map, 4, 3): + if car_front(ego, others, lane_map, 4.5, 3): if lane_map.has_right(ego.lane_mode) and \ not car_right(ego, others, lane_map): output.vehicle_mode = VehicleMode.SwitchRight diff --git a/demo/vehicle/inc-expr.py b/demo/vehicle/inc-expr.py index 039d937b1d1480b5c27eab4b5456a8e83abd8ba5..67cd2ec8564f29b988e12cbde7b881bf586a2828 100644 --- a/demo/vehicle/inc-expr.py +++ b/demo/vehicle/inc-expr.py @@ -52,7 +52,7 @@ if 'p' in arg: def run(sim, meas=False): time = timeit.default_timer() if sim: - traces = scenario.simulate(60, 0.05) + traces = scenario.simulate(60, 0.1) else: traces = scenario.verify(60, 0.1) @@ -78,6 +78,7 @@ def run(sim, meas=False): "dur": timeit.default_timer() - time, "cache_size": cache_size, "node_count": len(traces.nodes), + "hits": scenario.simulator.cache_hits if sim else (scenario.verifier.tube_cache_hits, scenario.verifier.trans_cache_hits), }) if __name__ == "__main__": diff --git a/inc-expr.py b/inc-expr.py index 6c068b170b672dc96e86f3305665d15a0977058a..3e94f1a22961b133214daa20a7f583cf773cd4c8 100644 --- a/inc-expr.py +++ b/inc-expr.py @@ -3,6 +3,7 @@ from itertools import product from pprint import pp import re from subprocess import PIPE, Popen +from typing import Tuple, Union @dataclass class ExperimentResult: @@ -12,10 +13,11 @@ class ExperimentResult: cache_size: float node_count: int ret_code: int + cache_hits: Union[Tuple[int, int], Tuple[Tuple[int, int], Tuple[int, int]]] xprms = [ - "v" + - "".join(l) for l in product("n8", ("", "i"))] + # "v" + + "".join(l) for l in product("brn8", ("", "i"))] rslts = [] for xprm in xprms: cmd = Popen(f"/usr/bin/time -v -- python3.8 demo/vehicle/inc-expr.py {xprm}", stdout=PIPE, stderr=PIPE, shell=True) @@ -30,7 +32,7 @@ for xprm in xprms: print(b"".join(stderr)) exit(2) info = eval(filtered_info[0]) - rslt = ExperimentResult(xprm, max_mem, info["dur"], info["cache_size"] / 1_000_000, info["node_count"], ret) + rslt = ExperimentResult(xprm, max_mem, info["dur"], info["cache_size"] / 1_000_000, info["node_count"], ret, info["hits"]) pp(rslt) if rslt.ret_code != 0: print(f"uh oh, var={xprm} ret={rslt.ret_code}") @@ -50,4 +52,5 @@ for i in range(0, len(rslts), 2): elif "8" in var: name = "change ctlr" - print(" & " + " & ".join([name] + [str(i) for i in [inc.node_count, round(no.duration, 2), round(no.max_mem), round(inc.duration, 2), round(inc.max_mem), round(inc.cache_size, 2)]]) + " \\\\") + cache_hit_rate = inc.cache_hits[0] / (inc.cache_hits[0] + inc.cache_hits[1]) if "v" not in var else (inc.cache_hits[0][0] + inc.cache_hits[1][0]) / (inc.cache_hits[0][0] + inc.cache_hits[0][1] + inc.cache_hits[1][0] + inc.cache_hits[1][1]) + print(" & " + " & ".join([name] + [str(i) for i in [inc.node_count, round(no.duration, 2), round(no.max_mem), round(inc.duration, 2), round(inc.max_mem), round(inc.cache_size, 2), round(cache_hit_rate * 100, 2)]]) + " \\\\")