Пример #1
0
from __future__ import absolute_import
from __future__ import print_function

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'])
    
    @property
    def CO2_episode(self):
        return self._CO2_episode

    @property
    def fuel_episode(self):
        return self._fuel_episode
    
    @property
    def waiting_times(self):
        return self._get_waiting_times()


if __name__ == "__main__":
    config = import_test_configuration(config_file='settings/testing_one_settings.ini')
    sumo_cmd = set_sumo(config['gui'], config['simulation_folder'], config['sumocfg_file_name'], config['max_steps'])
    model_path, plot_path = set_test_path(config['models_path_name'], config['model_to_test'])

    Traffic_Generator = Traffic_Generator(
        config["flow_file"],
        config["route_file"],
        config["n_cars_generated"],
        config["simulation_time"]
    )

    Visualization = Visualization(
        plot_path,
        dpi=96
    )