Simulation

rebase.Simulator models for gym-style environments (local-only for now).

rebase.Simulator is the model class for gym-style environments: reset() starts an episode, step(action) advances it. Simulators are how Agents and Optimizers are evaluated before deployment.

Local-only for now. Simulators are not deployable as cloud targets yet — they run in your own environment (tests, notebooks, backtests). The class exists so simulator code shares the model metadata and versioning conventions, ready for cloud execution later.

Author

import rebase


class BatterySimulator(rebase.Simulator):
    name = "battery-sim"

    def reset(self, capacity_mwh: float = 1.0) -> dict:
        self.soc = 0.5 * capacity_mwh
        self.capacity = capacity_mwh
        return {"soc": self.soc}

    def step(self, action: dict) -> dict:
        delta = action.get("charge_mwh", 0.0) - action.get("discharge_mwh", 0.0)
        self.soc = min(max(self.soc + delta, 0.0), self.capacity)
        return {"soc": self.soc}


sim = BatterySimulator()
state = sim.reset(capacity_mwh=2.0)
state = sim.step({"charge_mwh": 0.5})

Backtesting Environments

For forecasting and trading problems, emflow provides ready-made gym environments (ForecastEnv, TradingEnv) with leakage-safe, point-in-time data feeds — the same environments that score candidates in hillclimb searches. Prefer those over hand-rolled simulators when your problem fits them.

On this page