### BRANCH

The BRANCH module controls the flow of an entity through a set of branches. These branches are tested in sequence until the number of entities specified in 'Max number of branches' are sent from the module to the destination modules.

Prompt | Valid Entry | Default
Max number of branches | Expression truncated to integer | Infinite
Random number stream | Random number stream to use with the WITH rules [expression] | 10
Branch type | If, With, Always, Else | -
Condition | Branch condition [condition or expression] (only available for branch type 'IF' | -
Probability | Probability of selecting branch (0<= probability <= 1). For use only with 'WITH' | -
Label | Label of module to which a copy of entity is to be sent | -
Primary entity Indicator | Indicator that primary (incoming) entity can select this branch | Yes

There are four branch types which may be used singulary or in combination to control the flow of entites.

The 'IF, CONDITON,LABEL' type tests the condition and transfers the entity to label if the condition is passed. The condition can be written in either FORTRAN or C syntax as illustrated in the following table :

less than | .LT. | <
less than or equal | .LE. | <=
equal | .EQ. | ==
greater than or equal | .GE. | >=
greater than | .GT. | >
not equal to | .NE. | < >
or | .OR. | OR
and | .AND. | and

In ARENA it is not necessary to specify a label because the module linking tool can be used to connect to the transfer module.

The 'WITH' , prob, label allows for probabalistic branching. Regardless of the number of WITH clauses in the module only one random number value will be used.

The 'ALWAYS' is a deterministic clause indicating a branch which will always be taken. NOTE The maximum number of branches that can be taken is given by the first prompt and if an ALWAYS clause is encountered after this number of entity copies have been generated a run time error will occur.

The 'ELSE' clause is also deterministic and sends a copy of the entity to the relevant module only if the maximum number of entites has not been reached. If it has been reached the else clause is ignored. Examples

Prompt | Value
Max Branches | 1
BranchType | WITH
probability | 0.95
label | packing
Branch Type | ELSE
label | Rework

When an entity arrives at this module it will be transferred with a 95% probability to 'packing' and with a 5% probability to 'rework'

Prompt | Value
Max Branches | 2
Branch Type | IF
Condition | Jobtype.EQ.1
label | B1
Branch Type | IF
Condition | Duedate<=480
label | B2
Branch Type | ELSE
label | B3

When an entity arrives at this branch module a maximum of two copies of the entity are released. If the arriving entity has a job type of 1 and a due date of less than or equal 480 then one copy of the entity is sent to B1 and a second to B2. If however the job tyoe was 2 and the due date was less than or equal to 480 a copy of the entity would be sent to B2 and to B3. If the arriving entity fails both if clauses then a single copy is routed to B3.

Prompt | Value
Max Branches | 2
Branch Type | ALWAYS
label | B1
Branch Type | ALWAYS
label | B2

A simple way to duplicate an entity and send a copy along two branches.