예제 #1
0
                                                   n_vehicle_list[i].x, 0] = 0
                            if n_vehicle_list[i].y < 108:
                                north_highway.grid[n_vehicle_list[i].y - 2,
                                                   n_vehicle_list[i].x, 0] = 0
                            n_vehicle_list.remove(n_vehicle_list[i])

                            shift += 1
                n_vehicle_list.reverse()
                north_highway.gpl_speed = (
                    (north_highway.get_speed(n_total_moved_per_step[1],
                                             (1 / 360.0), 1)) +
                    (north_highway.get_speed(n_total_moved_per_step[2],
                                             (1 / 60.0), 2))) / 2.0
                north_highway.etl_speed = (north_highway.get_speed(
                    n_total_moved_per_step[0], (1 / 360.0), 0))
                north_highway.set_toll(t)
                time_vs_money[north_highway.etl_price] += len(n_vehicle_list)
                n_speed_g.append(north_highway.gpl_speed)
                n_speed_e.append(north_highway.etl_speed)
                if t % 5 == 0:
                    for i in range(len(north_highway.exits_arr)):
                        north_highway.exits_arr[i].deplete()
                #chaneg based on anticipated traffic numbers
                while bool(random.randint(0, 50) <= 30):
                    if random.randint(0, 1000000) / 1000000.0 <= percent_bus:
                        enter_number = random.randint(
                            0, len(north_highway.entrance_arr))
                        n_vehicle_list.append(
                            Bus(3,
                                north_highway.entrance_arr[enter_number - 1].y,
                                10))
예제 #2
0
def highway_setters_test():
    
    length_in_miles = 10
    
    min_price = 0
    
    max_price = 1
    
    start_tolling = 5
    
    end_tolling = 19
    
    shoulder_start = 15
    
    shoulder_end = 17
    
    GPL = 2
    
    ETL = 1
    
    exits = [3, 4, 6]
    
    peak_arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    
    test_road = Highway(length_in_miles, num_norm_lns=GPL, \
                        num_etl=ETL, exit_loc_arr = exits, \
                        min_toll=min_price, max_toll=max_price, \
                        start_tolling=start_tolling, end_tolling=end_tolling, \
                        start_shoulder=shoulder_start, end_shoulder=shoulder_end, peak_arr=peak_arr)
    
    if N.shape(test_road.grid)[0] != test_road.grid_per_mile * length_in_miles:
        print("Possible problem in scaling road")
    else:
        print("Road Length Scaled")
    if N.shape(test_road.grid)[1] != 5:
        print("Possible problem in _generate_road construction")
    else:
        print("Road Width maintained")
    for i in exits:
        if test_road.grid[M.floor(i*test_road.grid_per_mile - 0.5 * test_road.grid_per_mile), 3, 3] != 2:
            print("Exit \t\t", i, " Not Generated Properly" )
        else:
            print("Exit \t\t", i, " Generated Properly")
        if test_road.grid[M.ceil(i*test_road.grid_per_mile + 0.5 * test_road.grid_per_mile), 3, 3] != 1:
            print("Entrance \t", i, " Not Generated Properly" )
        else:
            print("Entrance \t", i, " Generated Properly")
    
    for i in range(24):
        test_road.set_toll(i)
        if i >= start_tolling and i < end_tolling:
            if test_road.etl_price != min_price and test_road.etl_price != max_price:
                print("ETL Price Inaacurate: Problems in set_toll")
            else:
                print("ETL Price Accurate: set_toll has no known problems")
        else:
            if test_road.etl_price != 0:
                print("ETL Price Inaacurate: Problems in set_toll")                
            else:                
                print("ETL Price Accurate: set_toll has no known problems")
    
    for i in range(24):
        test_road.open_shoulder(i)
        """Known problems in openeing shoulder"""
        if i >= shoulder_start and i < shoulder_end:
            if test_road.shoulder_open == False:
                print("Error opening shoulder")
            else:
                print("Shoudler opened successfully")
        else:
            if test_road.shoulder_open == True:
                print("Error closing shoulder")
            else:
                print("Shoudler closed successfully")