Example #1
0
import os
from shutil import copyfile

from testing_simulation import Simulation
from generator import TrafficGenerator
from model import TestModel
from visualization import Visualization
from utils import import_test_configuration, set_sumo, set_test_path

if __name__ == "__main__":

    config = import_test_configuration(config_file='testing_settings.ini')
    sumo_cmd = set_sumo(config['gui'], config['sumocfg_file_name'],
                        config['max_steps'])
    model_path, plot_path = set_test_path(config['models_path_name'],
                                          config['model_to_test'])

    Model = TestModel(input_dim=config['num_states'], model_path=model_path)

    TrafficGen = TrafficGenerator(config['max_steps'], config['n_v_generated'])

    Visualization = Visualization(plot_path, dpi=96)

    Simulation = Simulation(Model, TrafficGen, sumo_cmd, sumo_cmd,
                            config['max_steps'], config['green_duration'],
                            config['yellow_duration'], config['num_states'],
                            config['num_actions'])

    print('\n----- Test episode')
    simulation_time = Simulation.run(
        config['episode_seed'])  # run the simulation
Example #2
0
from shutil import copyfile
import datetime

from simulation import Simulation, TestSimulation
from generator import TrafficGenerator
from model import TestModel
from visualization import Visualization
from utils import import_test_configuration, set_sumo, set_test_path

if __name__ == "__main__":

    config = import_test_configuration(config_file='testing_settings.ini')
    sumo_cmd = set_sumo(config['gui'], config['sumocfg_file_name'],
                        config['max_steps'])
    model_path, plot_path = set_test_path(config['models_path_name'],
                                          config['model_to_test'],
                                          config['scenario_number'])

    #SET STATE DIMENSION PARAMETERS
    number_of_cells_per_lane = 10
    conv_state_shape = (number_of_cells_per_lane, 8, 2)
    green_phase_state_shape = 4
    elapsed_time_state_shape = 1
    state_shape = [
        conv_state_shape, green_phase_state_shape, elapsed_time_state_shape
    ]

    Model = TestModel(model_path=model_path, state_shape=state_shape)

    TrafficGen = TrafficGenerator(config['max_steps'],
                                  config['penetration_rate'])