Class Split<T>
- Type Parameters:
T- type (class or interface) whose instances represent types of material
Split has no storage capacity.
Split can have at most one incoming flow connection and many outflow connections.
The proportions of materials in the outflow mixture are not changed.
The behavior of a Split with its upstream element's outflow rate less than sum of max possible output flow rates
of defined by its FlowRateDistributionPolicy:
-
In a PRIORITY Split, the material is sent to the top priority outputs first
until the upstream element's outflow rate limit is reached.
For instance, if the upstream flow element can deliver material at the max rate of 12 and the Split has five outflow connections,
with their respective max possible rates and priorities (see
setOutflowPriority(FlowConnection, double)) being from 1 to 5 (1 is the highest priority), then connections 1-4 will be used at their full rates (for a total rate of 10), and the 5th connection will only be used at its partial rate of 2 (12 - (1+2+3+4) = 2). -
In a PROPORTIONAL Split, material is sent to all outflow connections.
For each connection, a 'rate fraction' parameter is set (see
setOutflowRateFraction(FlowConnection, double)) indicating the fraction of that connection's rate in the overall outflow rate of the Split. Rate limits of each incoming connection are respected. For instance, if the upstream flow element can deliver material at the max rate of 5 and the Split has four outflow connections, with their respective max rates being 1 to 4 and 'rate fractions' being 0.25, then the actual outflow rate via each of the outflow connections will be equal to 1, for a total outflow rate of 4. On the other hand, if rate fractions are set to be 0.1, 0.2, 0.3, and 0.4 - then the outflow connections will have respective actual rates of 0.5, 1.0, 1.5, and 2.0, for a total of 5 (this is the rate limit of the upstream element).
-
Constructor Summary
ConstructorsConstructorDescriptionSplit(FlowEnvironment<T> flowEnvironment, FlowRateDistributionPolicy policy) Creates a new Split instance.Split(FlowEnvironment<T> flowEnvironment, String name, FlowRateDistributionPolicy policy) Creates a new instance of the split. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the current sum of all amounts of all materials contained inside this flow element.doublegetContentsAmount(T material) Returns the current amount of the specified material contained inside this flow element.Returns the current stock contained inside this flow element as anAccumulatorinstance.Returns theFlowRateDistributionPolicyof this Split.doubleReturns the current flow rate of all materials at the input of thisflow element.Returns anAccumulatorinstance that describes the flow rate at the input of this flow element.Returns anAccumulatorinstance that contains rate proportions of materials in the material inflow of this flow element.doublegetOutflowPriority(FlowConnection<T> outflowConnection) Returns the priority of the specified outputoutflowConnection.doubleReturns the current flow rate at the output of this flow element.Returns anAccumulatorinstance that describes the flow rate at the output of this flow element.getOutflowRateDescriptor(FlowConnection<T> outflowConnection) Returns an Accumulator instance that describes the flow rate of material at the specified outflow connection.doublegetOutflowRateFraction(FlowConnection<T> outflowConnection) Returns the ratio of currentoutflowConnectionflow rate to the overall outflow rate of this Split.getOutflowRateProportions(FlowConnection<T> outflowConnection) Returns anAccumulatorinstance that contains flow rate proportions of materials exported through theoutflowConnectionoutflow connection.doubleReturns the total amount of all materials that have passed through this Split since the beginning of simulation.doubleReturns the total amount of all materials that have entered this flow element.doublegetTotalInflowAmount(T material) Returns the total amount of the specifiedmaterialthat has entered this flow element.Returns anAccumulatorinstance that contains the total quantity of each material that has entered this flow element.doubleReturns the total quantity of materials that have left this flow element.doublegetTotalOutflowAmount(T material) Returns the total quantity of the specifiedmaterialthat has left this flow element.Returns anAccumulatorinstance that holds the total amounts of each material that has left this flow element.voidsetOutflowFractionSupplier(Function<FlowConnection<T>, Double> outflowFractionSupplier) Sets the supplier of the fraction ofoutflowConnection's actual flow rate in the overall outflow rate of this Split.voidsetOutflowPriority(FlowConnection<T> outflowConnection, double priority) Sets the priority of the outputoutflowConnection.voidsetOutflowRateFraction(FlowConnection<T> outflowConnection, double rateFraction) Sets the fraction ofoutflowConnection's actual flow rate in the overall outflow rate of this Split.voidsetOutflowRateProportionsSupplier(Function<FlowConnection<T>, Accumulator<T>> outflowRateProportionsSupplier) Sets the supplier of the rate proportions ofoutflowConnection's actual flow rate in the overall outflow rate of this Split.Methods inherited from class com.amalgamasimulation.discreterate.FlowElement
addInflowElementConnectedHandler, addInflowElementDisconnectedHandler, addOutflowElementConnectedHandler, addOutflowElementDisconnectedHandler, connectToElement, disconnectFrom, getFlowEnvironment, getInflowConnections, getName, getOutflowConnections, inflowConnectionExists, isConnectedWith, outflowConnectionExists, removeInflowElementConnectedHandler, removeInflowElementDisconnectedHandler, removeOutflowElementConnectedHandler, removeOutflowElementDisconnectedHandler, toString
-
Constructor Details
-
Split
Creates a new Split instance.- Parameters:
flowEnvironment-FlowEnvironmentwhich this Split instance belongs topolicy- flow rate distribution policy of the new Split, can beFlowRateDistributionPolicy.PROPORTIONALorFlowRateDistributionPolicy.PRIORITY- See Also:
-
Split
Creates a new instance of the split.- Parameters:
flowEnvironment-FlowEnvironmentwhich this Split instance belongs toname- name of the new Splitpolicy- flow rate distribution policy of the new Split, can beFlowRateDistributionPolicy.PROPORTIONALorFlowRateDistributionPolicy.PRIORITY
-
-
Method Details
-
setOutflowFractionSupplier
Sets the supplier of the fraction ofoutflowConnection's actual flow rate in the overall outflow rate of this Split. Can only be called for a Split withFlowRateDistributionPolicy.PROPORTIONALpolicy.- See Also:
-
setOutflowRateProportionsSupplier
public void setOutflowRateProportionsSupplier(Function<FlowConnection<T>, Accumulator<T>> outflowRateProportionsSupplier) Sets the supplier of the rate proportions ofoutflowConnection's actual flow rate in the overall outflow rate of this Split. -
getPassedAmount
public double getPassedAmount()Returns the total amount of all materials that have passed through this Split since the beginning of simulation.- Returns:
- total amount of passed materials
-
setOutflowPriority
Sets the priority of the outputoutflowConnection. Can only be called for a Split withFlowRateDistributionPolicy.PRIORITYpolicy.- Parameters:
outflowConnection- the output flow connection for which the priority is being setpriority- new priority of the outputoutflowConnection, must be non-negative- See Also:
-
getOutflowPriority
Returns the priority of the specified outputoutflowConnection. The lower the returned value, the higher the priority.- Parameters:
outflowConnection- output flow connection- Returns:
- priority of the output
outflowConnection
-
setOutflowRateFraction
Sets the fraction ofoutflowConnection's actual flow rate in the overall outflow rate of this Split. Can only be called for a Split withFlowRateDistributionPolicy.PROPORTIONALpolicy.- Parameters:
outflowConnection- output flow connectionrateFraction- a number in the closed interval [0..1] representing the ratio ofoutflowConnectionflow rate to the overall outflow rate of this Split- Throws:
IllegalStateException- if called for a Split with flow distribution policy other thanFlowRateDistributionPolicy.PROPORTIONALIllegalArgumentException- if theoutflowConnectionis not related to this SplitIllegalArgumentException- ifrateFractionis not in the closed interval [0..1]- See Also:
-
getOutflowRateFraction
Returns the ratio of currentoutflowConnectionflow rate to the overall outflow rate of this Split.The returned value belongs to a closed interval [0..1].
- Parameters:
outflowConnection- output flow connection- Returns:
- fraction of the
outflowConnectionflow rate in the overall outflow rate of the Split - Throws:
IllegalStateException- if called for a Split with flow distribution policy other thanFlowRateDistributionPolicy.PROPORTIONALIllegalStateException- if the outflow rate fraction has not been configured for this outflowConnection and this SplitIllegalArgumentException- if theoutflowConnectionis not related to this Split- See Also:
-
getFlowRateDistributionPolicy
Returns theFlowRateDistributionPolicyof this Split. The policy is applied to the outflow rate.- Returns:
FlowRateDistributionPolicyof this Split
-
getContentsAmount
public double getContentsAmount()Returns the current sum of all amounts of all materials contained inside this flow element. Always zero for any Split because Splits do not contain any material.- Specified by:
getContentsAmountin classFlowElement<T>- Returns:
- current total amount of all materials inside this flow element
- See Also:
-
getContentsAmount
Returns the current amount of the specified material contained inside this flow element. Always zero for any Split because Splits do not contain any material.- Specified by:
getContentsAmountin classFlowElement<T>- Parameters:
material- material- Returns:
- current amount of the specified material contained inside this flow element
- See Also:
-
getContentsDescriptor
Returns the current stock contained inside this flow element as anAccumulatorinstance. Always returns an emptyAccumulatorfor any Split because Splits do not contain any material.- Specified by:
getContentsDescriptorin classFlowElement<T>- Returns:
- empty
Accumulator - See Also:
-
getInflowRate
public double getInflowRate()Description copied from class:FlowElementReturns the current flow rate of all materials at the input of thisflow element.- Specified by:
getInflowRatein classFlowElement<T>- Returns:
- current flow rate of all materials at this
flow element's input - See Also:
-
getInflowRateDescriptor
Description copied from class:FlowElementReturns anAccumulatorinstance that describes the flow rate at the input of this flow element.The returned
Accumulatorinstance contains the respective rates of all materials currently entering the flow element. The sum of values in the Accumulator is equal to 1.- Specified by:
getInflowRateDescriptorin classFlowElement<T>- Returns:
- descriptor of the current inflow rate
- See Also:
-
getOutflowRate
public double getOutflowRate()Description copied from class:FlowElementReturns the current flow rate at the output of this flow element.- Specified by:
getOutflowRatein classFlowElement<T>- Returns:
- current flow rate at the output of this flow element
- See Also:
-
getOutflowRateDescriptor
Description copied from class:FlowElementReturns anAccumulatorinstance that describes the flow rate at the output of this flow element.The returned
Accumulatorinstance contains the respective rates of all materials currently leaving the flow element. The sum of values in the Accumulator is equal to 1.- Specified by:
getOutflowRateDescriptorin classFlowElement<T>- Returns:
- descriptor of the current outflow rate
- See Also:
-
getOutflowRateDescriptor
Returns an Accumulator instance that describes the flow rate of material at the specified outflow connection.The returned
Accumulatorinstance contains the respective rates of all materials currently leaving the Split through the specified connection.- Parameters:
outflowConnection- output flow connection- Returns:
- current material flow rate at specified outflow connection
- Throws:
IllegalArgumentException- if theoutflowConnectionis not related to this Split
-
getOutflowRateProportions
Description copied from class:FlowElementReturns anAccumulatorinstance that contains flow rate proportions of materials exported through theoutflowConnectionoutflow connection.Each element of the returned
Accumulatorcorresponds to a material in the current material flow ofoutflowConnection. The value of each element in the Accumulator is the ratio of the rate of that material's partial flow to the overall flow rate ofoutflowConnection. The sum of values in the Accumulator is equal to 1.- Specified by:
getOutflowRateProportionsin classFlowElement<T>- Parameters:
outflowConnection- an outflow connection- Returns:
- material proportions in the outflow connection
-
getInflowRateProportions
Returns anAccumulatorinstance that contains rate proportions of materials in the material inflow of this flow element.Each element of the returned
Accumulatorcorresponds to a material in the current material inflow. The value of each element in the Accumulator is the ratio of the rate of that material's partial flow to the overall inflow rate of the flow element. The sum of amounts in the Accumulator is equal to 1.- Returns:
Accumulatorthat contains the current incoming flow rate proportions.- See Also:
-
getTotalInflowAmount
public double getTotalInflowAmount()Description copied from class:FlowElementReturns the total amount of all materials that have entered this flow element.- Specified by:
getTotalInflowAmountin classFlowElement<T>- Returns:
- total amount of all arrived materials
-
getTotalInflowAmount
Description copied from class:FlowElementReturns the total amount of the specifiedmaterialthat has entered this flow element.- Specified by:
getTotalInflowAmountin classFlowElement<T>- Parameters:
material- material- Returns:
- total amount of the specified
materialthat has arrived to this flow element - See Also:
-
getTotalInflowDescriptor
Description copied from class:FlowElementReturns anAccumulatorinstance that contains the total quantity of each material that has entered this flow element.The values of each element in the returned
Accumulatormatch the quantities of the respective materials that have entered the flow element. The sum of values in the Accumulator is equal to the value returned by theFlowElement.getTotalInflowAmount()method.- Specified by:
getTotalInflowDescriptorin classFlowElement<T>- Returns:
Accumulatorcontaining total amounts of materials that have entered this flow element- See Also:
-
getTotalOutflowAmount
public double getTotalOutflowAmount()Description copied from class:FlowElementReturns the total quantity of materials that have left this flow element.- Specified by:
getTotalOutflowAmountin classFlowElement<T>- Returns:
- total quantity of exported materials
- See Also:
-
getTotalOutflowAmount
Description copied from class:FlowElementReturns the total quantity of the specifiedmaterialthat has left this flow element.- Specified by:
getTotalOutflowAmountin classFlowElement<T>- Parameters:
material- material- Returns:
- total quantity of the specified material that has left this flow element
- See Also:
-
getTotalOutflowDescriptor
Description copied from class:FlowElementReturns anAccumulatorinstance that holds the total amounts of each material that has left this flow element.The values of each element in the returned
Accumulatormatch the quantities of the respective materials that have left the flow element. The sum of values in the Accumulator is equal to the value returned by theFlowElement.getTotalOutflowAmount()method.- Specified by:
getTotalOutflowDescriptorin classFlowElement<T>- Returns:
Accumulatorcontaining total amounts of materials that have left this flow element- See Also:
-