def test_realistic_road(self): # Test Case 2 (more realistic road) road = build_road(14, [80, 60, 40, 20]) lane_change_cost = 1.0 / 100.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 0.293333333333 self.assertAlmostEqual(cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 10)
def test_fast_left_lane(self): # Test Case 1 (FAST left lane) road = build_road(8, [100, 10, 1]) lane_change_cost = 1.0 / 1000.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 1.244 self.assertAlmostEqual(cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 3)
def test_realistic_road(self): # Test Case 2 (more realistic road) road = build_road(14, [80, 60, 40, 20]) lane_change_cost = 1.0 / 100.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 0.293333333333 self.assertAlmostEqual( cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 10)
def test_fast_left_lane(self): # Test Case 1 (FAST left lane) road = build_road(8, [100, 10, 1]) lane_change_cost = 1.0 / 1000.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 1.244 self.assertAlmostEqual( cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 3)
def test_slalom(self): # Test Case 4 (Slalom) road = [[50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 0, 50, 50, 50, 50], # left lane: 50 km/h [40, 40, 40, 40, 0, 30, 20, 30, 0, 40, 40, 40, 40, 40, 40], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]] # right lane: 30 km/h lane_change_cost = 1.0 / 65.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 0.450641025641 self.assertAlmostEqual(cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 10)
def test_obstacles_included(self): # Test Case 3 (Obstacles included) road = [[50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 50, 50, 50, 50, 50], # left lane: 50 km/h [40, 40, 40, 40, 40, 30, 20, 30, 40, 40, 40, 40, 40, 40, 40], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]] # right lane: 30 km/h lane_change_cost = 1.0 / 500.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 0.355333333333 self.assertAlmostEqual(cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 10)
def test_slalom(self): # Test Case 4 (Slalom) road = [ [50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 0, 50, 50, 50, 50], # left lane: 50 km/h [40, 40, 40, 40, 0, 30, 20, 30, 0, 40, 40, 40, 40, 40, 40], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30] ] # right lane: 30 km/h lane_change_cost = 1.0 / 65.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 0.450641025641 self.assertAlmostEqual( cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 10)
def test_obstacles_included(self): # Test Case 3 (Obstacles included) road = [ [50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 50, 50, 50, 50, 50], # left lane: 50 km/h [40, 40, 40, 40, 40, 30, 20, 30, 40, 40, 40, 40, 40, 40, 40], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30] ] # right lane: 30 km/h lane_change_cost = 1.0 / 500.0 init = [len(road) - 1, 0] goal = [len(road) - 1, len(road[0]) - 1] cost = 0.355333333333 self.assertAlmostEqual( cost, plan(road=road, lane_change_cost=lane_change_cost, goal=goal, init=init), 10)