aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java')
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java
new file mode 100644
index 00000000..f163f1a5
--- /dev/null
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java
@@ -0,0 +1,82 @@
1/*******************************************************************************
2 * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro
3 * This program and the accompanying materials are made available under the
4 * terms of the Eclipse Public License v. 2.0 which is available at
5 * http://www.eclipse.org/legal/epl-v20.html.
6 *
7 * SPDX-License-Identifier: EPL-2.0
8 *******************************************************************************/
9package org.eclipse.viatra.dse.statecode;
10
11import org.eclipse.emf.common.notify.Notifier;
12import org.eclipse.viatra.query.runtime.api.IPatternMatch;
13
14/**
15 * <p>
16 * To be able to efficiently explore a design space, a state that has been explored before through an other trajectory
17 * needs to be recognized and ignored accordingly.
18 * </p>
19 *
20 * <p>
21 * This is done by generating a pseudo-unique value (object) that is only depended on the relevant parts of the model's
22 * internal state, that is, the values of two states can only be equal if the states themselves can be considered equal.
23 * </p>
24 *
25 * <p>
26 * The processing engine however assumes, that any two states that share this pseudo-unique value has the same
27 * characteristics, meaning they have the same amount and type of outgoing transitions available, and firing the
28 * appropriate transitions from both states also result in states that share their pseudo-unique identifier. If this
29 * condition is not satisfied, the exploration process's result will be non-deterministic, and in consequence, solutions
30 * can be lost.
31 * </p>
32 *
33 * <p>
34 * In addition to providing pseudo-unique identifiers to model states, the state coder must provide pseud-unique
35 * identifiers to the outgoing transitions as well, but they only need to be unique on the scope of the particular
36 * state, not globally. Global addressing thus can be achieved by considering the pseudo-unique identifier of the state
37 * and the pseudo-unique identifier of the transition together if needed.
38 * </p>
39 *
40 * <p>
41 * Both identifiers can be arbitrary objects, and equality is checked by calling {@link Object#equals(Object)} on the
42 * two identifiers.
43 * </p>
44 *
45 * <p>
46 * For any particular implementation an {@link IStateCoderFactory} implementation must also be supplied that handles the
47 * creation of {@link IStateCoder} instances.
48 * </p>
49 *
50 * <p>
51 * Usually it is unnecessary to represent everything from the model in a state code, only the parts which are modified
52 * by the transformation rules.
53 * </p>
54 *
55 * @author Miklos Foldenyi, Andras Szabolcs Nagy
56 *
57 */
58public interface IStateCoder {
59
60 /**
61 * Initializes the state coder on the given model.
62 *
63 * @param notifier
64 */
65 void init(Notifier notifier);
66
67 /**
68 * Returns a pseudo-unique identifier that describes the underlying model's current internal state.
69 *
70 * @return an arbitrary {@link Object} that can be used as the identifier.
71 */
72 Object createStateCode();
73
74 /**
75 * Returns a pseudo-unique identifier that describes the given {@link IPatternMatch} in the context of the
76 * underlying model's current internal state.
77 *
78 * @return an arbitrary {@link Object} that can be used as the identifier in the given state.
79 */
80 Object createActivationCode(IPatternMatch match);
81
82}