All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.farao_community.farao.data.crac_api.RemedialAction Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
/*
 * Copyright (c) 2019, 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.farao_community.farao.data.crac_api;

import com.farao_community.farao.data.crac_api.cnec.FlowCnec;
import com.farao_community.farao.data.crac_api.usage_rule.OnContingencyStateAdderToRemedialAction;
import com.farao_community.farao.data.crac_api.usage_rule.UsageMethod;
import com.farao_community.farao.data.crac_api.usage_rule.UsageRule;
import com.powsybl.iidm.network.Country;
import com.powsybl.iidm.network.Network;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Most generic interface for remedial actions.
 *
 * A Remedial Action is a lever which can be applied on the network. It is typically used to improve
 * a network situation (e.g. increase the margin on the critical network elements).
 *
 * A Remedial Action contains {@link UsageRule} which defines conditions under which it can be used.
 * For instance, most remedial actions cannot be used in all {@link State}, and the usage rules of the
 * remedial action specify on which state it is available.
 *
 * @author Joris Mancini {@literal }
 * @author Peter Mitri {@literal }
 * @author Baptiste Seguinot {@literal }
 */
public interface RemedialAction> extends Identifiable {

    /**
     * Get the operator of the remedial action, as a String
     */
    String getOperator();

    /**
     * Get the list of {@link UsageRule} of the Remedial Action
     */
    List getUsageRules();

    /**
     * Get the {@link UsageMethod} of the Remedial Action in a given state, deduced from the
     * usage rules of the remedial action
     */
    UsageMethod getUsageMethod(State state);

    /**
     * Get the speed of the Remedial Action, i.e the time it takes to trigger.
     */
    Optional getSpeed();

    /**
     * Evaluates if the remedial action is available depending on its UsageMethod.
     */
    boolean isRemedialActionAvailable(State state);

    /**
     * Evaluates if the remedial action is available depending on its UsageMethod.
     */
    boolean isRemedialActionAvailable(State state, boolean evaluatedCondition);

    Set getFlowCnecsConstrainingUsageRules(Set perimeterCnecs, Network network, State optimizedState);

    /**
     * Gather all the network elements present in the remedial action. It returns a set because network
     * elements must not be duplicated inside a remedial action and there is no defined order for network elements.
     */
    Set getNetworkElements();

    /**
     * Returns the location of the remedial action, as a set of optional countries
     * @param network: the network object used to look for the location of the network elements of the remedial action
     * @return a set of optional countries containing the remedial action
     */
    default Set> getLocation(Network network) {
        return getNetworkElements().stream().map(networkElement -> networkElement.getLocation(network))
                .flatMap(Set::stream).collect(Collectors.toUnmodifiableSet());
    }

    OnContingencyStateAdderToRemedialAction newOnStateUsageRule();
}