Module ml4opf.formulations.ed
Economic Dispatch
Sub-modules
ml4opf.formulations.ed.model
-
Base class for EconomicDispatch proxy models
ml4opf.formulations.ed.problem
-
EconomicDispatch Problem data class
ml4opf.formulations.ed.violation
-
Class interface for EconomicDispatch constraints, objective, etc.
Classes
class EDModel
-
OPFModel
for EconomicDispatchAncestors
- OPFModel
- abc.ABC
Subclasses
Class variables
var problem : EDProblem
var violation : EDViolation
Methods
def evaluate_model(self, reduction: str | None = None, inner_reduction: str | None = None) ‑> dict[str, torch.Tensor]
-
Evaluate the model on the test data.
Args
reduction
:str
, optional- Reduction method for the metrics. Defaults to None. Must be one of "mean", "sum","max", "none". If specified, each value in the returned dictionary will be a scalar. Otherwise, they are arrays of shape (n_test_samples,)
inner_reduction
:str
, optional- Reduction method for turning metrics calculated per component to per sample. Defaults to None. Must be one of "mean", "sum","max", "none".
Returns
dict[str, Tensor]
-
Dictionary containing Tensor metrics of the model's performance.
pg_lower
: Generator lower bound violation.pg_upper
: Generator upper bound violation.pf_lower
: Branch power flow lower bound violation.pf_upper
: Branch power flow upper bound violation.p_balance
: Power balance violation.pg_mae
: Mean absolute error of the real power generation.obj_mape
: Mean absolute percent error of the objective value.
Inherited members
class EDProblem (data_directory: str, ptdf_path: str, dataset_name: str = 'ED', **parse_kwargs)
-
OPFProblem
for EconomicDispatchAncestors
- OPFProblem
- abc.ABC
Instance variables
prop default_combos : dict[str, list[str]]
-
Default combos for EconomicDispatch. input: pd, target: pg, va
prop default_order : list[str]
-
Default order for EconomicDispatch. input, target
prop feasibility_check : dict[str, str]
-
Default feasibility check for EconomicDispatch.
prop violation : EDViolation
-
OPFViolation object for EconomicDispatch constraint calculations.
Inherited members
class EDViolation (data: dict, ptdf: torch.Tensor)
-
OPFViolation
for EconomicDispatchInitialize internal Module state, shared by both nn.Module and ScriptModule.
Ancestors
- OPFViolation
- torch.nn.modules.module.Module
- abc.ABC
Methods
def balance_residual(self,
pd: torch.Tensor,
pg: torch.Tensor,
dpb_surplus: torch.Tensor | None = None,
dpb_shortage: torch.Tensor | None = None,
clamp: bool = False) ‑> torch.Tensor-
Compute power balance residual.
def calc_violations(self,
pd: torch.Tensor,
pg: torch.Tensor,
reduction: str = 'mean',
clamp: bool = True) ‑> dict[str, torch.Tensor]-
Compute all EconomicDispatch violations.
def objective(self, pd: torch.Tensor, pg: torch.Tensor) ‑> torch.Tensor
-
Compute ED objective function.
def pf_bound_residual(self, pf: torch.Tensor, df: torch.Tensor | None = None, clamp: bool = False) ‑> torch.Tensor
-
Compute power flow bound residual.
def pf_from_pdpg(self, pd: torch.Tensor, pg: torch.Tensor, dense_incidence: bool = False) ‑> torch.Tensor
-
Compute power flow from power demand and power generation.
def pg_bound_residual(self, pg: torch.Tensor, clamp: bool = False) ‑> torch.Tensor
-
Compute power generation bound residual.
Inherited members