Exemplo n.º 1
0
    def __init__(self, parameters: dict = {}):
        """
        @param path where results go, like "Experiment ID"
        @param parameters the configuration parameters.
        gui: whether we show a GUI. 
        scenario: the path to the scenario to use
        """
        logging.debug(parameters)
        self._parameters = copy.deepcopy(self._DEFAULT_PARAMETERS)
        self._parameters.update(parameters)

        dirname = os.path.dirname(__file__)
        tlPhasesFile = os.path.join(dirname, "../../scenarios/Sumo/",
                                    self._parameters['scene'],
                                    self._parameters['tlphasesfile'])
        self._tlphases = TrafficLightPhases(tlPhasesFile)
        self.ldm = ldm(using_libsumo=self._parameters['libsumo'])

        self._takenActions = {}
        self._yellowTimer = {}
        self._chosen_action = None
        self.seed(42)  # in case no seed is given
        self._action_space = self._getActionSpace()
        self.stats_control = Control(self._parameters['tripinfofolder'])
        self.factor_graph = self._parameters['factored_agents']
        self.n_factors = len(list(self.factor_graph.keys()))
        self.factored_coords = self._parameters['factored_coords']
        #self.pixelsPerMeter = self._parameters['pixelsPerMeter']
        self.testseed = list(self._parameters['test_seed'])
        self.seed_cntr = 0
Exemplo n.º 2
0
    def test_load(self):
        dirname = os.path.dirname(__file__)
        filename = os.path.join(dirname, "test.tll.xml")

        res = TrafficLightPhases(filename)
        self.assertEqual(['0', '1'], res.getIntersectionIds())
        self.assertEqual(1, res.getNrPhases('1'))  # one has yellow
        self.assertEqual(4, res.getNrPhases('0'))  # 4 of 8 have yellow
        self.assertEqual("GGggrrrrGGggrrrr", res.getPhase("0", 0))
    def __init__(self, parameters: dict = {}, init_state=True):
        """
        @param path where results go, like "Experiment ID"
        @param parameters the configuration parameters.
        gui: whether we show a GUI.
        scenario: the path to the scenario to use
        """
        logging.debug(parameters)
        self._parameters = copy.deepcopy(self._DEFAULT_PARAMETERS)
        self._parameters.update(parameters)

        self._scenario_path = os.path.join(self._parameters['scenarios_path'],
                                           self._parameters['scene'])

        if self._parameters['tlphasesfile'] is None:
            tlPhasesFile = self._parameters[
                'tlphasesfile'] = self.get_net_file()
        else:
            tlPhasesFile = os.path.join(self._parameters['scenarios_path'],
                                        self._parameters['scene'],
                                        self._parameters['tlphasesfile'])

        self._tlphases = TrafficLightPhases(tlPhasesFile)

        self.ldm = ldm(using_libsumo=self._parameters['libsumo'])
        self._takenActions = {}
        self._yellowTimer = {}
        self._chosen_action = None
        self.seed(parameters['seed'])  # in case no seed is given
        self._action_space = self._getActionSpace()

        # TODO: Wouter: make state configurable ("state factory")
        if init_state:
            self._state = LdmMatrixState(self.ldm, [
                self._parameters['box_bottom_corner'],
                self._parameters['box_top_corner']
            ], self._parameters["reward_range"], "byCorners")
        else:
            self._state = None

        # Computed when needed instead of in __init__:
        self._observation_space = None
Exemplo n.º 4
0
    def __init__(self, parameters:dict={}):
        """
        @param path where results go, like "Experiment ID"
        @param parameters the configuration parameters.
        gui: whether we show a GUI.
        scenario: the path to the scenario to use
        """
        logging.debug(parameters)
        self._parameters = copy.deepcopy(self._DEFAULT_PARAMETERS)
        self._parameters.update(parameters)

        dirname = os.path.dirname(__file__)
        tlPhasesFile = os.path.join(dirname, "../../scenarios/Sumo/", self._parameters['scene'], self._parameters['tlphasesfile'])
        self._tlphases = TrafficLightPhases(tlPhasesFile)
        self.ldm = ldm(using_libsumo=self._parameters['libsumo'])

        self._takenActions = {}
        self._yellowTimer = {}
        self._chosen_action = None
        self.seed(42)  # in case no seed is given
        self._action_space = self._getActionSpace()