Class FlowProfile<T>
java.lang.Object
com.amalgamasimulation.discreterate.flowstatistic.FlowProfile<T>
- Type Parameters:
T- the type of elements managed by this flow profile
Represents a flow profile for elements of type T. Stores the flow history
over time. Allows users to get statistics for any given time interval.
Effectively, this class is analogous to PiecewiseFunction, but with
Accumulator of elements as values, not just doubles.
- Author:
- Alexander Morozov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRate(double fromArgument, Accumulator<T> flowRates) Adds flow rates for elements starting from the specified argument and continuing indefinitely.voidaddRate(Interval withinArgumentInterval, Accumulator<T> flowRates) Adds flow rates for elements within the specified interval.voidaddStepChange(double argument, Accumulator<T> flowStepChanges) Adds a step change based on the provided argument andAccumulatorof flow step changes.voidaddStepChange(Interval argumentInterval, Accumulator<T> flowStepChanges) Adds step changes for the specified argument interval andAccumulatorof flow step changes.copy()Creates a new instance of thisFlowProfilethat is a copy of this profile, and returns this instance.doublefirstArgumentWithValueLessEqualThan(double lessEqualThanValue, double startingFromArgument) Finds and returns the first argument in the summary linear function where its value is less than or equal to the specified threshold, starting the search from the given argument, inclusive.doublefirstArgumentWithValueMoreEqualThan(double moreEqualThanValue, double startingFromArgument) Finds and returns the first argument in the summary linear function where its value is greater than or equal to the specified threshold, starting the search from the given argument, inclusive.flowElementProfile(T element) Returns thePiecewiseFunctionassociated with a given flow element.Returns thePiecewiseFunctionassociated with the summary linear function of all the elements.Calculates the integral of all flow profiles over a specified interval and returns the accumulated results.multiply(double factor) Multiplies the values of this profile by the specified factor.plus(FlowProfile<T> other) Adds the points of another profile to this profile.rateAt(double argument) Returns the flow rate for all element at the specified argument.doubleReturns the flow rate for a specific element at the specified argument.voidsetRate(double startingAtArgument, Accumulator<T> flowRates) Sets new flow rates for the elements starting from the specified argument.subProfile(IntervalLike withinArgumentInterval) Computes and returns a new instance ofFlowProfilewhich is a sub-function of this profile, i.e.subProfile(IntervalLike withinArgumentInterval, boolean shouldContinueLastValues) Computes and returns a new instance ofFlowProfilewhich is a sub-function of this profile, i.e.doublesummaryIntegral(Interval withinArgumentInterval) Calculates the integral of the summary piecewise linear function over the specified argument interval.doublesumRateAt(double argument) Returns the sum of all flow rate at the specified argument.doublesumValueAt(double argument) Returns the sum of all flow values at the specified argument.valueAt(double argument) Returns the flow values for all elements at the specified argument.doubleReturns the flow value for a specific element at the specified argument.
-
Constructor Details
-
FlowProfile
public FlowProfile()
-
-
Method Details
-
setRate
Sets new flow rates for the elements starting from the specified argument. Previous rate is discarded, if any.- Parameters:
startingAtArgument- the argument at which to set the ratesflowRates- anAccumulatorcontaining the new rates for the elements
-
addRate
Adds flow rates for elements within the specified interval.- Parameters:
withinArgumentInterval- the argument interval within which to set the ratesflowRates- anAccumulatorcontaining the flow rates to add for each element.
-
addRate
Adds flow rates for elements starting from the specified argument and continuing indefinitely.- Parameters:
fromArgument- the argument at which to set the ratesflowRates- anAccumulatorcontaining the flow rates to add for each element.
-
addStepChange
Adds a step change based on the provided argument andAccumulatorof flow step changes.- Parameters:
argument- the argument at which to set the step changesflowStepChanges- anAccumulatorof flow step changes that contains pairs (flow element, change value).
-
addStepChange
Adds step changes for the specified argument interval andAccumulatorof flow step changes. Negative step changes are added at the end of the specified interval.- Parameters:
argumentInterval- theIntervalwhere the step change occurs. Must be finite and notnullflowStepChanges- anAccumulatorof flow changes that contains pairs (flow element, change value).
-
valueAt
Returns the flow values for all elements at the specified argument.- Parameters:
argument- the argument at which to evaluate the flow values- Returns:
- an
Accumulatorcontaining the flow values for all elements
-
valueAt
Returns the flow value for a specific element at the specified argument. If the element is not present in the profile, returns 0.0.- Parameters:
element- the element for which to calculate the flowargument- the argument at which to evaluate the flow value- Returns:
- the flow value for the specified element at the specified argument
-
sumValueAt
public double sumValueAt(double argument) Returns the sum of all flow values at the specified argument.- Parameters:
argument- the argument at which to evaluate the flow value- Returns:
- the summed flow value across all elements at the specified argument
-
rateAt
Returns the flow rate for all element at the specified argument.- Parameters:
argument- the argument at which to evaluate the flow rate- Returns:
- the calculated rate at the specified argument
-
rateAt
Returns the flow rate for a specific element at the specified argument. If the element is not present in the profile, returns 0.0.- Parameters:
element- element the flow element whose rate is to be calculatedargument- the argument at which to evaluate the flow rate- Returns:
- the calculated rate at the specified argument for the given element
-
sumRateAt
public double sumRateAt(double argument) Returns the sum of all flow rate at the specified argument.- Parameters:
argument- the argument at which to evaluate the flow rate- Returns:
- the calculated rate at the specified argument
-
integral
Calculates the integral of all flow profiles over a specified interval and returns the accumulated results.Analogous to
PiecewiseFunction.integral()- Parameters:
interval- the interval over which the integrals are calculated- Returns:
- an
Accumulatorcontaining the results of the integration for each flow element
-
flowElementProfile
Returns thePiecewiseFunctionassociated with a given flow element.- Parameters:
element- the flow element for which the flow profile is requested- Returns:
- the corresponding PiecewiseFunction for the given element
-
getSummaryFunction
Returns thePiecewiseFunctionassociated with the summary linear function of all the elements.- Returns:
- the summary linear function of all the elements
-
firstArgumentWithValueMoreEqualThan
public double firstArgumentWithValueMoreEqualThan(double moreEqualThanValue, double startingFromArgument) Finds and returns the first argument in the summary linear function where its value is greater than or equal to the specified threshold, starting the search from the given argument, inclusive.If the value of the function at the given argument is already greater than or equal to the specified threshold, returns this given argument.
- Parameters:
moreEqualThanValue- the threshold value to compare against. Must be finite and notDouble.NaNstartingFromArgument- the argument from which to start the search, inclusive. Must not beDouble.NaN- Returns:
- the first argument where the value is greater than or equal to the
specified threshold, or
Double.POSITIVE_INFINITYif no such argument is found
-
firstArgumentWithValueLessEqualThan
public double firstArgumentWithValueLessEqualThan(double lessEqualThanValue, double startingFromArgument) Finds and returns the first argument in the summary linear function where its value is less than or equal to the specified threshold, starting the search from the given argument, inclusive.If the value of the function at the given argument is already less than or equal to the specified threshold, returns this given argument.
- Parameters:
lessEqualThanValue- the threshold value to compare against. Must be finite and notDouble.NaNstartingFromArgument- the argument from which to start the search, inclusive. Must not beDouble.NaN- Returns:
- the first argument where the value is less than or equal to the
specified threshold, or
Double.POSITIVE_INFINITYif no such argument is found
-
summaryIntegral
Calculates the integral of the summary piecewise linear function over the specified argument interval.- Parameters:
withinArgumentInterval- the interval within which to calculate the integral. Must not benull.- Returns:
- the integral of the function over the specified interval
-
subProfile
Computes and returns a new instance ofFlowProfilewhich is a sub-function of this profile, i.e. profile which is:- equal to this profile inside the specified argument interval or interval set,
- zero elsewhere.
If the specified interval is
Interval.UNIVERSE, returns a copy of this profile.- Parameters:
withinArgumentInterval- argument where the values of this profile are preserved, can be empty but must not be zero-length- Returns:
- a new instance of
FlowProfilewhich is a sub-profile of this function
-
subProfile
public FlowProfile<T> subProfile(IntervalLike withinArgumentInterval, boolean shouldContinueLastValues) Computes and returns a new instance ofFlowProfilewhich is a sub-function of this profile, i.e. profile which is:- equal to this profile inside the specified argument interval or interval set,
- zero elsewhere.
If the specified interval is
Interval.UNIVERSE, returns a copy of this profile.- Parameters:
withinArgumentInterval- argument where the values of this profile are preserved, can be empty but must not be zero-lengthshouldContinueLastValues- if true, then the sub profile continues at the ends of the intervals as if the value was accumulating if this is the case in the original profile- Returns:
- a new instance of
FlowProfilewhich is a sub-profile of this function
-
plus
Adds the points of another profile to this profile. Creates and returns a new instance ofFlowProfilewith the combined points. The current instance remains unchanged.- Parameters:
other- the other profile whose points are to be added, must not benull- Returns:
- a new
FlowProfileinstance with the points of both profiles combined
-
multiply
Multiplies the values of this profile by the specified factor. Creates and returns a new instance ofFlowProfilewith the values multiplied by the factor. The current instance remains unchanged.- Parameters:
factor- the factor by which to multiply the values of the profile. Must be finite and notDouble.NaN- Returns:
- a new
FlowProfileinstance with the values multiplied by the factor
-
copy
Creates a new instance of thisFlowProfilethat is a copy of this profile, and returns this instance.- Returns:
- a copy of this profile
-