def test_random_algorithm_equals(gen: int, elev: int):
    arrival_gen = algorithms.RandomArrivals(6, gen)
    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'] == gen * 15
    assert stats['total_people'] - stats['people_completed'] == people
Beispiel #2
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': 5,
        # Random arrival generator with 6 max floors and 2 arrivals per round.
        'arrival_generator': algorithms.RandomArrivals(6, 2),
        'moving_algorithm': algorithms.RandomAlgorithm(),
        'visualize': True
    }

    sim = Simulation(config)
    stats = sim.run(15)
    return stats
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': 7,
        # File arrival from "sample_arrivals.csv
        # and Random Arrival with 2 people every round"
        #'arrival_generator': algorithms.FileArrivals(6, "sample_arrivals.csv"),
        'arrival_generator': algorithms.RandomArrivals(6, 2),
        'moving_algorithm': algorithms.RandomAlgorithm(),
        #'moving_algorithm': algorithms.PushyPassenger(),
        #'moving_algorithm': algorithms.ShortSighted(),
        'visualize': True
    }

    sim = Simulation(config)
    stats = sim.run(15)
    return stats