public TrajectoryWithStateFitness(TrajectoryInfo trajectoryInfo, Fitness fitness) { super(trajectoryInfo, fitness); state = trajectoryInfo.getCurrentStateId(); }
public List<Object> getTrajectoryFromRoot() { return trajectory.getTrajectory(); }
public boolean isCurentStateInTrajectory() { Object currentStateId = trajectory.getCurrentStateId(); List<Object> stateTrajectory = trajectory.getStateTrajectory(); int size = stateTrajectory.size(); for (int i = 0; i < size - 1; i++) { Object stateId = stateTrajectory.get(i); if (currentStateId.equals(stateId)) { return true; } } return false; }
public Collection<Object> getUntraversedTransitionsFromCurrentState() { if (designSpace == null) { throw new DSEException("Unsupported without a design space"); } Object currentState = trajectory.getCurrentStateId(); Collection<Object> traversedIds = designSpace.getActivationIds(currentState); List<Object> untraversedTransitions = new ArrayList<>(); for (Object activationId : activationCodes.getCurrentActivationCodes()) { if (!traversedIds.contains(activationId)) { untraversedTransitions.add(activationId); } } return untraversedTransitions; }
public boolean undoLastTransformation() { if (!trajectory.canStepBack()) { return false; } domain.getCommandStack().undo(); activationCodes.updateActivationCodes(); Object lastActivationId = trajectory.getLastActivationId(); trajectory.backtrack(); if (handlers != null) { for (IExploreEventHandler iExploreEventHandler : handlers) { iExploreEventHandler.undo(lastActivationId); } } logger.debug("Backtrack."); return true; }
public void undoUntilRoot() { while(trajectory.canStepBack()) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); logger.debug("Backtracked to root."); }
public DesignSpaceManager(ThreadContext context) { this.context = context; model = context.getModel(); designSpace = context.getGlobalContext().getDesignSpace(); domain = context.getEditingDomain(); conflictSet = context.getConflictResolver().getLastCreatedConflictSet(); stateCoder = context.getStateCoder(); Object initialStateId = stateCoder.createStateCode(); designSpace.addState(null, null, initialStateId); activationCodes = context.getActivationCodesConflictSet(); this.trajectory = new TrajectoryInfo(initialStateId); logger.debug("DesignSpaceManager initialized with initial model: " + initialStateId); }
/** * Returns the number of distinct transitions the exploration process has discovered (but not necessarily traversed) * so far. * * @return the number of distinct transitions. */ public long getNumberOfTransitions() { return globalContext.getDesignSpace().getNumberOfTransitions(); }
/** * Returns the number of distinct states the exploration process has visited so far. * * @return the number of distinct states. */ public long getNumberOfStates() { return globalContext.getDesignSpace().getNumberOfStates(); }
@Override public int getDepth() { return designSpaceManager.getTrajectoryInfo().getDepth(); }
/** * <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()); }
public SolutionTrajectory createSolutionTrajectroy() { return trajectory.createSolutionTrajectory(context.getGlobalContext().getStateCoderFactory()); }
private void saveSolutionAndBacktrack() { context.calculateFitness(); context.newSolution(); logger.debug("Found solution: " + context.getTrajectoryInfo().toString()); logger.debug("Backtrack for more solutions, if needed."); context.backtrackUntilRoot(); }
public void executeTrajectoryWithMinimalBacktrackWithoutStateCoding(Object[] trajectory, int toExcludedIndex) { int fromIndex = backtrackUntilLastCommonActivation(trajectory); executeTrajectory(trajectory, fromIndex, toExcludedIndex, false, false); Object stateCode = stateCoder.createStateCode(); this.trajectory.modifyLastStateCode(stateCode); }
public void backtrackXTimes(int steps) { for (int i = steps; i > 0; i--) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); logger.debug("Backtracked " + steps + " times."); }
/** * Creates a {@link TrajectoryFitness} with the full trajectory. * @param trajectoryInfo The trajectory. * @param fitness The fitness. */ public TrajectoryFitness(TrajectoryInfo trajectoryInfo, Fitness fitness) { this.fitness = fitness; List<Object> fullTraj = trajectoryInfo.getTrajectory(); trajectory = fullTraj.toArray(new Object[fullTraj.size()]); }
public Object getCurrentState() { return trajectory.getCurrentStateId(); }
@Override public List<Object> getTrajectory() { return designSpaceManager.getTrajectoryInfo().getTrajectory(); }
@Override public Object getCurrentStateId() { return designSpaceManager.getTrajectoryInfo().getCurrentStateId(); }
private void addPermutation(DesignSpaceManager dsm, TrajectoryInfo trajectoryInfo, Object[] parent) { outerLoop: for (Object transitionToAddId : parent) { for (Object childTransition : trajectoryInfo.getTrajectory()) { Object id = childTransition; if (transitionToAddId.equals(id)) { continue outerLoop; } } GeneticHelper.tryFireRightTransition(dsm, transitionToAddId); } }