Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable scaling before ACOPF solving #62

Merged
merged 19 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions open-reac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,29 @@ The user can configure the run with the dedicated Java interface
Specifically, the user can set various parameters and thresholds used in the preprocessing and modeling of the reactive OPF.
These are specified in the file `param_algo.txt`:

| Parameter | Description | Default value | Domain |
|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-----------------------------------------------|
| `log_level_ampl` | Level of display for AMPL prints | INFO | {DEBUG, INFO, WARNING, ERROR} |
| `log_level_knitro` | Level of display for solver prints (see [AMPL documentation](https://dev.ampl.com/ampl/options.html)) | $1$ | {0, 1, 2} |
| `objective_choice` | Choice of the objective function for the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) | $0$ | {0, 1, 2} |
| `ratio_voltage_target` | Ratio to calculate target V of buses when `objective_choice` is set to $1$ (see [7](#7-alternative-current-optimal-power-flow)) | $0.5$ | $\[0; 1\]$ |
| `coeff_alpha` | Weight to favor more/less minimization of active power produced by generators or deviation between them and target values (see [6.2](#62-alternative-current-optimal-power-flow)) | $1$ | $\[0; 1\]$ |
| `Pnull` | Threshold of active and reactive powers considered as null | $0.01$ (MW) | $\[0; 1\]$ |
| `Znull` | Threshold of impedance considered as null (see [4.2](#)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ |
| `epsilon_nominal_voltage` | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathbb{R}^{+}$ |
| `min_plausible_low_voltage_limit` | Consistency bound for low voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $0.5$ (p.u.) | $\mathbb{R}^{+}$ |
| `max_plausible_high_voltage_limit` | Consistency bound for high voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $1.5$ (p.u.) | [`min_plausible_low_voltage_limit`; $\infty$] |
| `ignore_voltage_bounds` | Threshold to replace voltage limits of voltage levels with nominal voltage lower than it, by [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] | $0$ (p.u.) | $\mathbb{R}^{+}$ |
| `buses_with_reactive_slacks` | Choice of which buses will have reactive slacks attached in ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} |
| `PQmax` | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | $\mathbb{R}$ |
| `defaultPmax` | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | $\mathbb{R}$ |
| `defaultPmin` | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | $\mathbb{R}$ |
| `defaultQmaxPmaxRatio` | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.4](#44-pq-units-domain)) | $0.3$ (MVAr/MW) | $\mathbb{R}$ |
| `minimalQPrange` | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.4](#44-pq-units-domain)) | $1$ (MW, MVAr) | $\mathbb{R}$ |
| Parameter | Description | Default value | Domain |
|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-----------------------------------------------|
| `log_level_ampl` | Level of display for AMPL prints | INFO | {DEBUG, INFO, WARNING, ERROR} |
| `log_level_knitro` | Level of display for solver prints (see [AMPL documentation](https://dev.ampl.com/ampl/options.html)) | $1$ | {0, 1, 2} |
| `objective_choice` | Choice of the objective function for the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) | $0$ | {0, 1, 2} |
| `ratio_voltage_target` | Ratio to calculate target V of buses when `objective_choice` is set to $1$ (see [7](#7-alternative-current-optimal-power-flow)) | $0.5$ | $\[0; 1\]$ |
| `coeff_alpha` | Weight to favor more/less minimization of active power produced by generators or deviation between them and target values (see [6.2](#62-alternative-current-optimal-power-flow)) | $1$ | $\[0; 1\]$ |
| `Pnull` | Threshold of active and reactive powers considered as null | $0.01$ (MW) | $\[0; 1\]$ |
| `Znull` | Threshold of impedance considered as null (see [4.2](#)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ |
| `epsilon_nominal_voltage` | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathbb{R}^{+}$ |
| `min_plausible_low_voltage_limit` | Consistency bound for low voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $0.5$ (p.u.) | $\mathbb{R}^{+}$ |
| `max_plausible_high_voltage_limit` | Consistency bound for high voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $1.5$ (p.u.) | [`min_plausible_low_voltage_limit`; $\infty$] |
| `ignore_voltage_bounds` | Threshold to replace voltage limits of voltage levels with nominal voltage lower than it, by [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] | $0$ (p.u.) | $\mathbb{R}^{+}$ |
| `buses_with_reactive_slacks` | Choice of which buses will have reactive slacks attached in ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} |
| `PQmax` | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | $\mathbb{R}$ |
| `defaultPmax` | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | $\mathbb{R}$ |
| `defaultPmin` | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | $\mathbb{R}$ |
| `defaultQmaxPmaxRatio` | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.4](#44-pq-units-domain)) | $0.3$ (MVAr/MW) | $\mathbb{R}$ |
| `minimalQPrange` | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.4](#44-pq-units-domain)) | $1$ (MW, MVAr) | $\mathbb{R}$ |
| `default_variable_scaling_factor` | Default scaling factor applied to all the variables (except reactive slacks and transformer ratios) before ACOPF solving | $1$ | $\mathbb{R}^{*,+}$ |
| `default_constraint_scaling_factor` | Default scaling factor applied to all the constraints before ACOPF solving | $1$ | $\mathbb{R}^{+}$ |
| `reactive_slack_variable_scaling_factor` | Scaling factor applied to all reactive slacks variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.1$ | $\mathbb{R}^{*,+}$ |
| `transformer_ratio_variable_scaling_factor` | Scaling factor applied to all transformer ratio variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.001$ | $\mathbb{R}^{*,+}$ |


In addition to the previous parameters, the user can specify which
Expand Down Expand Up @@ -220,7 +224,7 @@ Consequently, **buses connected to the slack only by HVDC lines are excluded**.

This component is determined by solving the following optimization problem (the variables are bolded):

$$\text{minimize} \left(\sum\limits_{i} \boldsymbol{\theta_i^{cc}}\right)$$
$$\text{maximize} \left(\sum\limits_{i} \boldsymbol{\theta_i^{cc}}\right)$$

where $\boldsymbol{\theta_i^{cc}}$ is the voltage angle of bus $i$, and with the following constraints:

Expand Down Expand Up @@ -348,6 +352,7 @@ high coefficient ($10$) to drive it towards $0$, ensuring reactive power balance

Before solving the ACOPF, the voltage magnitudes $\boldsymbol{V_i}$ are warm-started with $V_i^t$
(specified in `ampl_network_buses.txt`), as well as the voltage phases $\boldsymbol{\theta_i}$ with the results of the DCOPF (see [6](#6-direct-current-optimal-power-flow)).
Please also note that a scaling is applied with user-defined values before solving the ACOPF.

The solving is considered as successful if the non-linear solver employed (see [Non-linear solver](#non-linear-optimization-solver))
finds a feasible approximate solution (**even if the sum of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ public class OpenReacParameters {

private ReactiveSlackBusesMode reactiveSlackBusesMode = ReactiveSlackBusesMode.NO_GENERATION;

private static final String DEFAULT_VARIABLE_SCALING_FACTOR = "default_variable_scaling_factor";

private double defaultVariableScalingFactor = 1;

private static final String DEFAULT_CONSTRAINT_SCALING_FACTOR = "default_constraint_scaling_factor";

private double defaultConstraintScalingFactor = 1;

private static final String REACTIVE_SLACK_VARIABLE_SCALING_FACTOR = "reactive_slack_variable_scaling_factor";

private double reactiveSlackVariableScalingFactor = 1e-1;

private static final String TWO_WINDING_TRANSFORMER_RATIO_VARIABLE_SCALING_FACTOR = "transformer_ratio_variable_scaling_factor";

private double twoWindingTransformerRatioVariableScalingFactor = 1e-3;

/**
* Override some voltage level limits in the network. This will NOT modify the network object.
* <p>
Expand Down Expand Up @@ -216,6 +232,66 @@ public OpenReacParameters setReactiveSlackBusesMode(ReactiveSlackBusesMode react
return this;
}

/**
* @return the default scaling value of all the variables in ACOPF solving.
*/
public double getDefaultVariableScalingFactor() {
return defaultVariableScalingFactor;
}

public OpenReacParameters setDefaultVariableScalingFactor(double defaultVariableScalingFactor) {
if (defaultVariableScalingFactor <= 0 || Double.isNaN(defaultVariableScalingFactor)) {
throw new IllegalArgumentException("Default scaling factor for variables must be > 0 and defined to be consistent.");
}
this.defaultVariableScalingFactor = defaultVariableScalingFactor;
return this;
}

/**
* @return the default scaling value of all the constraints in ACOPF solving.
*/
public double getDefaultConstraintScalingFactor() {
return defaultConstraintScalingFactor;
}

public OpenReacParameters setDefaultConstraintScalingFactor(double defaultConstraintScalingFactor) {
if (defaultConstraintScalingFactor < 0 || Double.isNaN(defaultConstraintScalingFactor)) {
throw new IllegalArgumentException("Default scaling factor for constraints must be >= 0 and defined to be consistent.");
}
this.defaultConstraintScalingFactor = defaultConstraintScalingFactor;
return this;
}

/**
* @return the scaling value of reactive slack variables in ACOPF solving.
*/
public double getReactiveSlackVariableScalingFactor() {
return reactiveSlackVariableScalingFactor;
}

public OpenReacParameters setReactiveSlackVariableScalingFactor(double reactiveSlackVariableScalingFactor) {
if (reactiveSlackVariableScalingFactor <= 0 || Double.isNaN(reactiveSlackVariableScalingFactor)) {
throw new IllegalArgumentException("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.");
}
this.reactiveSlackVariableScalingFactor = reactiveSlackVariableScalingFactor;
return this;
}

/**
* @return the scaling value of transformer ratios in ACOPF solving.
*/
public double getTwoWindingTransformerRatioVariableScalingFactor() {
return twoWindingTransformerRatioVariableScalingFactor;
}

public OpenReacParameters setTwoWindingTransformerRatioVariableScalingFactor(double twoWindingTransformerRatioVariableScalingFactor) {
if (twoWindingTransformerRatioVariableScalingFactor <= 0 || Double.isNaN(twoWindingTransformerRatioVariableScalingFactor)) {
throw new IllegalArgumentException("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.");
}
this.twoWindingTransformerRatioVariableScalingFactor = twoWindingTransformerRatioVariableScalingFactor;
return this;
}

public List<String> getVariableShuntCompensators() {
return variableShuntCompensators;
}
Expand Down Expand Up @@ -247,6 +323,10 @@ public List<OpenReacAlgoParam> getAllAlgorithmParams() {
allAlgoParams.add(new OpenReacAlgoParamImpl(MIN_PLAUSIBLE_LOW_VOLTAGE_LIMIT_KEY, Double.toString(minPlausibleLowVoltageLimit)));
allAlgoParams.add(new OpenReacAlgoParamImpl(MAX_PLAUSIBLE_HIGH_VOLTAGE_LIMIT_KEY, Double.toString(maxPlausibleHighVoltageLimit)));
allAlgoParams.add(reactiveSlackBusesMode.toParam());
allAlgoParams.add(new OpenReacAlgoParamImpl(DEFAULT_VARIABLE_SCALING_FACTOR, Double.toString(defaultVariableScalingFactor)));
allAlgoParams.add(new OpenReacAlgoParamImpl(DEFAULT_CONSTRAINT_SCALING_FACTOR, Double.toString(defaultConstraintScalingFactor)));
allAlgoParams.add(new OpenReacAlgoParamImpl(REACTIVE_SLACK_VARIABLE_SCALING_FACTOR, Double.toString(reactiveSlackVariableScalingFactor)));
allAlgoParams.add(new OpenReacAlgoParamImpl(TWO_WINDING_TRANSFORMER_RATIO_VARIABLE_SCALING_FACTOR, Double.toString(twoWindingTransformerRatioVariableScalingFactor)));
return allAlgoParams;
}

Expand Down
Loading
Loading