VeraGridEngine.Simulations.CatalogueOptimization package

Subpackages

Submodules

VeraGridEngine.Simulations.CatalogueOptimization.catalogue_optimization_driver module

class VeraGridEngine.Simulations.CatalogueOptimization.catalogue_optimization_driver.CatalogueOptimizationDriver(grid: MultiCircuit, options: CatalogueOptimizationOptions, problem: CatalogueOptimizationProblem)[source]

Bases: DriverTemplate

Driver that optimises the per-branch template selection from the grid catalogue using NSGA-3.

The driver is a thin orchestrator: the heavy lifting (apply / evaluate / revert) lives in the CatalogueOptimizationProblem, while the optimization loop is delegated to NSGA_3.

get_steps()[source]

Get the list of evaluation indices used by the GUI to display progress.

Returns:

list of step labels.

name = 'Catalogue optimization'
objective_function(x: ndarray[tuple[Any, ...], dtype[int64]], record_results: bool = True) ndarray[tuple[Any, ...], dtype[float64]][source]

Evaluate the catalogue problem at x and (optionally) record the result.

Parameters:
  • x – integer decision vector with x[i] indexing the template within the i-th pool.

  • record_results – when True the result is appended to the results container.

Returns:

six-objective vector returned by CatalogueOptimizationProblem.objective_function.

options: CatalogueOptimizationOptions
problem: CatalogueOptimizationProblem
run() None[source]

Entry point invoked by the session thread; runs NSGA-3 and finalises the results.

tpe = 'Catalogue optimization'
class VeraGridEngine.Simulations.CatalogueOptimization.catalogue_optimization_driver.CatalogueOptimizationOptions(max_eval: int, pf_options: PowerFlowOptions | None = None)[source]

Bases: OptionsTemplate

Options for the catalogue optimization driver.

Mirrors the relevant subset of InvestmentsEvaluationOptions: only the controls that the GUI currently exposes for catalogue optimization (max evaluations + power flow options).

CLASS_NON_EDITABLE_PROPERTIES: Tuple[str, ...] = ('idtag', 'selected_to_merge', 'diff_changes')
CLASS_PROPERTIES_WITH_PROFILE: Dict[str, str] = {}
CLASS_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:selected_to_merge, prop:comment, prop:diff_changes, prop:max_eval, prop:pf_options)
CLASS_PROPERTY_LIST: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:selected_to_merge, prop:comment, prop:diff_changes, prop:max_eval, prop:pf_options)
CLASS_REGISTERED_PROPERTIES: Dict[str, GCProp] = {'action': prop:action, 'code': prop:code, 'comment': prop:comment, 'diff_changes': prop:diff_changes, 'idtag': prop:idtag, 'max_eval': prop:max_eval, 'name': prop:name, 'pf_options': prop:pf_options, 'rdfid': prop:rdfid, 'selected_to_merge': prop:selected_to_merge}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:max_eval, prop:pf_options)
action: ActionType
comment: str
device_type: DeviceType
diff_changes
max_eval: int
pf_options: PowerFlowOptions
selected_to_merge

VeraGridEngine.Simulations.CatalogueOptimization.catalogue_utils module

class VeraGridEngine.Simulations.CatalogueOptimization.catalogue_utils.LineSnapshot(branch: Line)[source]

Bases: object

Snapshot of the editable fields of a Line that the apply_template method modifies. Used to revert a line to its baseline state between optimization evaluations.

B: float
B0: float
R: float
R0: float
X: float
X0: float
branch: Line
emt_template
rate: float
restore() None[source]

Write the captured values back to the underlying branch, undoing any apply_template mutation.

rms_template
template
ys
ysh
class VeraGridEngine.Simulations.CatalogueOptimization.catalogue_utils.TransformerSnapshot(branch: Transformer2W)[source]

Bases: object

Snapshot of the editable fields of a Transformer2W that apply_template modifies. Used to revert the transformer to its baseline state between optimization evaluations.

B: float
G: float
HV: float
I0: float
LV: float
Pcu: float
Pfe: float
R: float
Sn: float
Vsc: float
X: float
branch: Transformer2W
conn_f
conn_t
emt_template
rate: float
rate_prof
restore() None[source]

Write the captured values back to the underlying transformer, undoing any apply_template mutation.

rms_template
tap_changer
template
VeraGridEngine.Simulations.CatalogueOptimization.catalogue_utils.build_catalogue_pool(grid: MultiCircuit, selected_branches: List[Line | Transformer2W], voltage_tolerance: float, logger: Logger) Tuple[List[Line | Transformer2W], List[List[OverheadLineType | SequenceLineType | UndergroundLineType | TransformerType]]][source]

Build the per-branch catalogue pool for the optimization.

The function categorizes each selected branch (AC line or two-winding transformer), gathers the templates of the matching kind from the grid catalogue, filters them by voltage compatibility, and removes any branch whose pool would have one option or fewer (those slots cannot be optimized over because there is nothing to choose from).

Parameters:
  • grid – multi-circuit whose template catalogues provide the candidate templates.

  • selected_branches – branches that the user has pre-selected on the schematic.

  • voltage_tolerance – relative voltage tolerance (e.g. 0.1 for 10%).

  • logger – logger that receives warnings about unsupported branches and dropped slots.

Returns:

parallel lists (branches, pools) such that pools[i] is the list of templates compatible with branches[i]. Both lists have the same length.

VeraGridEngine.Simulations.CatalogueOptimization.catalogue_utils.take_snapshot(branch: Line | Transformer2W) LineSnapshot | TransformerSnapshot[source]

Produce the right snapshot type for the given branch.

Parameters:

branch – line or two-winding transformer whose state should be captured.

Returns:

a LineSnapshot for AC lines or a TransformerSnapshot for transformers.

Raises:

TypeError – if the branch is not a supported type.

VeraGridEngine.Simulations.CatalogueOptimization.catalogue_utils.template_capex(branch: Line | Transformer2W, template: OverheadLineType | SequenceLineType | UndergroundLineType | TransformerType) float[source]

Compute the capital expenditure of applying a template to a branch.

Line templates have a per-km capex (currency/km), so the cost scales with the line length. Transformer templates carry a flat capex (currency).

Parameters:
  • branch – branch that would receive the template.

  • template – template under consideration.

Returns:

capex contribution in currency units.

Raises:

TypeError – if branch and template combination is not supported.

VeraGridEngine.Simulations.CatalogueOptimization.nsga3_integer module

NSGA-3 wrapper specialised for the catalogue optimization problem.

Differs from VeraGridEngine.Simulations.InvestmentsEvaluation.Methods.NSGA_3 only in the mutation operator: catalogue indices are integer variables in [0, len(pool) - 1] and the pools can hold many templates (well above {0, 1}). The investments NSGA-3 uses BitflipMutation (designed for binary variables) which produces 1 - x; for x>=2 that gives a negative value that then has to be clipped to the boundary, biasing the search toward the lower bound. Here we use PolynomialMutation (bounded by [xl, xu]) plus RoundingRepair so each mutation stays within the valid integer range and actually explores neighbouring slots.

VeraGridEngine.Simulations.CatalogueOptimization.nsga3_integer.NSGA_3_integer(obj_func: Callable[[ndarray[tuple[Any, ...], dtype[int64]]], ndarray[tuple[Any, ...], dtype[float64]]], n_var: int, lb: ndarray[tuple[Any, ...], dtype[int64]], ub: ndarray[tuple[Any, ...], dtype[int64]], n_obj: int, n_partitions: int = 100, max_evals: int = 30, pop_size: int = 1, crossover_prob: float = 0.05, mutation_probability: float = 0.5, mutation_per_var_prob: float = 0.4, eta_crossover: float = 30.0, eta_mutation: float = 20.0) Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

NSGA-3 for problems whose decision vector is an integer index in [lb, ub] per slot.

The configuration matches NSGA_3 from the investments evaluation module except for the mutation operator (PolynomialMutation instead of BitflipMutation), which is the right choice here because our variables are not binary.

Parameters:
  • obj_func – black-box objective function f(x) returning a vector of n_obj values.

  • n_var – number of decision variables.

  • lb – integer lower bound array (length n_var).

  • ub – integer upper bound array (length n_var).

  • n_obj – number of objectives.

  • n_partitions – Das-Dennis partition count for the reference directions.

  • max_evals – maximum number of objective-function evaluations.

  • pop_size – population size.

  • crossover_prob – per-individual crossover probability.

  • mutation_probability – per-individual mutation probability.

  • mutation_per_var_prob – per-variable mutation probability inside an individual.

  • eta_crossover – distribution index for SBX crossover (higher = closer to parents).

  • eta_mutation – distribution index for polynomial mutation (higher = smaller jumps).

Returns:

tuple (X, F) where X is the Pareto-set decision vectors (shape (n_pareto, n_var)) and F is the corresponding objective values (shape (n_pareto, n_obj)).

Module contents