/** * Starts the design space exploration asynchronously. Completion of the process can be verified by calling * {@link DesignSpaceExplorer#isDone()}. * * @param strategy * The strategy of the exploration. */ public void startExplorationAsync(IStrategy strategy) { startExploration(strategy, false, -1); }
/** * Defines the initial model of the exploration. The given model won't be cloned, thus the exploration will modify * it. * * @param model * The root object of the EMF model. It won't be cloned. */ public void setInitialModelUncloned(Notifier model) { setInitialModel(model, false); }
/** * Transforms the given model along the trajectory. * * @param modelRoot * The root of the model. * @throws ViatraQueryRuntimeException * If the VIATRA Query fails to initialize. */ public void doTransformation(Notifier modelRoot) { setModel(modelRoot); doTransformation(); }
/** * Transforms the given model along the trajectory. * <p> * The transformation will be reversible by creating an {@link EditingDomain} on the model. * * @param modelRoot * The root of the model. * @throws ViatraQueryRuntimeException * If the VIATRA Query fails to initialize. */ public void doTransformationUndoable(Notifier modelRoot) { setModelWithEditingDomain(modelRoot); doTransformation(); }
/** * Returns an arbitrary solution trajectory or null if the exploration failed to find any. * * @return An arbitrary solution trajectory. */ public SolutionTrajectory getArbitrarySolution() { Collection<Solution> solutions = getSolutions(); if (solutions.isEmpty()) { return null; } return solutions.iterator().next().getArbitraryTrajectory(); }
public void backtrack() { int size = trajectory.size(); if (size == 0) { throw new DSEException("Cannot step back any further!"); } trajectory.remove(size - 1); rules.remove(size - 1); stateIds.remove(size); measuredCosts.remove(size - 1); }
/** * Serializes all the found solutions by transforming the given initial model. * </p>Files will be named <code>solution[id].[extension]</code>. * @param model The initial model. * @param extension The extension of the omitted file. */ public void saveModels(Notifier model, String extension) { this.saveModels(model, "solution", extension); }
@Override public void solutionTriedToSave(ThreadContext context, SolutionTrajectory trajectory) { logger.debug("Not good enough solution: " + trajectory.toPrettyString()); } }
/** * Transforms the given model along the trajectory. To initialize the model call the * {@link SolutionTrajectory#setModel(Notifier)} method. * * @throws Exception * If the activation to fire is not found. Possible problems: wrong model, bad state serializer. * @throws ViatraQueryRuntimeException * If the VIATRA Query fails to initialize. */ public void doTransformation() { while (doNextTransformation()); }
/** * Call this method to undo the transformation. */ public void undoTransformation() { while (undoLastTransformation()); }
/** * Creates a fixed priority exploration strategy without a depth limit. It is a depth-first search exploration * strategy but from a current state it only explores the activations with the highest priority. Priorities can be * defined on the strategy itself. * * @return The strategy. * @see FixedPriorityStrategy */ public static FixedPriorityStrategy createFixedPriorityStrategy() { return createFixedPriorityStrategy(-1); }
public SolutionTrajectory createSolutionTrajectory(final IStateCoderFactory stateCoderFactory) { List<Object> activationIds = new ArrayList<>(trajectory); List<BatchTransformationRule<?, ?>> copiedRules = new ArrayList<>(rules); return new SolutionTrajectory(activationIds, copiedRules, stateCoderFactory); }
/** * <p> * Creates a {@link DesignSpaceExplorer} object that is able to execute a design space exploration process. * </p> * * <p> * By default the state coder used is the generic (not meta-model specific) {@link GraphHash}. You can provide your * custom state coder by implementing the {@link IStateCoderFactory} and {@link IStateCoder} interfaces, and passing * the former to the {@link #setStateCoderFactory(IStateCoderFactory)} method. * */ public DesignSpaceExplorer() { setDesignspace(new DesignSpace()); }
/** * Initialize this SolutionTrajectory for transforming the given model along the trajectory. * <p> * The transformation will be reversible by creating an {@link EditingDomain} on the model. * * @param modelRoot * The root of the model. * @throws ViatraQueryRuntimeException * If the VIATRA Query fails to initialize. */ public void setModelWithEditingDomain(Notifier modelRoot) { setModel(modelRoot); editingDomain = EMFHelper.createEditingDomain(model); }
/** * Starts the design space exploration asynchronously with a timeout. Completion of the process can be verified by * calling {@link DesignSpaceExplorer#isDone()}. * * @param strategy * The strategy of the exploration. * @param timeout * The number of milliseconds before the exploration is forced to stop. * @return Returns true if the exploration stopped by the timeout. */ public boolean startExplorationAsyncWithTimeout(IStrategy strategy, long timeout) { return startExploration(strategy, false, timeout); }
/** * Defines the initial model of the exploration. The model will be cloned, which is desired in most cases as the * given model won't be changed. * * @param model * The root object of the EMF model. */ public void setInitialModel(Notifier model) { setInitialModel(model, true); }
/** * Serializes all the found solutions by transforming the given initial model. * </p>Files will be named <code>solution[id].xmi</code>. * @param model The initial model. */ public void saveModels(Notifier model) { this.saveModels(model, "solution", "xmi"); }
@Override public void solutionFound(ThreadContext context, SolutionTrajectory trajectory) { logger.info("Solution registered: " + trajectory.toPrettyString()); }
/** * Starts the design space exploration. It returns only when the strategy decides to stop the execution. * * @param strategy * The strategy of the exploration. */ public void startExploration(IStrategy strategy) { startExploration(strategy, true, -1); }
/** * Starts the design space exploration with a timeout. It returns only when the strategy decides to stop the * execution or the given timeout is elapsed. * * @param strategy * The strategy of the exploration. * @param timeout * The number of milliseconds before the exploration is forced to stop. * @return Returns true if the exploration stopped by the timeout. */ public boolean startExplorationWithTimeout(IStrategy strategy, long timeout) { return startExploration(strategy, true, timeout); }