Standalone Gym-style wrapper for CityFlow traffic signal control.
This package extracts the CityFlow simulation wrapper from LibSignal and keeps the observation, reward, and info definitions inside the environment rather than inside an agent class.
Run from this folder:
python -m cityflow_gym.env from cityflow_gym import GymTSCEnv, TSCEnvSpec
env = GymTSCEnv(
cityflow_config="configs/cityflow1x1.json",
thread_num=1,
spec=TSCEnvSpec(
obs_keys=("lane_count", "phase"),
reward_key="negative_waiting_count",
reward_mode="vector",
),
)
obs = env.reset()
actions = env.action_space.sample()
next_obs, rewards, done, info = env.step(actions)Observation keys:
lane_countlane_waiting_countlane_delaypressurephasephase_one_hot
Reward keys:
negative_waiting_countnegative_queuenegative_pressurenegative_delay
Reward modes:
vector: one reward per controllable intersectionmean: scalar mean rewardsum: scalar summed reward