@Override public Set<BatchTransformationRule<?, ?>> getRules() { return globalContext.getTransformations(); }
@Override public void initStrategy(ThreadContext context) { this.context = context; dsm = context.getDesignSpaceManager(); initialPopulation = new HashSet<TrajectoryFitness>(populationSize); Objects.requireNonNull(objective, "Hard objective is missing for FixedPriorityInitialSelector."); Preconditions.checkState(objective.isHardObjective(), "Given objective is not hard objective for FixedPriorityInitialSelector."); for (BatchTransformationRule<?, ?> batchTransformationRule : context.getGlobalContext().getTransformations()) { if (!priorities.containsKey(batchTransformationRule)) { throw new IllegalStateException("Missing rule priority for FixedPriorityInitialSelector."); } } FixedPriorityConflictResolver fixedPriorityResolver = ConflictResolvers.createFixedPriorityResolver(); for (Entry<BatchTransformationRule<?, ?>, Integer> entry : priorities.entrySet()) { fixedPriorityResolver.setPriority(entry.getKey().getRuleSpecification(), entry.getValue()); } context.changeActivationOrdering(fixedPriorityResolver.createConflictSet()); objective.init(context); logger.info("FixedPriorityInitialSelector inited."); }
/** * 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); } }
for (BatchTransformationRule<?, ?> tr : globalContext.getTransformations()) { ruleEngine.addRule(tr.getRuleSpecification(), (EventFilter<IPatternMatch>) tr.getFilter());