Search in sources :

Example 11 with LocalSearchPhaseConfig

use of org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig in project droolsjbpm-integration by kiegroup.

the class AbstractTaskAssigningCoreTest method createNonDaemonSolver.

protected Solver<TaskAssigningSolution> createNonDaemonSolver(int stepCountLimit) {
    SolverConfig config = createBaseConfig();
    ConstructionHeuristicPhaseConfig constructionHeuristicPhaseConfig = new ConstructionHeuristicPhaseConfig();
    constructionHeuristicPhaseConfig.setConstructionHeuristicType(ConstructionHeuristicType.FIRST_FIT);
    LocalSearchPhaseConfig phaseConfig = new LocalSearchPhaseConfig();
    phaseConfig.setTerminationConfig(new TerminationConfig().withStepCountLimit(stepCountLimit));
    config.setPhaseConfigList(Arrays.asList(constructionHeuristicPhaseConfig, phaseConfig));
    SolverFactory<TaskAssigningSolution> solverFactory = SolverFactory.create(config);
    return solverFactory.buildSolver();
}
Also used : TerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) LocalSearchPhaseConfig(org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig) ConstructionHeuristicPhaseConfig(org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig) SolverConfig(org.optaplanner.core.config.solver.SolverConfig)

Example 12 with LocalSearchPhaseConfig

use of org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig in project kie-benchmarks by kiegroup.

the class ConferenceSchedulingBenchmark method createSolver.

@Override
protected Solver<ConferenceSolution> createSolver() {
    // the pre-defined configuration in ConferenceScheduling cannot be used
    SolverConfig solverConfig = new SolverConfig();
    solverConfig.withEntityClasses(Talk.class);
    solverConfig.withSolutionClass(ConferenceSolution.class);
    ScoreDirectorFactoryConfig scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
    scoreDirectorFactoryConfig.setConstraintProviderClass(ConferenceSchedulingConstraintProvider.class);
    LocalSearchPhaseConfig localSearchPhaseConfig = new LocalSearchPhaseConfig();
    localSearchPhaseConfig.setLocalSearchType(LocalSearchType.TABU_SEARCH);
    solverConfig.setPhaseConfigList(Arrays.asList(new ConstructionHeuristicPhaseConfig(), localSearchPhaseConfig));
    solverConfig.setScoreDirectorFactoryConfig(scoreDirectorFactoryConfig);
    solverConfig.setTerminationConfig(new TerminationConfig().withTerminationClass(ConferenceSchedulingTermination.class));
    SolverFactory<ConferenceSolution> solverFactory = SolverFactory.create(solverConfig);
    return solverFactory.buildSolver();
}
Also used : ScoreDirectorFactoryConfig(org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig) TerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) ConferenceSolution(org.optaplanner.examples.conferencescheduling.domain.ConferenceSolution) LocalSearchPhaseConfig(org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig) ConstructionHeuristicPhaseConfig(org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig) SolverConfig(org.optaplanner.core.config.solver.SolverConfig) ConferenceSchedulingTermination(org.jboss.qa.brms.performance.examples.conferencescheduling.termination.ConferenceSchedulingTermination)

Example 13 with LocalSearchPhaseConfig

use of org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig in project droolsjbpm-integration by kiegroup.

the class PlannerCloudBalanceIntegrationTest method solveSolution.

private void solveSolution(CloudBalance cloudBalance) {
    LocalSearchPhaseConfig localSearchPhaseConfig = new LocalSearchPhaseConfig();
    localSearchPhaseConfig.setTerminationConfig(new TerminationConfig().withStepCountLimit(20));
    SolverConfig config = new SolverConfig().withEntityClassList(Arrays.asList(CloudProcess.class)).withSolutionClass(CloudBalance.class).withScoreDirectorFactory(new ScoreDirectorFactoryConfig().withIncrementalScoreCalculatorClass(CloudBalancingIncrementalScoreCalculator.class)).withPhases(new ConstructionHeuristicPhaseConfig().withConstructionHeuristicType(ConstructionHeuristicType.FIRST_FIT_DECREASING), localSearchPhaseConfig);
    Assert.assertEquals(cloudBalance.getScore().getHardScore(), Integer.MIN_VALUE);
    Assert.assertEquals(cloudBalance.getScore().getSoftScore(), Integer.MIN_VALUE);
    SolverFactory<CloudBalance> solverFactory = SolverFactory.create(config);
    Solver<CloudBalance> solver = solverFactory.buildSolver();
    solver.solve(cloudBalance);
    CloudBalance solution = solver.getBestSolution();
    Assert.assertNotEquals(solution.getScore().getHardScore(), Integer.MIN_VALUE);
    Assert.assertNotEquals(solution.getScore().getSoftScore(), Integer.MIN_VALUE);
}
Also used : ScoreDirectorFactoryConfig(org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig) TerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) CloudBalance(org.kie.karaf.itest.planner.domain.CloudBalance) LocalSearchPhaseConfig(org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig) ConstructionHeuristicPhaseConfig(org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig) SolverConfig(org.optaplanner.core.config.solver.SolverConfig)

Aggregations

LocalSearchPhaseConfig (org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig)13 SolverConfig (org.optaplanner.core.config.solver.SolverConfig)12 LocalSearchForagerConfig (org.optaplanner.core.config.localsearch.decider.forager.LocalSearchForagerConfig)8 UnionMoveSelectorConfig (org.optaplanner.core.config.heuristic.selector.move.composite.UnionMoveSelectorConfig)7 ConstructionHeuristicPhaseConfig (org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig)5 TerminationConfig (org.optaplanner.core.config.solver.termination.TerminationConfig)5 ScoreDirectorFactoryConfig (org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig)3 VehicleRoutingSolution (org.optaplanner.examples.vehiclerouting.domain.VehicleRoutingSolution)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1 ConferenceSchedulingTermination (org.jboss.qa.brms.performance.examples.conferencescheduling.termination.ConferenceSchedulingTermination)1 CloudBalance (org.kie.karaf.itest.planner.domain.CloudBalance)1 LimeConfig (org.kie.kogito.explainability.local.lime.LimeConfig)1 TaskAssigningSolution (org.kie.kogito.taskassigning.core.model.TaskAssigningSolution)1 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)1 MoveSelectorConfig (org.optaplanner.core.config.heuristic.selector.move.MoveSelectorConfig)1 ChangeMoveSelectorConfig (org.optaplanner.core.config.heuristic.selector.move.generic.ChangeMoveSelectorConfig)1 SwapMoveSelectorConfig (org.optaplanner.core.config.heuristic.selector.move.generic.SwapMoveSelectorConfig)1