def _save_stats(self, traffic_code, tot_neg_reward): # save the stats for this episode
		numb_generated_veh = count_veh.cal_numb_generated_veh(self.get_simu_type_str(traffic_code), is_random = False)

		if traffic_code == 0: # data low
			self._reward_store_LOW.append(tot_neg_reward) # how much negative reward in this episode
			self._cumulative_wait_store_LOW.append(self._sum_intersection_queue) # total number of seconds waited by cars (1 step = 1 second -> 1 car in queue/step = 1 second in queue/step=
			self._avg_intersection_queue_store_LOW.append(self._sum_intersection_queue / self._max_steps) # average number of queued cars per step, in this episode
			self._avg_waiting_time_per_veh_LOW.append(self._sum_intersection_queue / numb_generated_veh)
		if traffic_code == 1: # data high
			self._reward_store_HIGH.append(tot_neg_reward)
			self._cumulative_wait_store_HIGH.append(self._sum_intersection_queue)
			self._avg_intersection_queue_store_HIGH.append(self._sum_intersection_queue / self._max_steps)
			self._avg_waiting_time_per_veh_HIGH.append(self._sum_intersection_queue / numb_generated_veh)
		if traffic_code == 2: # da		# INIT some vars:
			self._reward_store_NS.append(tot_neg_reward)
			self._cumulative_wait_store_NS.append(self._sum_intersection_queue)
			self._avg_intersection_queue_store_NS.append(self._sum_intersection_queue / self._max_steps)
			self._avg_waiting_time_per_veh_NS.append(self._sum_intersection_queue / numb_generated_veh)
		if traffic_code == 3: # data ew
			self._reward_store_EW.append(tot_neg_reward)
			self._cumulative_wait_store_EW.append(self._sum_intersection_queue)
			self._avg_intersection_queue_store_EW.append(self._sum_intersection_queue / self._max_steps)
			self._avg_waiting_time_per_veh_EW.append(self._sum_intersection_queue / numb_generated_veh)
		if traffic_code == 4:
			self._avg_waiting_time_per_veh_RANDOM.append(self._sum_intersection_queue / numb_generated_veh)
Esempio n. 2
0
	def _save_stats(self, traffic_code, tot_neg_reward): # save the stats for this episode
		self._reward_store.append(tot_neg_reward) # how much negative reward in this episode
		self._cumulative_wait_store.append(self._sum_intersection_queue) # total number of seconds waited by cars (1 step = 1 second -> 1 car in queue/step = 1 second in queue/step=
		self._avg_intersection_queue_store.append(self._sum_intersection_queue / self._max_steps) # average number of queued cars per step, in this episode

		numb_generated_veh = count_veh.cal_numb_generated_veh(self.get_simu_type_str(traffic_code), is_random = False)
		self._avg_waiting_time_per_veh.append(self._sum_intersection_queue / numb_generated_veh)
Esempio n. 3
0
    def _save_stats(self, traffic_code, tot_neg_reward): # save the stats for this episode
        numb_generated_veh = count_veh.cal_numb_generated_veh(self.get_simu_type_str(traffic_code), is_random = True)
      
        if traffic_code == 0: # data low
            self._reward_store_LOW.append(tot_neg_reward) # how much negative reward in this episode
            # array của [queue_length, ....]
            self._cumulative_wait_store_LOW.append(self._sum_intersection_queue) # total number of seconds waited by cars (1 step = 1 second -> 1 car in queue/step = 1 second in queue/step=
            # mỗi giây, có bao nhiêu xe đợi?
            self._avg_intersection_queue_store_LOW.append(self._sum_intersection_queue / self._max_steps) # average number of queued cars per step, in this episode

            self._avg_waiting_time_per_veh_LOW.append(self._sum_intersection_queue / numb_generated_veh)
        elif traffic_code == 1: # data high
            self._reward_store_HIGH.append(tot_neg_reward)
            self._cumulative_wait_store_HIGH.append(self._sum_intersection_queue)
            self._avg_intersection_queue_store_HIGH.append(self._sum_intersection_queue / self._max_steps)
            self._avg_waiting_time_per_veh_HIGH.append(self._sum_intersection_queue / numb_generated_veh)
        elif traffic_code == 2: # data ns
            self._reward_store_NS.append(tot_neg_reward)
            self._cumulative_wait_store_NS.append(self._sum_intersection_queue)
            self._avg_intersection_queue_store_NS.append(self._sum_intersection_queue / self._max_steps)
            self._avg_waiting_time_per_veh_NS.append(self._sum_intersection_queue / numb_generated_veh)
        elif traffic_code == 3: # data ew
            self._reward_store_EW.append(tot_neg_reward)
            self._cumulative_wait_store_EW.append(self._sum_intersection_queue)
            self._avg_intersection_queue_store_EW.append(self._sum_intersection_queue / self._max_steps)
            self._avg_waiting_time_per_veh_EW.append(self._sum_intersection_queue / numb_generated_veh)
Esempio n. 4
0
    def _save_fixed_status(self, traffic_code): # save the stats for this episode
        numb_generated_veh = count_veh.cal_numb_generated_veh(self.get_simu_type_str(traffic_code), is_random = False)

        if traffic_code == 0: # data low
            self._avg_waiting_time_per_veh_LOW_fixed_route.append(self._sum_intersection_queue / numb_generated_veh)
        elif traffic_code == 1: # data high
            self._avg_waiting_time_per_veh_HIGH_fixed_route.append(self._sum_intersection_queue / numb_generated_veh)
        elif traffic_code == 2: # data ns
            self._avg_waiting_time_per_veh_NS_fixed_route.append(self._sum_intersection_queue / numb_generated_veh)
        elif traffic_code == 3: # data ew
            self._avg_waiting_time_per_veh_EW_fixed_route.append(self._sum_intersection_queue / numb_generated_veh)

        np.save(constants.path + '_avg_waiting_time_per_veh_LOW_fixed_route.npy', self._avg_waiting_time_per_veh_LOW_fixed_route)
        np.save(constants.path + '_avg_waiting_time_per_veh_HIGH_fixed_route.npy', self._avg_waiting_time_per_veh_HIGH_fixed_route)
        np.save(constants.path + '_avg_waiting_time_per_veh_NS_fixed_route.npy', self._avg_waiting_time_per_veh_NS_fixed_route)
        np.save(constants.path + '_avg_waiting_time_per_veh_EW_fixed_route.npy', self._avg_waiting_time_per_veh_EW_fixed_route)