Skip to content

Commit

Permalink
PLANNER-491 Rename PartSolver to PartitionSolver
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Oct 12, 2016
1 parent 1e023f4 commit 08d25c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Expand Up @@ -73,11 +73,13 @@ public String getPhaseTypeString() {


@Override @Override
public void solve(DefaultSolverScope<Solution_> solverScope) { public void solve(DefaultSolverScope<Solution_> solverScope) {
// PartitionedSearchPhaseScope<Solution_> phaseScope = new PartitionedSearchPhaseScope<>(solverScope);
// phaseStarted(phaseScope);
List<Solution_> partList = solutionPartitioner.splitWorkingSolution(solverScope.getScoreDirector()); List<Solution_> partList = solutionPartitioner.splitWorkingSolution(solverScope.getScoreDirector());
List<Future> futureList = new ArrayList<>(partList.size()); List<Future> futureList = new ArrayList<>(partList.size());
for (Solution_ part : partList) { for (Solution_ part : partList) {
PartSolver<Solution_> partSolver = buildPartSolver(solverScope); PartitionSolver<Solution_> partitionSolver = buildPartitionSolver(solverScope);
Future<?> future = executorService.submit(() -> partSolver.solve(part)); Future<?> future = executorService.submit(() -> partitionSolver.solve(part));
futureList.add(future); futureList.add(future);
} }
for (Future future : futureList) { for (Future future : futureList) {
Expand All @@ -87,9 +89,8 @@ public void solve(DefaultSolverScope<Solution_> solverScope) {
e.printStackTrace(); // TODO remove e.printStackTrace(); // TODO remove
} }
} }
// phaseEnded(phaseScope);


// PartitionedSearchPhaseScope<Solution_> phaseScope = new PartitionedSearchPhaseScope<>(solverScope);
// phaseStarted(phaseScope);
// //
// while (!termination.isPhaseTerminated(phaseScope)) { // while (!termination.isPhaseTerminated(phaseScope)) {
// PartitionedSearchStepScope<Solution_> stepScope = new PartitionedSearchStepScope<>(phaseScope); // PartitionedSearchStepScope<Solution_> stepScope = new PartitionedSearchStepScope<>(phaseScope);
Expand Down Expand Up @@ -119,10 +120,9 @@ public void solve(DefaultSolverScope<Solution_> solverScope) {
// stepEnded(stepScope); // stepEnded(stepScope);
// phaseScope.setLastCompletedStepScope(stepScope); // phaseScope.setLastCompletedStepScope(stepScope);
// } // }
// phaseEnded(phaseScope);
} }


public PartSolver<Solution_> buildPartSolver(DefaultSolverScope<Solution_> solverScope) { public PartitionSolver<Solution_> buildPartitionSolver(DefaultSolverScope<Solution_> solverScope) {
Termination partTermination = termination.createChildThreadTermination(solverScope, ChildThreadType.PART_THREAD); Termination partTermination = termination.createChildThreadTermination(solverScope, ChildThreadType.PART_THREAD);
BestSolutionRecaller<Solution_> bestSolutionRecaller = new BestSolutionRecallerConfig() BestSolutionRecaller<Solution_> bestSolutionRecaller = new BestSolutionRecallerConfig()
.buildBestSolutionRecaller(configPolicy.getEnvironmentMode()); .buildBestSolutionRecaller(configPolicy.getEnvironmentMode());
Expand All @@ -132,8 +132,9 @@ public PartSolver<Solution_> buildPartSolver(DefaultSolverScope<Solution_> solve
phaseList.add(phaseConfig.buildPhase(partPhaseIndex, configPolicy, bestSolutionRecaller, partTermination)); phaseList.add(phaseConfig.buildPhase(partPhaseIndex, configPolicy, bestSolutionRecaller, partTermination));
partPhaseIndex++; partPhaseIndex++;
} }
// TODO create PartitionSolverScope alternative to deal with 3 layer terminations
DefaultSolverScope<Solution_> partSolverScope = solverScope.createChildThreadSolverScope(ChildThreadType.PART_THREAD); DefaultSolverScope<Solution_> partSolverScope = solverScope.createChildThreadSolverScope(ChildThreadType.PART_THREAD);
return new PartSolver<>(partTermination, bestSolutionRecaller, phaseList, partSolverScope); return new PartitionSolver<>(partTermination, bestSolutionRecaller, phaseList, partSolverScope);
} }


// private void doStep(PartitionedSearchStepScope<Solution_> stepScope) { // private void doStep(PartitionedSearchStepScope<Solution_> stepScope) {
Expand Down
Expand Up @@ -32,15 +32,15 @@
/** /**
* @param <Solution_> the solution type, the class with the {@link PlanningSolution} annotation * @param <Solution_> the solution type, the class with the {@link PlanningSolution} annotation
*/ */
public class PartSolver<Solution_> extends AbstractSolver<Solution_> { public class PartitionSolver<Solution_> extends AbstractSolver<Solution_> {


protected final DefaultSolverScope<Solution_> solverScope; protected final DefaultSolverScope<Solution_> solverScope;


// ************************************************************************ // ************************************************************************
// Constructors and simple getters/setters // Constructors and simple getters/setters
// ************************************************************************ // ************************************************************************


public PartSolver(Termination termination, BestSolutionRecaller<Solution_> bestSolutionRecaller, public PartitionSolver(Termination termination, BestSolutionRecaller<Solution_> bestSolutionRecaller,
List<Phase<Solution_>> phaseList, DefaultSolverScope<Solution_> solverScope) { List<Phase<Solution_>> phaseList, DefaultSolverScope<Solution_> solverScope) {
super(termination, bestSolutionRecaller, phaseList); super(termination, bestSolutionRecaller, phaseList);
this.solverScope = solverScope; this.solverScope = solverScope;
Expand Down

0 comments on commit 08d25c6

Please sign in to comment.