Class Merge<T>

java.lang.Object
com.amalgamasimulation.discreterate.FlowElement<T>
com.amalgamasimulation.discreterate.Merge<T>
Type Parameters:
T - type (class or interface) whose instances represent types of material

public final class Merge<T> extends FlowElement<T>
Merge is a flow element that receives material from several inputs and combines them into a single output.

Merge has no storage capacity.

Merge can have many inflow connections and at most one outflow connection. The total current rate of inflow connections is equal to the rate of the outflow connection.

The behavior of a Merge with its downstream element's inflow rate less than sum of actual input flow rates of inflows being merged is defined by its FlowRateDistributionPolicy:

  • In a PRIORITY Merge, the material is taken from the top priority inputs first until the downstream element's inflow rate limit is reached. For instance, if the downstream flow element can accept material at the max rate of 12 and the Merge has five inflow connections, with their respective inflow rates and priorities (see setInflowPriority(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 Merge, material is taken from all inflow connections. For each connection, a 'rate fraction' parameter is set (see setInflowRateFraction(FlowConnection, double)) indicating the fraction of that connection's rate in the overall inflow rate of the Merge. Rate limits of each incoming connection are respected. For instance, if the downstream flow element can accept material at the max rate of 5 and the Merge has four inflow connections, with their respective max inflow rates being 1 to 4 and 'rate fractions' being 0.25, then the actual inflow rate via each of the inflow connections will be equal to 1, for a total inflow 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 inflow 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 downstream element).
Author:
Alexander Morozov