Module ml4opf.formulations.ac.model
Base class for ACOPF proxy models
Classes
class ACModel-
OPFModelfor ACOPFAncestors
- OPFModel
- abc.ABC
Subclasses
Class variables
var problem : ACProblemvar violation : ACViolation
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.
vm_lower: Lower bound on the voltage magnitude.vm_upper: Upper bound on the voltage magnitude.pg_lower: Lower bound on the real power generation.pg_upper: Upper bound on the real power generation.qg_lower: Lower bound on the reactive power generation.qg_upper: Upper bound on the reactive power generation.thrm_1: Thermal limit violation fromthrm_2: Thermal limit violation top_balance: Active power balance violation.q_balance: Reactive power balance violation.pg_mae: Mean absolute error of the real power generation.qg_mae: Mean absolute error of the reactive power generation.vm_mae: Mean absolute error of the voltage magnitude.va_mae: Mean absolute error of the voltage angle. (if not bus-wise and va not in predictions, skipped)dva_mae: Mean absolute error of the angle difference. (only if not bus-wise)obj_mape: Mean absolute percent error of the objective value.
def predict(self, pd: torch.Tensor, qd: torch.Tensor) ‑> dict[str, torch.Tensor]-
Predict the ACOPF primal solution for a given set of loads.
Args
pd:Tensor- Active power demand per load.
qd:Tensor- Reactive power demand per load.
Returns
dict[str, Tensor]-
Dictionary containing the predicted primal solution.
pg: Active power generation per generator or per bus.qg: Reactive power generation per generator or per bus.vm: Voltage magnitude per bus.va: Voltage angle per bus.
Inherited members
class PerfectACPModel (problem: ACProblem)-
Returns the ground truth, only works with test data.
Ancestors
Methods
def predict(self, pd: torch.Tensor, qd: torch.Tensor) ‑> dict[str, torch.Tensor]-
Return the ground truth. Only works for
self.problem.test_data.
Inherited members