Module ml4opf.formulations.dc.model
Base class for DCOPF proxy models
Classes
class DCModel-
OPFModelfor DCOPFAncestors
- OPFModel
- abc.ABC
Subclasses
Class variables
var problem : DCProblemvar violation : DCViolation
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.dva_lower: Angle difference limit lower bound violation.dva_upper: Angle difference limit upper bound violation.pf_lower: Flow limit lower bound violation.pf_upper: Flow limit upper bound violation.p_balance: Power balance violation.pg_mae: Mean absolute error of the real power generation.va_mae: Mean absolute error of the voltage angle. (if not bus-wise and va not in predictions, skipped)pf_mae: Mean absolute error of the real power flow.obj_mape: Mean absolute percent error of the objective value.
def predict(self, pd: torch.Tensor) ‑> dict[str, torch.Tensor]-
Predict the DCOPF primal solution for a given set of loads.
Args
pd:Tensor- Active power demand per load.
Returns
dict[str, Tensor]-
Dictionary containing the predicted primal solution.
pg: Active power generation per generator or per bus.va: Voltage angle per bus.
Inherited members
class PerfectDCModel (problem: DCProblem)-
Returns the ground truth, only works with test data.
Ancestors
Methods
def predict(self, pd: torch.Tensor) ‑> dict[str, torch.Tensor]-
Return the ground truth. Only works for
self.problem.test_data.
Inherited members