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); }
public int getId(BatchTransformationRule<?, ?> rule) { Thread currentThread = Thread.currentThread(); HashMap<BatchTransformationRule<?, ?>, IdProvider> ruleMap = idProviders.get(currentThread); if (ruleMap == null) { throw new DSEException("There is no registered id provider"); } IdProvider idProvider = ruleMap.get(rule); return idProvider.getId(); }
/** * Returns a {@link Hasher} with an internal {@link MessageDigest} that is based on the protocol named * {@code protocoll}. * * @param protocoll * the name of the hash algorythm. * @return the initialized {@link Hasher} * * @throws DSEException * on initialization failure. */ public static Hasher getHasher(String protocoll) { try { return new Hasher(MessageDigest.getInstance(protocoll)); } catch (NoSuchAlgorithmException e) { throw new DSEException(e); } }
@Override public void init(ThreadContext context) { try { ViatraQueryEngine queryEngine = context.getQueryEngine(); for (IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> querySpecification : constraints) { ViatraQueryMatcher<? extends IPatternMatch> matcher = querySpecification.getMatcher(queryEngine); matchers.add(matcher); } } catch (ViatraQueryException e) { throw new DSEException("Couldn't get the VIATRA Query matcher, see inner exception", e); } }
break; default: throw new DSEException("Not supported logging level.");
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; }
@Override public void init(ThreadContext context) { super.init(context); softMatches = new ArrayList<Integer>(softConstraints.size()); softMatchers = new ArrayList<ViatraQueryMatcher<? extends IPatternMatch>>(softConstraints.size()); hardMatches = new ArrayList<Integer>(hardConstraints.size()); hardMatchers = new ArrayList<ViatraQueryMatcher<? extends IPatternMatch>>(hardConstraints.size()); for (int i = 0; i < softConstraints.size(); i++) { softMatches.add(0); } for (int i = 0; i < hardConstraints.size(); i++) { hardMatches.add(0); } try { ViatraQueryEngine queryEngine = context.getQueryEngine(); for (QueryConstraint qc : softConstraints) { softMatchers.add(qc.query.getMatcher(queryEngine)); } for (QueryConstraint qc : hardConstraints) { hardMatchers.add(qc.query.getMatcher(queryEngine)); } } catch (ViatraQueryException e) { throw new DSEException("Couldn't initialize the VIATRA Query matcher, see inner exception", e); } }
public void fireActivation(final Object transition) { if (fireActivationSilent(transition)) { return; } StringBuilder sb = new StringBuilder(); sb.append("A retrieved Transition SHOULD have a matching Activation. Possible causes: the state serializer is faulty; the algorithm choosed a wrong Transition."); sb.append("\nSought transition: "); sb.append(transition); Object currentStateId = getCurrentState(); sb.append("\nCurrent known state: "); sb.append(currentStateId); Object actualStateId = stateCoder.createStateCode(); sb.append("\nActual state: "); sb.append((actualStateId.equals(currentStateId) ? "same as current" : actualStateId)); sb.append("\n"); sb.append(trajectory); sb.append("\nAvailable transitions:"); for (Activation<?> act : conflictSet.getNextActivations()) { IPatternMatch match = (IPatternMatch) act.getAtom(); Object code = generateMatchCode(match); sb.append("\n\t"); sb.append(code); } throw new DSEException(sb.toString()); }
/** * Adds an objective the the exploration process. Please see the {@link IObjective} interface and its * implementations for details. * * @param objective * The objective. * @see IObjective */ public void addObjective(IObjective objective) { for (IObjective o : globalContext.getObjectives()) { if (o.getName().equals(objective.getName())) { throw new DSEException("Two objectives with the same name cannot be registered:" + o.getName()); } } globalContext.getObjectives().add(objective); }
return addStateCode(sd.node, (EObject) eReferred); } else { throw new DSEException("The EObject " + eObject.toString() + " does not have a feature " + eReferred.toString() + "."); throw new DSEException("The EObject " + eObject.toString() + " does not have a feature " + eReferred.toString() + ".");
@Override public void init(Notifier notifier, StatecodingDependencyGraph statecodingDependencyGraph) { try { EMFScope scope = new EMFScope(notifier); ViatraQueryEngine queryEngine = ViatraQueryEngine.on(scope); Set<EClass> classes = new HashSet<EClass>(); // Set<EReference> references = new HashSet<EReference>(); for (StatecodingNode node : statecodingDependencyGraph.getNodes()) { classes.add(node.getClazz()); // for (StatecodingDependency dependency : node.getStatecodingDependencies()) { // // TODO inverse reference // references.add(dependency.eReference); // } } baseIndex = EMFScope.extractUnderlyingEMFIndex(queryEngine); baseIndex.registerEClasses(classes, IndexingLevel.FULL); } catch (ViatraQueryException e) { logger.error("Failed to initialize VIATRA Query engine on the given notifier", e); throw new DSEException("Failed to initialize VIATRA Query engine on the given notifier"); } }
Solution s = st.getSolution(); if (!s.getTrajectories().remove(st)) { throw new DSEException("Should not happen.");
Object[] nextTrajectory = queue.poll(); if (nextTrajectory == null) { throw new DSEException("Could not generate enough initial solutions.");
boolean isSuccessfulUndo = context.backtrack(); if (!isSuccessfulUndo) { throw new DSEException("The new state is present in the trajectoy but cannot bactkrack. Should never happen!"); } else { logger.info("The new state is already visited in the trajectory, backtrack.");
boolean isSuccessfulUndo = context.backtrack(); if (!isSuccessfulUndo) { throw new DSEException( "The new state is present in the trajectoy but cannot bactkrack. Should never happen!"); } else {
boolean isSuccessfulUndo = context.backtrack(); if (!isSuccessfulUndo) { throw new DSEException( "The new state is present in the trajectoy but cannot bactkrack. Should never happen!"); } else {
/** * Adds a {@link BatchTransformationRule}. * * @param rule * The transformationRule. */ public void addTransformationRule(BatchTransformationRule<?, ?> rule) { Preconditions.checkArgument(rule != null); for (BatchTransformationRule<?, ?> rule2 : globalContext.getTransformations()) { if (rule.getPrecondition().equals(rule2.getPrecondition())) { throw new DSEException( "Two transformation rule (" + rule.getName() + "; " + rule2.getName() + ") uses the same LHS VIATRA Query pattern (" + rule.getPrecondition().getFullyQualifiedName() + "), which may lead to hash collision." + " Please wrap the pattern with an other pattern with the 'find' keyword (or duplicate the code), and use that for one of the rules LHS."); } } globalContext.getTransformations().add(rule); }
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); } }
navigationHelper.registerObservedTypes(classes, null, features, IndexingLevel.FULL); } catch (ViatraQueryException e) { throw new DSEException(e);
throw new DSEException("Failed to create unmanaged ViatraQueryEngine on the model.", e);