com.powsybl.openrao.searchtreerao.result.impl.SkippedOptimizationResultImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of open-rao-search-tree-rao Show documentation
Show all versions of open-rao-search-tree-rao Show documentation
Implementation of search tree remedial action optimisation with modular approach
The newest version!
/*
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.openrao.searchtreerao.result.impl;
import com.powsybl.contingency.Contingency;
import com.powsybl.openrao.commons.OpenRaoException;
import com.powsybl.openrao.commons.Unit;
import com.powsybl.openrao.data.crac.api.Instant;
import com.powsybl.openrao.data.crac.api.State;
import com.powsybl.openrao.data.crac.api.cnec.FlowCnec;
import com.powsybl.iidm.network.TwoSides;
import com.powsybl.openrao.data.crac.api.networkaction.NetworkAction;
import com.powsybl.openrao.data.crac.api.rangeaction.PstRangeAction;
import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction;
import com.powsybl.openrao.data.raoresult.api.ComputationStatus;
import com.powsybl.openrao.searchtreerao.result.api.OptimizationResult;
import com.powsybl.sensitivity.SensitivityVariableSet;
import java.util.*;
/**
* @author Philippe Edwards {@literal }
*/
public class SkippedOptimizationResultImpl implements OptimizationResult {
private static final String SHOULD_NOT_BE_USED = "Should not be used: optimization result has been skipped.";
private static final String SENSITIVITY_FAILURE_COST = "sensitivity-failure-cost";
private final State state;
private final Set activatedNetworkActions;
private final Set> activatedRangeActions;
private final ComputationStatus computationStatus;
private final double sensitivityFailureOverCost;
public SkippedOptimizationResultImpl(State state, Set activatedNetworkActions, Set> activatedRangeActions, ComputationStatus computationStatus, double sensitivityFailureOverCost) {
this.state = state;
this.activatedNetworkActions = activatedNetworkActions;
this.activatedRangeActions = activatedRangeActions;
this.computationStatus = computationStatus;
this.sensitivityFailureOverCost = sensitivityFailureOverCost;
}
@Override
public ComputationStatus getSensitivityStatus() {
return computationStatus;
}
@Override
public ComputationStatus getSensitivityStatus(State state) {
return computationStatus;
}
@Override
// The following method is used to determine which contingencies must be excluded from cost computation
public Set getContingencies() {
if (computationStatus != ComputationStatus.FAILURE) {
Optional contingency = state.getContingency();
if (contingency.isPresent()) {
return Set.of(contingency.get().getId());
}
}
return new HashSet<>();
}
@Override
public double getSensitivityValue(FlowCnec flowCnec, TwoSides side, RangeAction> rangeAction, Unit unit) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getSensitivityValue(FlowCnec flowCnec, TwoSides side, SensitivityVariableSet linearGlsk, Unit unit) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getFlow(FlowCnec flowCnec, TwoSides side, Unit unit) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getFlow(FlowCnec flowCnec, TwoSides side, Unit unit, Instant instant) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getMargin(FlowCnec flowCnec, Unit unit) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getCommercialFlow(FlowCnec flowCnec, TwoSides side, Unit unit) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getPtdfZonalSum(FlowCnec flowCnec, TwoSides side) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public Map> getPtdfZonalSums() {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public boolean isActivated(NetworkAction networkAction) {
return activatedNetworkActions.contains(networkAction);
}
@Override
public Set getActivatedNetworkActions() {
return new HashSet<>(activatedNetworkActions);
}
@Override
public double getFunctionalCost() {
return -1.0;
}
@Override
public List getMostLimitingElements(int number) {
return new ArrayList<>();
}
@Override
public double getVirtualCost() {
return sensitivityFailureOverCost;
}
@Override
public Set getVirtualCostNames() {
return Set.of(SENSITIVITY_FAILURE_COST);
}
@Override
public double getVirtualCost(String virtualCostName) {
return virtualCostName.equals(SENSITIVITY_FAILURE_COST) ? sensitivityFailureOverCost : 0;
}
@Override
public List getCostlyElements(String virtualCostName, int number) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public void excludeContingencies(Set contingenciesToExclude) {
//do not do anything
}
@Override
public Set> getRangeActions() {
return activatedRangeActions;
}
@Override
public Set> getActivatedRangeActions(State state) {
return activatedRangeActions;
}
@Override
public double getOptimizedSetpoint(RangeAction> rangeAction, State state) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public Map, Double> getOptimizedSetpointsOnState(State state) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public double getSetPointVariation(RangeAction> rangeAction, State state) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public int getOptimizedTap(PstRangeAction pstRangeAction, State state) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public Map getOptimizedTapsOnState(State state) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
@Override
public int getTapVariation(PstRangeAction pstRangeAction, State state) {
throw new OpenRaoException(SHOULD_NOT_BE_USED);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy