citygrid-policy-driven-fede.../citygrid/adapters/der_controller.py

25 lines
906 B
Python

from __future__ import annotations
from citygrid import LocalProblem
from citygrid.bridge.energi_bridge import EnergiBridge
from citygrid import __version__ as citygrid_version
class DerControllerAdapter:
def __init__(self, adapter_id: str = "der-controller-1"):
self.adapter_id = adapter_id
def build_local_problem(self) -> LocalProblem:
# Toy local problem for a DER controller
return LocalProblem(
id="lp-der-1",
domain="electricity",
assets=["DER-Unit-1"],
objective={"minimize": ["loss"], "weight": 1.0},
constraints={"voltage": {"min": 0.95, "max": 1.05}},
solver_hint=None,
)
def receive_delta(self, delta: dict) -> dict:
# In a real system, this would update internal state. Here we echo the delta.
return {"ack": True, "delta_version": delta.get("version", 0)}