Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Bouquet <[email protected]>
  • Loading branch information
bqth29 committed Nov 26, 2024
1 parent 82d4256 commit 6638d98
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,29 @@ public abstract class AbstractObjectiveFunctionCreator {
protected final Set<FlowCnec> flowCnecs;
protected final Set<State> optimizedStates;
protected final RaoParameters raoParameters;
protected final MarginEvaluator marginEvaluator;
protected final Unit unit;

protected AbstractObjectiveFunctionCreator(Set<FlowCnec> flowCnecs, Set<State> optimizedStates, RaoParameters raoParameters) {
this.flowCnecs = flowCnecs;
this.optimizedStates = optimizedStates;
this.raoParameters = raoParameters;
this.marginEvaluator = getMarginEvaluator();
this.unit = raoParameters.getObjectiveFunctionParameters().getType().getUnit();
}

protected MarginEvaluator getMarginEvaluator() {
return raoParameters.getObjectiveFunctionParameters().getType().relativePositiveMargins() ? new BasicRelativeMarginEvaluator() : new BasicMarginEvaluator();
}

protected CostEvaluator getFunctionalCostEvaluator() {
protected CostEvaluator getFunctionalCostEvaluator(MarginEvaluator marginEvaluator) {
return raoParameters.getObjectiveFunctionParameters().getType().costOptimization() ? new RemedialActionCostEvaluator(optimizedStates) : new MinMarginEvaluator(flowCnecs, unit, marginEvaluator);
}

protected abstract List<CostEvaluator> getVirtualCostEvaluators();
protected abstract List<CostEvaluator> getVirtualCostEvaluators(MarginEvaluator marginEvaluator);

public ObjectiveFunction create() {
CostEvaluator functionalCostEvaluator = getFunctionalCostEvaluator();
List<CostEvaluator> virtualCostEvaluators = getVirtualCostEvaluators();
MarginEvaluator marginEvaluator = getMarginEvaluator();
CostEvaluator functionalCostEvaluator = getFunctionalCostEvaluator(marginEvaluator);
List<CostEvaluator> virtualCostEvaluators = getVirtualCostEvaluators(marginEvaluator);
return new ObjectiveFunction(functionalCostEvaluator, virtualCostEvaluators, flowCnecs, unit, marginEvaluator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.powsybl.openrao.data.cracapi.State;
import com.powsybl.openrao.data.cracapi.cnec.FlowCnec;
import com.powsybl.openrao.raoapi.parameters.RaoParameters;
import com.powsybl.openrao.searchtreerao.commons.marginevaluator.MarginEvaluator;
import com.powsybl.openrao.searchtreerao.commons.objectivefunctionevaluator.CostEvaluator;
import com.powsybl.openrao.searchtreerao.commons.objectivefunctionevaluator.MinMarginViolationEvaluator;
import com.powsybl.openrao.searchtreerao.commons.objectivefunctionevaluator.SensitivityFailureOvercostEvaluator;
Expand All @@ -28,7 +29,7 @@ protected InitialSensitivityAnalysisObjectiveFunctionCreator(Set<FlowCnec> flowC
}

@Override
protected List<CostEvaluator> getVirtualCostEvaluators() {
protected List<CostEvaluator> getVirtualCostEvaluators(MarginEvaluator marginEvaluator) {
List<CostEvaluator> virtualCostEvaluators = new ArrayList<>();

if (raoParameters.getObjectiveFunctionParameters().getType().costOptimization()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected MarginEvaluator getMarginEvaluator() {
}

@Override
protected List<CostEvaluator> getVirtualCostEvaluators() {
protected List<CostEvaluator> getVirtualCostEvaluators(MarginEvaluator marginEvaluator) {
List<CostEvaluator> virtualCostEvaluators = new ArrayList<>();

if (raoParameters.getObjectiveFunctionParameters().getType().costOptimization()) {
Expand Down

0 comments on commit 6638d98

Please sign in to comment.