Synthia
Generic and flexible data structure generator
PickTrees1.java
Go to the documentation of this file.
1 /*
2  Synthia, a data structure generator
3  Copyright (C) 2019-2020 Laboratoire d'informatique formelle
4  Université du Québec à Chicoutimi, Canada
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 package examples.graphs;
20 
26 import ca.uqac.lif.synthia.tree.Node;
28 import ca.uqac.lif.synthia.util.Choice;
30 
31 /**
32  *
33  * @author Sylvain Hallé
34  * @ingroup Examples
35  */
36 public class PickTrees1
37 {
38 
39  public static void main(String[] args)
40  {
41  int seed = 1234591;
42  RandomInteger height = new RandomInteger(2, 6);
43  height.setSeed(seed);
44  System.out.println(height.pick());
45  RandomFloat color_float = new RandomFloat();
46  color_float.setSeed(seed);
47  Choice<String> color = new Choice<String>(color_float);
48  color.add("blue", 0.33).add("red", 0.33).add("yellow", 0.34);
49  ColoredNodePicker node = new ColoredNodePicker(color);
50  //RandomInteger degree = new RandomInteger(0, 4);
51  //Constant<Integer> degree = new Constant<Integer>(2);
52  Playback<Integer> degree = new Playback<Integer>(0, new Integer[] {2,0});
53  //degree.setSeed(seed);
54  //RandomFloat child = new RandomFloat(0.4, 0.6);
55  Constant<Float> child = new Constant<Float>(0.9f);
56  //child.setSeed(seed);
57  TreePicker<String> tp = new TreePicker<String>(node, height, degree, child);
58  Node<String> root = tp.pick();
59  ColoredTreeRenderer.treeToDot(System.out, root);
60  }
61 
62 }
ca.uqac.lif.synthia.util
Miscellaneous pickers performing various functions.
Definition: ArrayPicker.java:19
ca.uqac.lif.synthia.tree.TreePicker.pick
Node< T > pick()
Picks an object.
Definition: TreePicker.java:61
ca.uqac.lif.synthia.tree.ColoredTreeRenderer
Definition: ColoredTreeRenderer.java:5
ca.uqac.lif.synthia.sequence.Playback
Picker that returns values taken from a list.
Definition: Playback.java:61
examples.graphs.PickTrees1.main
static void main(String[] args)
Definition: PickTrees1.java:39
ca.uqac
ca.uqac.lif.synthia.random
Pickers that produce pseudo-random objects such as numbers.
Definition: AffineTransform.java:19
ca.uqac.lif.synthia
Definition: Bounded.java:19
ca.uqac.lif.synthia.util.Constant
Picker that returns the same object every time.
Definition: Constant.java:37
ca.uqac.lif.synthia.tree
Pickers for the generation of trees made of nodes with labels.
Definition: ColoredNodePicker.java:19
examples.graphs.PickTrees1
Definition: PickTrees1.java:36
ca.uqac.lif.synthia.random.RandomFloat.setSeed
RandomFloat setSeed(int seed)
Definition: RandomFloat.java:85
ca.uqac.lif
ca.uqac.lif.synthia.util.Choice.add
Choice< T > add(ProbabilityChoice< T > pc)
Adds an object-probability association.
Definition: Choice.java:72
ca.uqac.lif.synthia.random.RandomInteger.setSeed
RandomInteger setSeed(int seed)
Definition: RandomInteger.java:102
ca.uqac.lif.synthia.random.RandomInteger
Picks an integer uniformly in an interval.
Definition: RandomInteger.java:31
ca.uqac.lif.synthia.random.RandomInteger.pick
Integer pick()
Picks a random integer.
Definition: RandomInteger.java:118
ca.uqac.lif.synthia.tree.ColoredNodePicker
Definition: ColoredNodePicker.java:28
ca
ca.uqac.lif.synthia.tree.ColoredTreeRenderer.treeToDot
static void treeToDot(PrintStream ps, Node< String > root)
Definition: ColoredTreeRenderer.java:12
ca.uqac.lif.synthia.tree.Node
Simple implementation of a labeled nodel.
Definition: Node.java:31
ca.uqac.lif.synthia.random.RandomFloat
Picks a floating point number uniformly in an interval.
Definition: RandomFloat.java:30
ca.uqac.lif.synthia.util.Choice
Picks an element from a collection, where the probability of picking each element can be user-defined...
Definition: Choice.java:44
ca.uqac.lif.synthia.sequence
Pickers related to the generation of a sequence of values.
Definition: BehaviorTree.java:19
ca.uqac.lif.synthia.tree.TreePicker
Generates a tree of labeled nodes.
Definition: TreePicker.java:33