Search in sources :

Example 1 with Solver

use of org.optaplanner.core.api.solver.Solver in project camel by apache.

the class OptaPlannerConsumer method doStop.

@Override
protected void doStop() throws Exception {
    Solver solver = endpoint.getOrCreateSolver(configuration.getSolverId());
    solver.removeEventListener(listener);
    super.doStop();
}
Also used : Solver(org.optaplanner.core.api.solver.Solver)

Example 2 with Solver

use of org.optaplanner.core.api.solver.Solver in project camel by apache.

the class OptaPlannerEndpoint method doStop.

@Override
protected void doStop() throws Exception {
    synchronized (SOLVERS) {
        for (Solver solver : SOLVERS.values()) {
            solver.terminateEarly();
            SOLVERS.remove(solver);
        }
    }
    super.doStop();
}
Also used : Solver(org.optaplanner.core.api.solver.Solver)

Example 3 with Solver

use of org.optaplanner.core.api.solver.Solver in project droolsjbpm-integration by kiegroup.

the class SolverBuilderTest method buildFromContainerSuccessful.

@Test
public void buildFromContainerSuccessful() {
    when(registry.getContainer(CONTAINER_ID)).thenReturn(container);
    InternalKieContainer kieContainer = (InternalKieContainer) KieServices.Factory.get().getKieClasspathContainer(getClass().getClassLoader());
    when(container.getKieContainer()).thenReturn(kieContainer);
    when(container.getStatus()).thenReturn(KieContainerStatus.STARTED);
    SolverDef solverDef = new SolverDef(CONTAINER_ID, null, null, null, SOLVER_CONTAINER_CONFIG_RESOURCE, null, -1, null);
    Solver solver = SolverBuilder.create().solverDef(solverDef).registry(registry).build();
    assertNotNull(solver);
}
Also used : Solver(org.optaplanner.core.api.solver.Solver) InternalKieContainer(org.drools.core.impl.InternalKieContainer) Test(org.junit.Test)

Example 4 with Solver

use of org.optaplanner.core.api.solver.Solver in project droolsjbpm-integration by kiegroup.

the class SolverBuilderTest method buildFromResourceSuccessful.

@Test
public void buildFromResourceSuccessful() {
    SolverDef solverDef = new SolverDef(SOLVER_SIMPLE_CONFIG_RESOURCE);
    Solver solver = SolverBuilder.create().solverDef(solverDef).registry(registry).build();
    assertNotNull(solver);
}
Also used : Solver(org.optaplanner.core.api.solver.Solver) Test(org.junit.Test)

Example 5 with Solver

use of org.optaplanner.core.api.solver.Solver in project camel by apache.

the class OptaPlannerConsumer method doStart.

@Override
protected void doStart() throws Exception {
    Solver solver = endpoint.getOrCreateSolver(configuration.getSolverId());
    solver.addEventListener(listener);
    super.doStart();
}
Also used : Solver(org.optaplanner.core.api.solver.Solver)

Aggregations

Solver (org.optaplanner.core.api.solver.Solver)9 Test (org.junit.Test)3 ProblemFactChange (org.optaplanner.core.impl.solver.ProblemFactChange)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 InternalKieContainer (org.drools.core.impl.InternalKieContainer)1 KieContainer (org.kie.api.runtime.KieContainer)1 KieServerConfigProviderLoader (org.kie.server.api.model.KieServerConfigProviderLoader)1 ServiceResponse (org.kie.server.api.model.ServiceResponse)1 ScoreWrapper (org.kie.server.api.model.instance.ScoreWrapper)1 SolverInstance (org.kie.server.api.model.instance.SolverInstance)1 SolverInstanceList (org.kie.server.api.model.instance.SolverInstanceList)1