com.powsybl.openrao.searchtreerao.commons.objectivefunctionevaluator.CostEvaluatorUtils 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) 2024, 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.commons.objectivefunctionevaluator;
import com.powsybl.openrao.data.crac.api.State;
import com.powsybl.openrao.data.crac.api.cnec.FlowCnec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Thomas Bouquet {@literal }
*/
public final class CostEvaluatorUtils {
private CostEvaluatorUtils() {
}
public static Map> groupFlowCnecsPerState(Set flowCnecs) {
Map> flowCnecsPerState = new HashMap<>();
flowCnecs.forEach(flowCnec -> flowCnecsPerState.computeIfAbsent(flowCnec.getState(), k -> new HashSet<>()).add(flowCnec));
return flowCnecsPerState;
}
public static List sortFlowCnecsByDecreasingCost(Map costPerFlowCnec) {
List sortedFlowCnecs = new ArrayList<>(costPerFlowCnec.entrySet().stream().sorted(Comparator.comparingDouble(Map.Entry::getValue)).map(Map.Entry::getKey).toList());
Collections.reverse(sortedFlowCnecs);
return sortedFlowCnecs;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy