Skip to content

Commit

Permalink
enable prev factors after sensi ends (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle authored Jul 9, 2024
1 parent 7a46992 commit 1f4d5b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ public List<Contingency> getContingencies(Network network) {
public void disableFactorsForBaseCaseSituation() {
this.afterContingencyOnly = true;
}

@Override
public void enableFactorsForBaseCaseSituation() {
this.afterContingencyOnly = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public interface CnecSensitivityProvider extends ContingenciesProvider {

void disableFactorsForBaseCaseSituation();

void enableFactorsForBaseCaseSituation();

List<SensitivityFactor> getBasecaseFactors(Network network);

List<SensitivityFactor> getContingencyFactors(Network network, List<Contingency> contingencies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public void disableFactorsForBaseCaseSituation() {
cnecSensitivityProviders.forEach(CnecSensitivityProvider::disableFactorsForBaseCaseSituation);
}

@Override
public void enableFactorsForBaseCaseSituation() {
cnecSensitivityProviders.forEach(CnecSensitivityProvider::enableFactorsForBaseCaseSituation);
}

@Override
public List<SensitivityFactor> getBasecaseFactors(Network network) {
List<SensitivityFactor> factors = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ static SystematicSensitivityResult runSensitivity(Network network,
network.getVariantManager().removeVariant(variantForState);
}

// enable preventive factors for next iterations
cnecSensitivityProvider.enableFactorsForBaseCaseSituation();

TECHNICAL_LOGS.debug("Systematic sensitivity analysis with applied RA [end]");

network.getVariantManager().setWorkingVariant(workingVariantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ void testDisableFactorForBaseCase() {
// factors after disabling basecase
assertEquals(0, provider.getBasecaseFactors(network).size());
assertEquals(4, provider.getContingencyFactors(network, List.of(new Contingency("Contingency FR1 FR3", new ArrayList<>()))).size());

provider.enableFactorsForBaseCaseSituation();
// factors are enabled back
assertEquals(4, provider.getBasecaseFactors(network).size());

}

@Test
Expand Down

0 comments on commit 1f4d5b3

Please sign in to comment.