/** * 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); }
/** * 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); }
/** * 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); }
initExploration(strategy); waitForTerminaition(); timer.cancel(); } else {
/** * 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(); }
/** * Changes the level of logging. See {@link DseLoggingLevel} for details. * * Also configures a basic console appender for log4j. * * @param dseLoggingLevel */ public static void turnOnLoggingWithBasicConfig(DseLoggingLevel dseLoggingLevel) { BasicConfigurator.configure(); Logger.getRootLogger().setLevel(Level.WARN); turnOnLogging(dseLoggingLevel); }
/** * <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()); }
/** * Stops the exploration and waits for termination. It has no effect if the exploration is already terminated or not * even started. */ public void stopExploration() { if (globalContext.isDone()) { logger.info("Cannot stop exploration - design space exploration has already finished."); } else if (globalContext.isNotStarted()) { logger.info("Cannot stop exploration - design space exploration has not been started."); } else { globalContext.stopAllThreads(); waitForTerminaition(); } }
private void initExploration(IStrategy strategy) { Preconditions.checkArgument(model != null, MODEL_NOT_YET_GIVEN); Preconditions.checkArgument(strategy != null, "A strategy must be given. Use the Strategies helper class."); Preconditions.checkState(!globalContext.getTransformations().isEmpty(), "At least one transformation rule must be added to start the exploration."); if (globalContext.getStateCoderFactory() == null) { if (getMetaModelPackages() == null || getMetaModelPackages().isEmpty()) { throw new DSEException("Cannot initialize state coder." + " Please specifiy the EPackages your model uses with addMetaModelPackage(EPackage)"); } globalContext.setStateCoderFactory(new SimpleStateCoderFactory(getMetaModelPackages())); } logger.info("DesignSpaceExplorer started exploration."); if (deepCopyModel) { globalContext.startFirstThread(strategy, model); } else { globalContext.startFirstThreadWithoutModelClone(strategy, model); } }
/** * Creates a string containing the state codes of all the found solutions and the found trajectories to these * solutions with fitness values. * * @return A pretty string with the solutions. */ public String toStringSolutions() { StringBuilder sb = new StringBuilder(); Collection<Solution> solutions = getSolutions(); sb.append("Number of solutions: "); sb.append(solutions.size()); sb.append("\n"); for (Solution solution : solutions) { sb.append("Solution: "); sb.append(solution.getStateCode()); sb.append("\n"); for (SolutionTrajectory trajectory : solution.getTrajectories()) { sb.append(" "); sb.append(trajectory.toPrettyString()); sb.append("\n"); } } return sb.toString(); }
/** * 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 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"); }
/** * 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); }