Constraint solver

In reply to Mittal Maru:

Because randomize() is a function, it must execute with no delay. foreach loops get unrolled so that each iteration becomes a separate constraint.

The simplest way of explaining how the constraints work is to think of table with columns for each random variable, and a row for each possible combination of values that satisfy the constraints (where all constraint expressions evaluate true). After that, one row gets randomly picked, so all random variable values get selected at once.

Actually implementing it that way would be very inefficient. The LRM does not specify how to implement constrain solvers as long as the behavior essentially matches the simple description I gave.

There are cases where some random variables must get values before others, and the random size of an array is one one them.