Spaces:
Running on Zero
Running on Zero
Download simulation/baseline.py from BJyotibrat/BanTrel-Inference: direct link, hf CLI and curl.
- Browser
- Download file 591 Bytes
-
https://huggingface.co/spaces/BJyotibrat/BanTrel-Inference/resolve/main/simulation/baseline.py
- Command line
-
hf download hf://spaces/BJyotibrat/BanTrel-Inference/simulation/baseline.py
-
curl -L -o baseline.py https://huggingface.co/spaces/BJyotibrat/BanTrel-Inference/resolve/main/simulation/baseline.py
591 Bytes
| """Fixed-cycle baseline controller — verbatim port of BanTRel.py Cell 9.""" | |
| class FixedCyclePolicy: | |
| """ | |
| Deterministic fixed-cycle traffic signal controller. | |
| cycle_steps=3, step_length=10s -> 30s per phase, 60s full cycle. | |
| """ | |
| def __init__(self, cycle_steps: int = 3) -> None: | |
| self.cycle_steps = cycle_steps | |
| self.step_counter = 0 | |
| def choose_action(self, state) -> int: | |
| phase = (self.step_counter // self.cycle_steps) % 2 | |
| self.step_counter += 1 | |
| return int(phase) | |
| def reset(self) -> None: | |
| self.step_counter = 0 | |