def test_file_arrivals_algorithm_equals(elev: int):
    #   10 is arbitrary
    gen = 10
    arrival_gen = algorithms.FileArrivals(6, 'arrival_files/arrivals_1.csv')
    move_gen = algorithms.RandomAlgorithm()
    """Run a test simulation, and return the simulation statistics"""
    config = {
        'num_rounds': 15,
        'num_floors': 6,
        'num_elevators': elev,
        'elevator_capacity': 3,
        'num_people_per_round': gen,
        'arrival_generator': arrival_gen,
        # File arrival generator with 6 max floors and arrivals dictated by file
        # 'arrival_generator': arrival_gen,
        'moving_algorithm': move_gen,
        'visualize': False
    }

    sim = Simulation(config)
    stats = sim.run(15)
    people = 0
    for elevator in sim.elevators:
        people += len(elevator.passengers)
    for key in sim.waiting:
        people += len(sim.waiting[key])
    assert stats['total_people'] == 8  # 8 according to sample_arrivals.csv
    assert stats['total_people'] - stats['people_completed'] == people
def test_short_sighted():
    gen = 10
    arrival_gen = algorithms.FileArrivals(6, 'arrival_files/arrivals_3.csv')
    move_gen = algorithms.ShortSighted()
    config = {
        'num_rounds': 15,
        'num_floors': 6,
        'num_elevators': 2,
        'elevator_capacity': 3,
        'num_people_per_round': gen,
        'arrival_generator': arrival_gen,
        # File arrival generator with 6 max floors and arrivals dictated by file
        # 'arrival_generator': arrival_gen,
        'moving_algorithm': move_gen,
        'visualize': False
    }
    sim = simulation.Simulation(config)
    stats = sim.run(15)
    people = 0
    for elevator in sim.elevators:
        people += len(elevator.passengers)
    for key in sim.waiting:
        people += len(sim.waiting[key])
    assert stats['num_iterations'] == 15
    assert stats['total_people'] == 9
    assert stats['people_completed'] == 7
    assert stats['max_time'] == 8
    assert stats['min_time'] == 1
    assert stats['avg_time'] == 4
    assert stats['total_people'] - stats['people_completed'] == people
Exemplo n.º 3
0
def sample_run() -> Dict[str, int]:
    """Run a sample simulation, and return the simulation statistics."""
    config = {
        'num_floors': 5,
        'num_elevators': 1,
        'elevator_capacity': 4,
        # This is likely not used.
        'num_people_per_round': 2,
        'arrival_generator': algorithms.FileArrivals(5, 'arr.csv'),
        'moving_algorithm': algorithms.PushyPassenger(),
        'visualize': True
    }
    sim = Simulation(config)
    results = sim.run(17)
    return results
Exemplo n.º 4
0
def sample_run() -> Dict[str, int]:
    """Run a sample simulation, and return the simulation statistics."""
    config = {
        'num_floors': 6,
        'num_elevators': 3,
        'elevator_capacity': 3,
        'num_people_per_round': 4,
        # Random arrival generator with 6 max floors and 2 arrivals per round.
        'arrival_generator': algorithms.FileArrivals(6, 'sample_arrivals.csv'),
        'moving_algorithm': algorithms.ShortSighted(),
        'visualize': True
    }
    sim = Simulation(config)
    stats = sim.run(9)
    return stats
Exemplo n.º 5
0
def sample_run() -> Dict[str, int]:
    """Run a sample simulation, and return the simulation statistics."""
    config = {
        'num_floors': 6,
        'floor_height': 10,
        'num_elevators': 4,
        'elevator_capacity': 2,
        'num_people_per_round': 2,
        'arrival_generator': algorithms.FileArrivals(6, 'test3.csv'),
        'moving_algorithm': algorithms.ShortSighted(),
        'visualize': False
    }

    sim = Simulation(config)
    stats = sim.run(20)
    return stats
Exemplo n.º 6
0
def sample_run() -> Dict[str, int]:
    """Run a sample simulation, and return the simulation statistics."""
    config = {
        'num_floors': 5,
        'num_elevators': 2,
        'elevator_capacity': 10,
        # This is likely not used.
        'num_people_per_round': 2,
        'arrival_generator': algorithms.FileArrivals(5, 'sample_arrivals.csv'),
        'moving_algorithm': algorithms.ShortSighted(),
        'visualize': True
    }

    sim = Simulation(config)
    stats = sim.run(10)
    return stats
Exemplo n.º 7
0
def sample_run() -> Dict[str, int]:
    """Run a sample simulation, and return the simulation statistics."""
    config = {
        'num_floors': 6,
        'num_elevators': 6,
        'elevator_capacity': 3,
        'num_people_per_round': 3,
        # Random arrival generator with 6 max floors and 1 arrival per round.
        # 'arrival_generator': algorithms.RandomArrivals(6, 2),
        'arrival_generator': algorithms.FileArrivals(8, 'sample_arrivals.csv'),
        'moving_algorithm': algorithms.PushyPassenger(),
        'visualize': True
    }

    sim = Simulation(config)
    stats = sim.run(15)
    return stats
Exemplo n.º 8
0
def sample_run() -> Dict[str, int]:
    """Run a sample simulation, and return the simulation statistics."""
    config = {
        'num_floors': 6,  #check
        'num_elevators': 3,  #check
        'elevator_capacity': 3,  #check
        'num_people_per_round': 2,
        # Random arrival generator with 6 max floors and 2 arrivals per round.
        'arrival_generator': algorithms.FileArrivals(6, "sample_arrivals.csv"),
        'moving_algorithm': algorithms.ShortSighted(),
        'visualize': True,
        'max-attributes': 12,
        'disable': ['R0201']
    }

    sim = Simulation(config)
    stats = sim.run(10)
    return stats
Exemplo n.º 9
0
"""CSC148 Assignment 1 - Simulation