1 | package de.ugoe.cs.eventbench.models;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.security.InvalidParameterException;
|
---|
5 | import java.util.Collection;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.eventbench.data.Event;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * <p>
|
---|
12 | * This interface defines the functionalities provided by stochastic processes.
|
---|
13 | * </p>
|
---|
14 | *
|
---|
15 | * @author Steffen Herbold
|
---|
16 | * @version 1.0
|
---|
17 | */
|
---|
18 | public interface IStochasticProcess extends Serializable {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * <p>
|
---|
22 | * Returns the probability, that the next event is {@code symbol} given the
|
---|
23 | * last events are {@code context}. The last element of {@code context} is
|
---|
24 | * the most recent in the history, the first element is the oldest.
|
---|
25 | * </p>
|
---|
26 | *
|
---|
27 | * @param context
|
---|
28 | * recently observed symbols
|
---|
29 | * @param symbol
|
---|
30 | * event for which the probability is calculated
|
---|
31 | * @return probabilty the {@code symbol} is the next event, given the last
|
---|
32 | * events {@code context}
|
---|
33 | * @throws InvalidParameterException
|
---|
34 | * thrown if context or symbol is null
|
---|
35 | */
|
---|
36 | double getProbability(List<? extends Event<?>> context, Event<?> symbol);
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * <p>
|
---|
40 | * Returns the probabilitiy that a given sequence is generated by the
|
---|
41 | * stochastic process.
|
---|
42 | * </p>
|
---|
43 | *
|
---|
44 | * @param sequence
|
---|
45 | * sequences of which the probability is calculated
|
---|
46 | * @return probability of the sequences; 1.0 if sequence is empty or null
|
---|
47 | * @throws InvalidParameterException
|
---|
48 | * thrown if sequence is null
|
---|
49 | */
|
---|
50 | double getProbability(List<? extends Event<?>> sequence);
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * <p>
|
---|
54 | * Generates a random sequence of events. The sequence starts with
|
---|
55 | * {@link Event#STARTEVENT} and finishes with {@link Event#ENDEVENT}.
|
---|
56 | * </p>
|
---|
57 | *
|
---|
58 | * @return randomly generated sequence
|
---|
59 | */
|
---|
60 | public List<? extends Event<?>> randomSequence();
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * <p>
|
---|
64 | * Generates a random sequence of events. The sequence starts with
|
---|
65 | * {@link Event#STARTEVENT} and finishes with
|
---|
66 | * <ul>
|
---|
67 | * <li>{@link Event#ENDEVENT} if validEnd==true.</li>
|
---|
68 | * <li>b) if a generated sequences reaches {@link Event#ENDEVENT} before
|
---|
69 | * maxLength, the sequence finishes and is shorter than maxLenght.
|
---|
70 | * Otherwise, the sequence finishes as soon as maxLength is reached and the
|
---|
71 | * final event of the sequence must not be {@link Event#ENDEVENT}.</li>
|
---|
72 | * </ul>
|
---|
73 | * </p>
|
---|
74 | *
|
---|
75 | * @param maxLength
|
---|
76 | * maximum length of the generated sequence
|
---|
77 | * @param validEnd
|
---|
78 | * if true, only sequences that finish with
|
---|
79 | * {@link Event#ENDEVENT} are generated
|
---|
80 | * @return randomly generated sequence
|
---|
81 | *
|
---|
82 | */
|
---|
83 | public List<? extends Event<?>> randomSequence(int maxLength,
|
---|
84 | boolean validEnd);
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * <p>
|
---|
88 | * Generates all sequences of a given length are possible, i.e., have a
|
---|
89 | * positive probability.<br>
|
---|
90 | * All states are used as possible starting states.
|
---|
91 | * </p>
|
---|
92 | *
|
---|
93 | * @param length
|
---|
94 | * length of the generated sequences
|
---|
95 | * @return generated sequences
|
---|
96 | * @see #generateSequences(int, boolean)
|
---|
97 | * @throws InvalidParameterException
|
---|
98 | * thrown if length is less than or equal to 0
|
---|
99 | */
|
---|
100 | public Collection<List<? extends Event<?>>> generateSequences(int length);
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * <p>
|
---|
104 | * Generates all sequences of given length that can are possible, i.e., have
|
---|
105 | * positive probability.<br>
|
---|
106 | * If {@code fromStart==true}, all generated sequences start in
|
---|
107 | * {@link Event#STARTEVENT}. Otherwise this method is the same as
|
---|
108 | * {@link #generateSequences(int)}.
|
---|
109 | * </p>
|
---|
110 | *
|
---|
111 | * @param length
|
---|
112 | * length of the generated sequences
|
---|
113 | * @param fromStart
|
---|
114 | * if true, all generated sequences start with
|
---|
115 | * {@link Event#STARTEVENT}
|
---|
116 | * @return generated sequences
|
---|
117 | * @throws InvalidParameterException
|
---|
118 | * thrown if length is less than or equal to 0
|
---|
119 | */
|
---|
120 | public Collection<List<? extends Event<?>>> generateSequences(int length,
|
---|
121 | boolean fromStart);
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * <p>
|
---|
125 | * Generates all sequences starting with {@link Event#STARTEVENT} and
|
---|
126 | * finishing with {@link Event#ENDEVENT} of a given length. It is possible
|
---|
127 | * that no such sequence exists with the defined length and the returned set
|
---|
128 | * is empty. If {@code length} is less than 2 the returned set is always
|
---|
129 | * empty.
|
---|
130 | * </p>
|
---|
131 | *
|
---|
132 | * @param length
|
---|
133 | * @return generated sequences
|
---|
134 | * @throws InvalidParameterException
|
---|
135 | * thrown if length is less than or equal to 0
|
---|
136 | */
|
---|
137 | public Collection<List<? extends Event<?>>> generateValidSequences(
|
---|
138 | int length);
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * <p>
|
---|
142 | * Returns the number of states known by the stochastic process, i.e., the
|
---|
143 | * size of its alphabet.
|
---|
144 | * </p>
|
---|
145 | *
|
---|
146 | * @return number of states
|
---|
147 | */
|
---|
148 | public int getNumSymbols();
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * <p>
|
---|
152 | * Returns a string representation of all known states.
|
---|
153 | * </p>
|
---|
154 | *
|
---|
155 | * @return string representation for all known states
|
---|
156 | */
|
---|
157 | public String[] getSymbolStrings();
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * <p>
|
---|
161 | * Returns the number of states the process would have if it would be
|
---|
162 | * flattened through state-splitting to a first-order Markov model.
|
---|
163 | * </p>
|
---|
164 | * <p>
|
---|
165 | * If it is not possible to flatten the model, -1 is returned.
|
---|
166 | * </p>
|
---|
167 | *
|
---|
168 | * @return number of states an equivalent FOM would have; -1 if not
|
---|
169 | * available
|
---|
170 | */
|
---|
171 | public int getNumFOMStates();
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * <p>
|
---|
175 | * Returns the number of transitions the process would have if it would be
|
---|
176 | * flattened through state-splitting to a first-order Markov model.
|
---|
177 | * </p>
|
---|
178 | *
|
---|
179 | * @return number of transitions an equivalent FOM would have; -1 if not
|
---|
180 | * available
|
---|
181 | */
|
---|
182 | public int getNumTransitions();
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * <p>
|
---|
186 | * Returns all states known by the stochastic process, i.e., its
|
---|
187 | * {@link Event}s.
|
---|
188 | * </p>
|
---|
189 | *
|
---|
190 | * @return events known by the process
|
---|
191 | */
|
---|
192 | public Collection<? extends Event<?>> getEvents();
|
---|
193 |
|
---|
194 | } |
---|