From e11bce7ad3e803e80883499fec0ad6e4540ffe43 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 30 Jun 2020 18:03:48 +0200 Subject: Add modified VIATRA-DSE version --- .../eclipse/viatra/dse/statecode/IStateCoder.java | 82 ++++++++++++++++++++++ .../viatra/dse/statecode/IStateCoderFactory.java | 29 ++++++++ 2 files changed, 111 insertions(+) create mode 100644 Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoder.java create mode 100644 Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoderFactory.java (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode') 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 @@ +/******************************************************************************* + * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-v20.html. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.viatra.dse.statecode; + +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; + +/** + *

+ * To be able to efficiently explore a design space, a state that has been explored before through an other trajectory + * needs to be recognized and ignored accordingly. + *

+ * + *

+ * This is done by generating a pseudo-unique value (object) that is only depended on the relevant parts of the model's + * internal state, that is, the values of two states can only be equal if the states themselves can be considered equal. + *

+ * + *

+ * The processing engine however assumes, that any two states that share this pseudo-unique value has the same + * characteristics, meaning they have the same amount and type of outgoing transitions available, and firing the + * appropriate transitions from both states also result in states that share their pseudo-unique identifier. If this + * condition is not satisfied, the exploration process's result will be non-deterministic, and in consequence, solutions + * can be lost. + *

+ * + *

+ * In addition to providing pseudo-unique identifiers to model states, the state coder must provide pseud-unique + * identifiers to the outgoing transitions as well, but they only need to be unique on the scope of the particular + * state, not globally. Global addressing thus can be achieved by considering the pseudo-unique identifier of the state + * and the pseudo-unique identifier of the transition together if needed. + *

+ * + *

+ * Both identifiers can be arbitrary objects, and equality is checked by calling {@link Object#equals(Object)} on the + * two identifiers. + *

+ * + *

+ * For any particular implementation an {@link IStateCoderFactory} implementation must also be supplied that handles the + * creation of {@link IStateCoder} instances. + *

+ * + *

+ * Usually it is unnecessary to represent everything from the model in a state code, only the parts which are modified + * by the transformation rules. + *

+ * + * @author Miklos Foldenyi, Andras Szabolcs Nagy + * + */ +public interface IStateCoder { + + /** + * Initializes the state coder on the given model. + * + * @param notifier + */ + void init(Notifier notifier); + + /** + * Returns a pseudo-unique identifier that describes the underlying model's current internal state. + * + * @return an arbitrary {@link Object} that can be used as the identifier. + */ + Object createStateCode(); + + /** + * Returns a pseudo-unique identifier that describes the given {@link IPatternMatch} in the context of the + * underlying model's current internal state. + * + * @return an arbitrary {@link Object} that can be used as the identifier in the given state. + */ + Object createActivationCode(IPatternMatch match); + +} diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoderFactory.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoderFactory.java new file mode 100644 index 00000000..cf8bdf8d --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/statecode/IStateCoderFactory.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-v20.html. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.viatra.dse.statecode; + +/** + * Interface for a factory class that creates instances of {@link IStateCoder} objects. This is required because state + * coders have to be created on-demand if the design space exploration process decides that a new thread is to be + * spawned. Since each thread requires it's own working model instance and a state coder is linked to the underlying + * model, a new {@link IStateCoder} needs to be created per processing thread. + * + * @author Miklos Foldenyi, Andras Szabolcs Nagy + * + */ +public interface IStateCoderFactory { + + /** + * Creates a new {@link IStateCoder} instance specific to this {@link IStateCoderFactory}. + * + * @return the new {@link IStateCoder} instance specific to this working model. + */ + IStateCoder createStateCoder(); + +} -- cgit v1.2.3-70-g09d2