Depending on the Sorting Gate's distribution mode AND its Resource Connections' Labels, it will sort the Resources going through them.
Here are all types of Sorting Gates and their expected actions.
Deterministic Sorting Gates sort Resources according to the Labels on their output Resource Connections.
The order in which Resources are being sent towards their targets depends on the order in which these targets were added to the diagram.
Here's what happens in the example above:
The sorting algorithm will be applied on each of the Resources going in
The first Resources will be redistributed towards the upper Pool (the one we first added to the diagram) and they will continue to be directed towards it until the weight is reached. In this case, the first 2 Resources will go towards the first Pool. 1 part out of 4 (1+3) of 8 Resources (1/4 of 8)
The rest of the Resources will go towards the other Pool. 3 parts out of 4 of 8 Resources (3/4 of 8)
Here's an example:
Mathematically, the redistribution of the 10 Resources would amount to 10*1/4 (2.5) Resources towards the first Pool and 10*3/4 (7.5) Resources towards the second.
Pools cannot collect fractions of a Resource, therefore the algorithm will send 3 Resources towards the first Pool and 7 towards the second Pool during the first execution Time Step
On the next Time Step, it will send 2 Resources towards the 1st Pool and 8 towards the second
At the end of Time Step 2, the result will be 20 Resources perfectly distributed between the 2 Pools, according to their weights
The order in which the Resources are redistributed towards the targets is given by the probabilities on the Output Resource Connections' Labels.
Each Resource going through the Gate will be redistributed according to the probabilities on the output Resource Connections - this is obvious in the example on the right. The Resources will also be redistributed weighted - see the example on the right.
To better understand this, perform a Multiple Run on both examples above.
In the example above, the working rates are normalised, and become: (50/130*100)%; (60/130*100)% and (20/130*100)%.
Deterministic Gates with conditional outcomes take into account the sequence of Resources/Time Step.
Each Resource that goes through a Gate within a Time Step will be given an order number (1st Resource, 2nd Resource, etc) and will be redistributed accordingly.
Here's what happens: the algorithm redistributes each Resource depending on its order number - the first 3 Resources go through the <4 Connection, while everything else goes through the >=4 Connection.
Random Gates generate random values which will determine the redistribution of incoming Resources.
During execution, the Random Gate displays the random number it generated.
For each Resource passing through, the Gate the algorithm will throw a die with a number of faces equal to the SUM of weights on the Output Connections. This will determine towards which Connection the Resource will be redistributed also taking into account the weights determined by the Connections' Labels.
Here's what happens in the example above: For each Resource, the algorithm uses a die with 4 faces (1+3). If the die throws 1, the Gate redistributes the Resource towards the 1st Resource Connection. If the die throws either one of 2, 3 or 4, the Resource will be redistribute towards the second Resource Connection.
Use the 2 pie charts below to visualise the algorithm. The pie chart in the middle, represents the 4-faced die and the equal chances for it to throw either one of the numbers on it: 25% chance for each face. The outer pie chart's sections represent the weights according to which the Resources will be redistributed towards the Output Connections, considering the result of the die throw.
For each Resource passing through the Gate, the algorithm throws a 100-faced die. This will determine towards which Connection the Resource will be redistributed also taking into account the weighted rates on the Connections' Labels.
Here's what happens in the example above: For each Resource, the algorithm throws the 100-faced die, any result that falls between 1 and 40 will go through the first Resource Connection, all else will go through the second connection.
Same as with the previous example, consider these 2 pie charts to visualise the algorithm.
The 100-faced die is the pie chart in the middle, and each of its sections represents the probability of the die to throw 1 of its faces (1% for each). All faces between 1-40 will be redistributed towards the 40% weighted rate Pool, whilst all others will go through to the 60% weighted rate Pool.
For each resource going through the Gate, the algorithm throws a die with a number of faces equal to the die set at diagram level (
Diagram Functional Panel > Dice) and then redistributes the Resources according to which condition the number on the die meets.
In the example above, the die is a D10. The throws that result in a number that's below 4 will go through the <4 branch, all else through the >=4 one.