idea165-commonsgrid-communi.../idea165_commonsgrid_communi.../adapters/inverter_adapter.py

20 lines
718 B
Python

from typing import Dict, Any
from ..dsl import LocalProblem
class InverterControllerAdapter:
"""
Toy adapter that maps rooftop PV inverter signals to a canonical LocalProblem delta.
"""
def __init__(self, neighborhood_id: str):
self.neighborhood_id = neighborhood_id
def map_to_local_problem(self, pv_output_kw: float, demand_kw: float) -> Dict[str, Any]:
lp = LocalProblem(
neighborhood_id=self.neighborhood_id,
objective="minimize_cost",
data_sources=["pv_inverter"],
constraints={"pv_output_kw": pv_output_kw, "demand_kw": demand_kw},
)
# Simple LocalProblem dictionary representation
return lp.to_dict()