Skip to content

[WIP] Fast rao refactoring #1233

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ private Object runScenario(PrePerimeterResult prePerimeterSensitivityOutput, boo
AutomatonPerimeterResultImpl automatonResult = automatonSimulator.simulateAutomatonState(automatonState.get(), curativeStates, networkClone, stateTree, automatonTreeParameters);
if (automatonResult.getComputationStatus() == ComputationStatus.FAILURE) {
autoStateSensiFailed = true;
contingencyScenarioResults.put(automatonState.get(), new SkippedOptimizationResultImpl(automatonState.get(), automatonResult.getActivatedNetworkActions(), automatonResult.getActivatedRangeActions(automatonState.get()), ComputationStatus.FAILURE, sensitivityFailureOvercost));
//contingencyScenarioResults.put(automatonState.get(), new SkippedOptimizationResultImpl(automatonState.get(), automatonResult.getActivatedNetworkActions(), automatonResult.getActivatedRangeActions(automatonState.get()), ComputationStatus.FAILURE, sensitivityFailureOvercost));
contingencyScenarioResults.put(automatonState.get(), automatonResult);
} else {
contingencyScenarioResults.put(automatonState.get(), automatonResult);
preCurativeResult = automatonResult.getPostAutomatonSensitivityAnalysisOutput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ public CompletableFuture<RaoResult> run() {
BUSINESS_LOGS.info("Merging preventive and post-contingency RAO results:");
RaoLogger.logMostLimitingElementsResults(BUSINESS_LOGS, stateTree.getBasecaseScenario(), preventiveResult, stateTree.getContingencyScenarios(), postContingencyResults, raoParameters.getObjectiveFunctionParameters().getType(), NUMBER_LOGGED_ELEMENTS_END_RAO);
}

RaoLogger.logSensitivityAnalysisResults(String.format("Iteration %d: sensitivity analysis: ", 1),
prePerimeterSensitivityAnalysis.getObjectiveFunction(),
null, //TODO: Find the right remedialActionActivationResult if we want to use costly objective function not needed otherwise
preCurativeSensitivityAnalysisOutput,
raoParameters,
NUMBER_LOGGED_ELEMENTS_DURING_RAO);
return postCheckResults(mergedRaoResults, initialOutput, raoParameters.getObjectiveFunctionParameters());
} catch (RuntimeException e) {
BUSINESS_LOGS.error("{} \n {}", e.getMessage(), ExceptionUtils.getStackTrace(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ public static void logSensitivityAnalysisResults(String prefix,
numberOfLoggedLimitingElements);
}

public static void logObjectifFunctionResult(String prefix,
ObjectiveFunctionResult objectiveFunctionResult,
PrePerimeterResult sensitivityAnalysisResult,
RaoParameters raoParameters,
int numberOfLoggedLimitingElements) {

if (!BUSINESS_LOGS.isInfoEnabled()) {
return;
}

Map<String, Double> virtualCostDetailed = getVirtualCostDetailed(objectiveFunctionResult);

BUSINESS_LOGS.info(prefix + "cost = {} (functional: {}, virtual: {}{})",
formatDoubleBasedOnMargin(objectiveFunctionResult.getCost(), -objectiveFunctionResult.getCost()),
formatDoubleBasedOnMargin(objectiveFunctionResult.getFunctionalCost(), -objectiveFunctionResult.getCost()),
formatDoubleBasedOnMargin(objectiveFunctionResult.getVirtualCost(), -objectiveFunctionResult.getCost()),
virtualCostDetailed.isEmpty() ? "" : " " + virtualCostDetailed);

RaoLogger.logMostLimitingElementsResults(BUSINESS_LOGS,
sensitivityAnalysisResult,
raoParameters.getObjectiveFunctionParameters().getType(),
numberOfLoggedLimitingElements);
}

public static void logRangeActions(OpenRaoLogger logger,
Leaf leaf,
OptimizationPerimeter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public double getMargin(FlowResult flowResult, FlowCnec flowCnec, TwoSides side,
}

private double computeMargin(FlowCnec flowCnec, double newMargin, double prePerimeterMargin) {
if (countriesNotToOptimize.contains(flowCnec.getOperator()) && newMargin > prePerimeterMargin - .0001 * Math.abs(prePerimeterMargin)) {
if (countriesNotToOptimize.contains(flowCnec.getOperator()) && newMargin > prePerimeterMargin - .0001 * Math.abs(prePerimeterMargin) && flowCnec.getState().getInstant().isCurative()) {
return Double.MAX_VALUE;
}
return newMargin;
Expand Down
Loading
Loading