Customize Observations, Actions, and Rewards
mainObservations
The default observation for each traffic signal agent is a vector containing:
phase_one_hot: One-hot encoded vector of the current green phase.min_green: Binary variable (hasmin_greentime passed?).lane_i_density: Vehicle count in lane $i$ divided by total capacity.lane_i_queue: Number of queued vehicles (speed < 0.1 m/s) in lane $i$ divided by total capacity.
To use a custom observation, implement a class inheriting from ObservationFunction and pass it to the SumoEnvironment constructor.
Actions
The action space is discrete. Every delta_time seconds, an agent chooses the next green phase configuration. Note that phase changes are always preceded by a yellow phase lasting yellow_time seconds.
Rewards
The default reward is the change in cumulative vehicle delay (the change in the sum of waiting times of all approaching vehicles compared to the previous step).
To use a custom reward function, pass a function that accepts a TrafficSignal object to the reward_fn parameter in the SumoEnvironment constructor.
# Example of a custom reward function
def my_reward_fn(traffic_signal):
return traffic_signal.get_average_speed()
env = SumoEnvironment(..., reward_fn=my_reward_fn)