Tutorial

5.1 A question, not an if

The obvious way to write this is an if in a junction. It works, and it hides three things: which orders were stopped and why, which rule stopped them, and what a different rule would have done. Trax can do better when the branch is declared on the chain as a question: the chain names every track it can take, a decider answers the question on each run, and Trax records the answer.

There are three kinds of question. This one has two answers, so it is a yes or no question, routed by a Gate.

QuestionRouted byAnswer
Which of these options?SwitchOne member of an enum, with a confidence
Where on this scale?ScaleA position on an ordered enum
How likely is yes?GateA probability from 0 to 1

The decider can be a rule table, a model or, in a test, a script. The train does not know which.


Next: 5.2 The question and what it is asked about