![]() |
Synthia
Generic and flexible data structure generator
|
Illustration of mutation operations on lists and list elements.
The program generates lists and then applies various Mutators on them. The wiring of pickers in this program is illustrated by the following diagram:
The diagram culminates into a Mutate picker (box A) that receives as one of its inputs an arbitrary list of numbers (not shown). The picker that provides a mutator for each list is a Choice (box B), which may pick with equal probability one of three possible mutators, represented by boxes 1-3. The first is an instance of MutateElement, whose mutator picker is another Choice (box a), selecting either an Offset (box b) or a Replace feeding the constant value 0 (box c). The other two list mutators are instances of Swap (box 2) and DeleteElement (box 3). All these pickers use a distinct Random\-Float as their source of randomness for making their respective choices. The end result is that, for every list given to the picker of box A, three equally probable outcomes are possible:
The program takes a single list and repeatedly passes it to Mutate. It produces the following output:
[56.0, 55.0, 57.0] [55.0, 56.78632, 57.0] [56.0, 57.0] [56.0, 57.0] [55.0, 57.0] [55.135525, 56.0, 57.0] [55.93449, 56.0, 57.0] [56.0, 55.0, 57.0] [55.0, 56.0, 57.367645] [0, 56.0, 57.0]
One can see how the original list [55, 56, 57] is modified in different ways:
Note that although the diagram looks complex, the part of the program that builds the wiring of pickers only contains 13 lines.
Definition at line 94 of file MutatedLists.java.
Static Public Member Functions | |
| static void | main (String[] args) |
|
static |
Definition at line 96 of file MutatedLists.java.