Ejemplo n.º 1
0
    def __init__(self, master_kernel, sim_params):
        """See parent class."""
        KernelVehicle.__init__(self, master_kernel, sim_params)

        self.__ids = []  # ids of all vehicles
        self.__human_ids = []  # ids of human-driven vehicles
        self.__controlled_ids = []  # ids of flow-controlled vehicles
        self.__controlled_lc_ids = []  # ids of flow lc-controlled vehicles
        self.__rl_ids = []  # ids of rl-controlled vehicles
        self.__observed_ids = []  # ids of the observed vehicles

        # vehicles: Key = Vehicle ID, Value = Dictionary describing the vehicle
        # Ordered dictionary used to keep neural net inputs in order
        self.__vehicles = collections.OrderedDict()

        # total number of vehicles in the network
        self.num_vehicles = 0
        # number of rl vehicles in the network
        self.num_rl_vehicles = 0

        # contains the parameters associated with each type of vehicle
        self.type_parameters = {}

        # list of vehicle ids located in each edge in the network
        self._ids_by_edge = dict()

        # number of vehicles that entered the network for every time-step
        self._num_departed = []
        self._departed_ids = []

        # number of vehicles to exit the network for every time-step
        self._num_arrived = []
        self._arrived_ids = []

        # contains conversion from Flow-ID to Aimsun-ID
        self._id_aimsun2flow = {}
        self._id_flow2aimsun = {}

        # contains conversion from Flow-type to Aimsun-type
        self._type_aimsun2flow = {}
        self._type_flow2aimsun = {}

        # number of vehicles of each type
        self.num_type = {}
Ejemplo n.º 2
0
    def __init__(self,
                 master_kernel,
                 sim_params):
        """See parent class."""
        KernelVehicle.__init__(self, master_kernel, sim_params)

        self.__ids = []  # ids of all vehicles
        self.__human_ids = []  # ids of human-driven vehicles
        self.__controlled_ids = []  # ids of flow-controlled vehicles
        self.__controlled_lc_ids = []  # ids of flow lc-controlled vehicles
        self.__rl_ids = []  # ids of rl-controlled vehicles
        self.__observed_ids = []  # ids of the observed vehicles

        # vehicles: Key = Vehicle ID, Value = Dictionary describing the vehicle
        # Ordered dictionary used to keep neural net inputs in order
        self.__vehicles = collections.OrderedDict()

        # total number of vehicles in the network
        self.num_vehicles = 0
        # number of rl vehicles in the network
        self.num_rl_vehicles = 0

        # contains the parameters associated with each type of vehicle
        self.type_parameters = {}

        # list of vehicle ids located in each edge in the network
        self._ids_by_edge = dict()

        # number of vehicles that entered the network for every time-step
        self._num_departed = []
        self._departed_ids = []

        # number of vehicles to exit the network for every time-step
        self._num_arrived = []
        self._arrived_ids = []

        # contains conversion from Flow-ID to Aimsun-ID
        self._id_aimsun2flow = {}
        self._id_flow2aimsun = {}

        # current number of vehicles of each type
        self.num_type = {}
        # total number of vehicles of each type (used for naming them)
        self.total_num_type = {}

        # type of vehicles that will be tracked
        # note: vehicles added via the scenario (ie by calling the
        # add_vehicle function) will also be tracked, even if their
        # type is not specified here
        self.tracked_vehicle_types = {"rl", "idm"}  # TODO maybe generic

        # all the vehicle tracking information that should be stored
        # for the tracked vehicles info that can be tracked:
        # CurrentPos, distance2End, xCurrentPos, yCurrentPos, zCurrentPos,
        # xCurrentPosBack, yCurrentPosBack, zCurrentPosBack, CurrentSpeed,
        # TotalDistance, SectionEntranceT, CurrentStopTime, stopped,
        # idSection, segment, numberLane, idJunction, idSectionFrom,
        # idLaneFrom, idSectionTo, idLaneTo
        self.tracked_info_bitmap = self.make_bitmap_for_tracking({
            'CurrentPos', 'distance2End',
            'xCurrentPos', 'yCurrentPos', 'xCurrentPosBack', 'yCurrentPosBack',
            'CurrentSpeed', 'numberLane',
            'idSection', 'idJunction', 'idSectionFrom', 'idSectionTo'
        })