pypsa.optimization.optimize.OptimizationAccessor.optimize_mga

pypsa.optimization.optimize.OptimizationAccessor.optimize_mga#

OptimizationAccessor.optimize_mga(snapshots: Sequence | None = None, multi_investment_periods: bool = False, weights: dict | None = None, sense: str | int = 'min', slack: float = 0.05, model_kwargs: dict = {}, **kwargs: Any) tuple[str, str]#

Run modelling-to-generate-alternatives (MGA) on network to find near- optimal solutions.

Parameters:
  • n (pypsa.Network snapshots : list-like) – Set of snapshots to consider in the optimization. The default is None.

  • multi_investment_periods (bool, default False) – Whether to optimise as a single investment period or to optimize in multiple investment periods. Then, snapshots should be a pd.MultiIndex.

  • weights (dict-like) –

    Weights for alternate objective function. The default is None, which minimizes generation capacity. The weights dictionary should be keyed with the component and variable (see pypsa/variables.csv), followed by a float, dict, pd.Series or pd.DataFrame for the coefficients of the objective function. Examples:

    >>> {"Generator": {"p_nom": 1}}
    >>> {"Generator": {"p_nom": pd.Series(1, index=n.generators.index)}}
    >>> {"Generator": {"p_nom": {"gas": 1, "coal": 2}}}
    >>> {"Generator": {"p": pd.Series(1, index=n.generators.index)}
    >>> {"Generator": {"p": pd.DataFrame(1, columns=n.generators.index, index=n.snapshots)}
    

    Weights for non-extendable components are ignored. The dictionary does not need to provide weights for all extendable components.

  • sense (str|int) – Optimization sense of alternate objective function. Defaults to ‘min’. Can also be ‘max’.

  • slack (float) – Cost slack for budget constraint. Defaults to 0.05.

  • model_kwargs (dict) – Keyword arguments used by linopy.Model, such as solver_dir or chunk.

  • **kwargs – Keyword argument used by linopy.Model.solve, such as solver_name,

Returns: