Synthia
Generic and flexible data structure generator
MarkovSimple.java
Go to the documentation of this file.
1 /*
2  Synthia, a data structure generator
3  Copyright (C) 2019-2021 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.sequences;
20 
26 import ca.uqac.lif.synthia.util.Tick;
27 
28 /**
29  * Generates a sequence of values according to a Markov chain.
30  * @ingroup Examples
31  */
32 public class MarkovSimple
33 {
34  public static void main(String[] args)
35  {
36  Tick tick = new Tick(0, new Playback<Integer>(new Integer[] {1, 2, 1}));
38  mc.add(0, new Constant<String>(""));
39  mc.add(1, new Constant<String>("START"));
40  mc.add(2, new StringPattern("{$0},A", tick));
41  mc.add(3, new StringPattern("{$0},B", tick));
42  mc.add(4, new StringPattern("{$0},C", tick));
43  mc.add(0, 1, 1).add(1, 2, 0.9).add(1, 4, 0.1);
44  mc.add(2, 3, 1).add(3, 2, 0.7).add(3, 4, 0.3).add(4, 4, 1);
45  for (int i = 0; i < 10; i++)
46  {
47  System.out.println(mc.pick());
48  }
49  }
50 
51 }
ca.uqac.lif.synthia.string.StringPattern
Generates a string according to a predefined pattern.
Definition: StringPattern.java:41
ca.uqac.lif.synthia.util
Miscellaneous pickers performing various functions.
Definition: ArrayPicker.java:19
ca.uqac.lif.synthia.sequence.MarkovChain.pick
T pick()
Picks an object.
Definition: MarkovChain.java:136
ca.uqac.lif.synthia.sequence.MarkovChain.add
MarkovChain< T > add(int source, int destination, Number probability)
Adds a new transition to the machine.
Definition: MarkovChain.java:97
ca.uqac.lif.synthia.sequence.Playback
Picker that returns values taken from a list.
Definition: Playback.java:61
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.string
Pickers producing and manipulating character strings.
Definition: AsString.java:19
ca.uqac.lif
ca.uqac.lif.synthia.util.Tick
Generates a sequence of monotonically increasing numerical values.
Definition: Tick.java:51
ca
ca.uqac.lif.synthia.sequence.MarkovChain
Generates a sequence of objects by a random walk in a Markov chain.
Definition: MarkovChain.java:47
examples.sequences.MarkovSimple
Generates a sequence of values according to a Markov chain.
Definition: MarkovSimple.java:32
ca.uqac.lif.synthia.random.RandomFloat
Picks a floating point number uniformly in an interval.
Definition: RandomFloat.java:30
examples.sequences.MarkovSimple.main
static void main(String[] args)
Definition: MarkovSimple.java:34
ca.uqac.lif.synthia.sequence
Pickers related to the generation of a sequence of values.
Definition: BehaviorTree.java:19