public SolutionTrajectory createSolutionTrajectroy() { return trajectory.createSolutionTrajectory(context.getGlobalContext().getStateCoderFactory()); }
@Override public void initStrategy(ThreadContext context) { this.context = context; this.solutionStore = context.getGlobalContext().getSolutionStore(); final ObjectiveComparatorHelper objectiveComparatorHelper = context.getObjectiveComparatorHelper(); trajectoiresToExplore = new PriorityQueue<TrajectoryWithFitness>(11, (o1, o2) -> objectiveComparatorHelper.compare(o2.fitness, o1.fitness)); }
public BatchTransformationRule<?, ?> getRuleByActivation(Activation<?> activation) { return context.getGlobalContext().getSpecificationRuleMap().get(activation.getInstance().getSpecification()); }
@Override public void initStrategy(ThreadContext context) { this.context = context; trajectoryInfo = context.getTrajectoryInfo(); GlobalContext gc = context.getGlobalContext(); Object sharedObject = gc.getSharedObject(); if (sharedObject == null) { gc.setSharedObject(shared); logger.info("Random exploration strategy is initied."); startThreads(); } else { shared = (SharedData) sharedObject; } maxDepth = rnd.nextInt(shared.maxDepth - shared.minDepth) + shared.minDepth; }
@Override public void initStrategy(ThreadContext context) { this.context = context; this.solutionStore = context.getGlobalContext().getSolutionStore(); GlobalContext globalContext = context.getGlobalContext(); if (globalContext.getSharedObject() == null) { isFirstThread = true; shared = new BfsSharedObject(globalContext.getThreadPool().getMaximumPoolSize()); globalContext.setSharedObject(shared); logger.info("Breadth-first exploration strategy is inited."); } else { shared = (BfsSharedObject) globalContext.getSharedObject(); } }
@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."); }
int threads = context.getGlobalContext().getThreadPool().getMaximumPoolSize(); so.barrierBeforeChildGeneration = new CyclicBarrier(threads); so.barrierAfterChildGeneration = new CyclicBarrier(threads); context.getGlobalContext().stopAllThreads(); so.barrierBeforeChildGeneration.await(); return;
/** * Starts the design space exploration. Returns only when the {@link IStrategy#explore()} method returns. */ public void run() { GlobalContext globalContext = threadContext.getGlobalContext(); try { threadContext.init(); strategy.initStrategy(threadContext); strategy.explore(); threadContext.backtrackUntilRoot(); } catch (Throwable e) { Logger.getLogger(IStrategy.class).error("Thread stopped unexpectedly!", e); globalContext.registerException(e); } finally { globalContext.strategyFinished(this); dispose(); } }
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); }
public synchronized void newSolution(ThreadContext context) { solutionSaver.setSolutionsCollection(solutions); Fitness fitness = context.getLastFitness(); DesignSpaceManager dsm = context.getDesignSpaceManager(); Object id = dsm.getCurrentState(); IStateCoderFactory stateCoderFactory = context.getGlobalContext().getStateCoderFactory(); SolutionTrajectory solutionTrajectory = dsm.getTrajectoryInfo().createSolutionTrajectory(stateCoderFactory); solutionTrajectory.setFitness(fitness); if (acceptOnlyGoalSolutions && !fitness.isSatisifiesHardObjectives()) { unsavedSolutionCallbacks(context, solutionTrajectory); return; } boolean solutionSaved = solutionSaver.saveSolution(context, id, solutionTrajectory); if (solutionSaved) { enoughSolutions.solutionFound(context, solutionTrajectory); savedSolutionCallbacks(context, solutionTrajectory); if (enoughSolutions.enoughSolutions()) { context.getGlobalContext().stopAllThreads(); } } else { unsavedSolutionCallbacks(context, solutionTrajectory); } }
stateCoder = getGlobalContext().getStateCoderFactory().createStateCoder(); stateCoder.init(model); stateCoder.createStateCode();