Optimization

Author, run, and deploy rebase.Optimizer models.

rebase.Optimizer is the model class for decision problems solved as optimizations — dispatch, bidding, storage scheduling. It exposes one cloud operation, optimize(...).

Author

import rebase


class BatteryDispatchOptimizer(rebase.Optimizer):
    name = "battery-dispatch"

    def optimize(self, prices: list[float], capacity_mwh: float = 1.0) -> dict:
        charge_hour = prices.index(min(prices))
        discharge_hour = prices.index(max(prices))
        return {
            "charge_hour": charge_hour,
            "discharge_hour": discharge_hour,
            "spread": prices[discharge_hour] - prices[charge_hour],
            "capacity_mwh": capacity_mwh,
        }


model = BatteryDispatchOptimizer()

Run it in the cloud without deploying (target_type=model):

rebase run battery_model.py --param prices='[42.0, 18.5, 95.0]'

Deploy and Invoke

Deploy (see Models for versioning, environments, and promotion):

rebase model deploy battery_model.py --env dev

Call the deployed model through its SDK optimize handle:

import rebase


model = rebase.get_optimizer("default/battery-dispatch")
result = model.optimize.remote(prices=[42.0, 18.5, 95.0], capacity_mwh=2.0)

Optimizers commonly consume the output of deployed Predictors — forecast first, optimize against the forecast — composed in a workflow, often on a schedule.

On this page