Пример #1
0
 public void decideNextStep(LocalSearchStepScope localSearchStepScope) {
   WorkingMemory workingMemory = localSearchStepScope.getWorkingMemory();
   Iterator<Move> moveIterator = selector.moveIterator(localSearchStepScope);
   while (moveIterator.hasNext()) {
     Move move = moveIterator.next();
     MoveScope moveScope = new MoveScope(localSearchStepScope);
     moveScope.setMove(move);
     // Filter out not doable moves
     if (move.isMoveDoable(workingMemory)) {
       doMove(moveScope);
       if (forager.isQuitEarly()) {
         break;
       }
     } else {
       logger.debug("    Ignoring not doable move ({}).", move);
     }
   }
   MoveScope pickedMoveScope = forager.pickMove(localSearchStepScope);
   if (pickedMoveScope != null) {
     Move step = pickedMoveScope.getMove();
     localSearchStepScope.setStep(step);
     if (logger.isInfoEnabled()) {
       localSearchStepScope.setStepString(step.toString());
     }
     localSearchStepScope.setUndoStep(step.createUndoMove(workingMemory));
     localSearchStepScope.setScore(pickedMoveScope.getScore());
   }
 }
Пример #2
0
 public void beforeDeciding(LocalSearchStepScope localSearchStepScope) {
   deciderScoreComparatorFactory.beforeDeciding(localSearchStepScope);
   localSearchStepScope.setDeciderScoreComparator(
       deciderScoreComparatorFactory.createDeciderScoreComparator());
   selector.beforeDeciding(localSearchStepScope);
   acceptor.beforeDeciding(localSearchStepScope);
   forager.beforeDeciding(localSearchStepScope);
 }
Пример #3
0
 private void processMove(MoveScope moveScope) {
   Score score =
       moveScope
           .getLocalSearchStepScope()
           .getLocalSearchSolverPhaseScope()
           .calculateScoreFromWorkingMemory();
   if (assertMoveScoreIsUncorrupted) {
     moveScope
         .getLocalSearchStepScope()
         .getLocalSearchSolverPhaseScope()
         .assertWorkingScore(score);
   }
   moveScope.setScore(score);
   double acceptChance = acceptor.calculateAcceptChance(moveScope);
   moveScope.setAcceptChance(acceptChance);
   forager.addMove(moveScope);
 }
Пример #4
0
 public void phaseStarted(LocalSearchSolverPhaseScope localSearchSolverPhaseScope) {
   deciderScoreComparatorFactory.phaseStarted(localSearchSolverPhaseScope);
   selector.phaseStarted(localSearchSolverPhaseScope);
   acceptor.phaseStarted(localSearchSolverPhaseScope);
   forager.phaseStarted(localSearchSolverPhaseScope);
 }
Пример #5
0
 public void stepTaken(LocalSearchStepScope localSearchStepScope) {
   deciderScoreComparatorFactory.stepTaken(localSearchStepScope);
   selector.stepTaken(localSearchStepScope);
   acceptor.stepTaken(localSearchStepScope);
   forager.stepTaken(localSearchStepScope);
 }