Example #1
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);
 }
Example #2
0
 private void doMove(MoveScope moveScope) {
   WorkingMemory workingMemory = moveScope.getWorkingMemory();
   Move move = moveScope.getMove();
   Move undoMove = move.createUndoMove(workingMemory);
   moveScope.setUndoMove(undoMove);
   move.doMove(workingMemory);
   processMove(moveScope);
   undoMove.doMove(workingMemory);
   if (assertUndoMoveIsUncorrupted) {
     Score undoScore =
         moveScope
             .getLocalSearchStepScope()
             .getLocalSearchSolverPhaseScope()
             .calculateScoreFromWorkingMemory();
     Score lastCompletedStepScore =
         moveScope
             .getLocalSearchStepScope()
             .getLocalSearchSolverPhaseScope()
             .getLastCompletedLocalSearchStepScope()
             .getScore();
     if (!undoScore.equals(lastCompletedStepScore)) {
       throw new IllegalStateException(
           "Corrupted undo move ("
               + undoMove
               + ") received from move ("
               + move
               + ").\n"
               + "Unequal lastCompletedStepScore ("
               + lastCompletedStepScore
               + ") and undoScore ("
               + undoScore
               + ").\n"
               + moveScope
                   .getLocalSearchStepScope()
                   .getLocalSearchSolverPhaseScope()
                   .getSolverScope()
                   .getSolutionDirector()
                   .buildConstraintOccurrenceSummary());
     }
   }
   logger.debug(
       "    Move score ({}), accept chance ({}) for move ({}).",
       new Object[] {moveScope.getScore(), moveScope.getAcceptChance(), moveScope.getMove()});
 }