@Test public void trackLocalSearch() { SolverFactory<NQueens> solverFactory = SolverFactory.createFromXmlResource(NQueensApp.SOLVER_CONFIG); SolverConfig solverConfig = solverFactory.getSolverConfig(); NQueensGenerator generator = new NQueensGenerator(); NQueens planningProblem = NQueensSolutionInitializer.initialize(generator.createNQueens(N)); LocalSearchPhaseConfig localSearchPhaseConfig = new LocalSearchPhaseConfig(); localSearchPhaseConfig.setAcceptorConfig(acceptorConfig); localSearchPhaseConfig.setForagerConfig(localSearchForagerConfig); localSearchPhaseConfig.getForagerConfig().setBreakTieRandomly(false); localSearchPhaseConfig.setMoveSelectorConfig(new ChangeMoveSelectorConfig()); localSearchPhaseConfig.getMoveSelectorConfig().setSelectionOrder(SelectionOrder.ORIGINAL); localSearchPhaseConfig.setTerminationConfig(new TerminationConfig()); localSearchPhaseConfig.getTerminationConfig().setStepCountLimit(20); solverConfig.getPhaseConfigList().set(1, localSearchPhaseConfig); NQueensStepTracker listener = new NQueensStepTracker(); DefaultSolver<NQueens> solver = (DefaultSolver<NQueens>) solverFactory.buildSolver(); solver.addPhaseLifecycleListener(listener); NQueens bestSolution = solver.solve(planningProblem); assertNotNull(bestSolution); assertTrackingList(expectedCoordinates, listener.getTrackingList()); }
protected SolverFactory buildSolverFactory() { SolverFactory solverFactory = SolverFactory.createFromXmlResource(createSolverConfigResource()); SolverConfig solverConfig = solverFactory.getSolverConfig(); solverConfig.setTerminationConfig(new TerminationConfig()); ConstructionHeuristicPhaseConfig constructionHeuristicPhaseConfig = new ConstructionHeuristicPhaseConfig(); constructionHeuristicPhaseConfig.setConstructionHeuristicType(constructionHeuristicType); solverConfig.setPhaseConfigList(Arrays.<PhaseConfig>asList(constructionHeuristicPhaseConfig)); return solverFactory; }
@Override protected SolverFactory<Solution_> buildSolverFactory() { SolverFactory<Solution_> solverFactory = SolverFactory.createFromXmlResource(createSolverConfigResource()); SolverConfig solverConfig = solverFactory.getSolverConfig(); solverConfig.setTerminationConfig(new TerminationConfig()); ExhaustiveSearchPhaseConfig exhaustiveSearchPhaseConfig = new ExhaustiveSearchPhaseConfig(); exhaustiveSearchPhaseConfig.setExhaustiveSearchType(exhaustiveSearchType); solverConfig.setPhaseConfigList(Arrays.asList(exhaustiveSearchPhaseConfig)); return solverFactory; }
@Override protected Solver createSolver() { SolverFactory solverFactory = SolverFactory.createFromXmlResource(SOLVER_CONFIG); return solverFactory.buildSolver(); }
public VehicleRoutingDistanceTypeComparison() { vehicleRoutingDao = new VehicleRoutingDao(); SolverFactory solverFactory = SolverFactory.createFromXmlResource(VehicleRoutingApp.SOLVER_CONFIG); scoreDirectorFactory = solverFactory.buildSolver().getScoreDirectorFactory(); }
@Override protected Solver<CloudBalance> createSolver() { SolverFactory<CloudBalance> solverFactory = SolverFactory.createFromXmlResource(SOLVER_CONFIG); return solverFactory.buildSolver(); }