def observation_space(self): traffic_lights = Box( low=0.0, high=1.0, shape=(4 * self.num_traffic_lights,), # each traffic light can be observed as in up-down, left-rigth, or in yellow. [1 0 0 0] means grgr, [0 1 0 0] means yryr, [0 0 1 0] means rgrg, and [0 0 0 1] means ryry dtype=np.float32) # TODO after validation that it works with float, type should be turned into boolean. last_change = Box( low=0.0, high=1.0, shape=(self.num_traffic_lights,), # normalized time laps since the last change. dtype=np.float32) #print ('observation_space: observed_queue: {}, traffic_lights: {}, last_change: {}'.format(self.edge_names, 4 * self.num_traffic_lights, self.num_traffic_lights)) if self.observation_mode == "Q_WEIGHT": """ Use normalized weighted average of cars in the queue as observation. Normalization is with regards to a full queue of vehicles. Traffic lights are observed as a vector signifying which lights are on. The lapsed time from the last change is normalized to the max phase lenght.""" observed_queue = Box( low=0.0, high=1.0, shape=(len(self.edge_names),), # we observe all edges dtype=np.float32) return Tuple((observed_queue, traffic_lights, last_change)) if self.observation_mode == "SEGMENT": observed_segments = Box( low=0.0, high=1.0, shape=(self.total_nof_segments,), # we observe all segments dtype=np.float32) return Tuple((observed_segments, traffic_lights, last_change))
def observation_space(self): """ See parent class An observation is an array the velocities for each vehicle """ speed = Box(low=0, high=np.inf, shape=(self.vehicles.num_vehicles, )) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) distance_to_intersection = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) lane = Box(low=0, high=(2 - 1), shape=(self.vehicles.num_vehicles, )) no_leaders = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) no_follower = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) remaining_green = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) next_green = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) return Tuple((speed, absolute_pos, distance_to_intersection, lane, no_leaders, no_follower, remaining_green, next_green))
def action_space(self): """See class definition.""" if self.env_params.additional_params['communicate']: accel = Box(low=-3.0, high=3.0, shape=(1, ), dtype=np.float32) communicate = Discrete(2) return Tuple((accel, communicate)) else: return Box(low=-3.0, high=3.0, shape=(1, ), dtype=np.float32)
def observation_space(self): speed = Box(low=0, high=np.inf, shape=(self.n_obs_vehicles,), dtype=np.float32) absolute_pos = Box(low=0., high=np.inf, shape=(self.n_obs_vehicles,), dtype=np.float32) queue_length = Box(low=0, high=np.inf, shape=(1,), dtype=np.float32) vel_stats = Box(low=-np.inf, high=np.inf, shape=(2,), dtype=np.float32) return Tuple((speed, absolute_pos, queue_length, vel_stats))
def observation_space(self): """ See parent class """ speed = Box(low=0, high=np.inf, shape=(self.vehicles.num_vehicles, )) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) edge = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) return Tuple([speed, absolute_pos, edge])
def observation_space(self): """ See parent class An observation is an array the velocities for each vehicle """ speed = Box(low=0, high=np.inf, shape=(self.vehicles.num_vehicles, )) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) return Tuple((speed, absolute_pos))
def __init__(self): self.seed_num = None self.dealer = [] self.player = [] # ACE, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King self.deck = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) self.action_space = Discrete(N_ACTIONS) self.observation_space = Tuple( (Discrete(11), Discrete(32), Discrete(2))) self.reward_range = (-1, 1) self.dealer_stop = DEALER_SICK_SUM
def observation_space(self): """ See parent class An observation is an array the velocities and absolute positions for each vehicle """ self.obs_var_labels = ["Velocity", "Absolute_pos"] speed = Box(low=0, high=np.inf, shape=(self.vehicles.num_vehicles,)) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles,)) return Tuple((speed, absolute_pos))
def observation_space(self): self.obs_var_labels = ["Velocity", "Absolute_pos"] speed = Box(low=0, high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) pos = Box(low=0., high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) return Tuple((speed, pos))
def observation_space(self): """ See parent class """ num_vehicles = self.scenario.num_vehicles observation_space = [] speed = Box(low=0, high=np.inf, shape=(num_vehicles,)) absolute_pos = Box(low=0., high=np.inf, shape=(num_vehicles,)) obs_tuple = Tuple((speed, absolute_pos)) for veh_id in self.rl_ids: observation_space.append(obs_tuple) return observation_space
def observation_space(self): """ See parent class. An observation is an array the velocities, positions, and edges for each vehicle """ self.obs_var_labels = ["speed", "lane_pos", "edge_id"] speed = Box(low=0, high=np.inf, shape=(self.vehicles.num_vehicles,)) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles,)) edge_id = Box(low=0., high=1, shape=(self.vehicles.num_vehicles,)) is_rl = Box(low=0., high=1, shape=(self.vehicles.num_vehicles,)) return Tuple((speed, absolute_pos, edge_id, is_rl))
def observation_space(self): speed = Box(low=-np.inf, high=np.inf, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) lane = Box(low=0, high=self.scenario.lanes - 1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) return Tuple((speed, absolute_pos, lane))
def observation_space(self): speed = Box(low=0, high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) lane = Box(low=0, high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) pos = Box(low=0., high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) return Tuple((speed, pos, lane))
def __init__(self, rows=8, cols=8, mines=10): seed() # Initialize RNG self.action_space = Tuple((Discrete(rows), Discrete(cols))) self.rows = rows self.cols = cols self.mines = mines self.nonMines = rows * cols - mines self.clickedCoords = set() self.letter_Axis = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't' ] self.chosenCoords = [] self.state = np.full([self.rows, self.cols], Minefield.UNKNOWN) self.neighboring_mines = 0
def observation_space(self): """ See parent class An observation consists of the velocity, absolute position, and lane index of each vehicle in the fleet """ speed = Box(low=-np.inf, high=np.inf, shape=(self.vehicles.num_vehicles, )) lane = Box(low=0, high=self.scenario.lanes - 1, shape=(self.vehicles.num_vehicles, )) absolute_pos = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, )) return Tuple((speed, absolute_pos, lane))
def observation_space(self): speed = Box(low=0, high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) dist_to_intersec = Box(low=0., high=np.inf, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) edge_num = Box(low=0., high=1, shape=(self.vehicles.num_vehicles, ), dtype=np.float32) traffic_lights = Box(low=0., high=1, shape=(3 * self.rows * self.cols, ), dtype=np.float32) return Tuple((speed, dist_to_intersec, edge_num, traffic_lights))
def observation_space(self): """See class definition.""" if self.test: Box(low=0, high=0, shape=(0, ), dtype=np.float32) speed = Box(low=0, high=1, shape=(self.scenario.vehicles.num_vehicles, ), dtype=np.float32) dist_to_intersec = Box(low=0., high=np.inf, shape=(self.scenario.vehicles.num_vehicles, ), dtype=np.float32) edge_num = Box(low=0., high=1, shape=(self.scenario.vehicles.num_vehicles, ), dtype=np.float32) traffic_lights = Box(low=0., high=1, shape=(3 * self.num_traffic_lights, ), dtype=np.float32) return Tuple((speed, dist_to_intersec, edge_num, traffic_lights))
def __init__(self, rows=8, cols=8, mines=10): seed() # Initialize RNG self.action_space = Tuple((Discrete(rows), Discrete(cols))) self.rows = rows self.cols = cols self.mines = mines