Class AbstractLimitsComputerWithCache<P,L>

java.lang.Object
com.powsybl.iidm.network.limitmodification.AbstractLimitsComputerWithCache<P,L>
All Implemented Interfaces:
LimitsComputer<P,L>
Direct Known Subclasses:
AbstractLimitReductionsApplier, LimitsComputer.NoModificationsImpl

public abstract class AbstractLimitsComputerWithCache<P,L> extends Object implements LimitsComputer<P,L>

Abstract class responsible for computing limits (potentially altered from the ones declared on the network element).

Already computed altered limits are stored in an internal cache to avoid unnecessary computations. This cache should be cleared with clearCache() when the reductions to apply are changed.

Author:
Olivier Perrin <olivier.perrin at rte-france.com>
  • Constructor Details

    • AbstractLimitsComputerWithCache

      protected AbstractLimitsComputerWithCache()
  • Method Details

    • computeLimits

      public Optional<LimitsContainer<L>> computeLimits(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly)

      Retrieve the limits of processable corresponding to the given limits type and side, then apply on them the modifications configured in the current LimitsComputer.

      The result of this method contains both originals and altered limits.

      Resulting limits are stored in an internal cache, by (identifier's ID, limit type, side), in order to avoid unnecessary re-computation. If needed, this cache can be cleared using clearCache().

      Specified by:
      computeLimits in interface LimitsComputer<P,L>
      Parameters:
      processable - The network element for which the reduced limits must be computed
      limitType - The type of the limits to process
      side - The side of processable on which the limits should be retrieved
      monitoringOnly - If true, compute the limits to use for a monitoring only use case. If false, compute the limits to use for a monitoring + action use case.
      Returns:
      an object containing the original limits and the altered ones
    • computeUncachedLimits

      protected abstract Optional<LimitsContainer<L>> computeUncachedLimits(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly)

      Retrieve the limits on processable then apply modifications on them.

      If no modifications applies on the resulting LimitsContainer must contains the same object for the original and the reduced limits.

      This function is called when the corresponding limits were not found in the cache.

      This function is responsible for the addition of the computed limit in the cache (via the putInCache(P, com.powsybl.iidm.network.LimitType, com.powsybl.iidm.network.ThreeSides, boolean, com.powsybl.iidm.network.limitmodification.result.LimitsContainer<L>) method).

      Parameters:
      processable - the network element for which the limits must be retrieved and modified
      limitType - the type of limits to process
      side - the side of the network element where to retrieve the original limits
      monitoringOnly - If true, compute the limits to use for a monitoring only use case. If false, compute the limits to use for a monitoring + action use case.
      Returns:
      an object containing both the original and the modified limits.
    • putInCache

      protected void putInCache(P processable, LimitType limitType, ThreeSides side, boolean monitoringOnly, LimitsContainer<L> limitsContainer)
    • clearCache

      public void clearCache()

      Clear the cache containing the already computed limits.

      This method must be called when the modifications to apply on the original limits of a network element are changed.