コード例 #1
0
  public void solve(DefaultSolverScope solverScope) {
    BruteForceSolverPhaseScope bruteForceSolverPhaseScope =
        new BruteForceSolverPhaseScope(solverScope);
    phaseStarted(bruteForceSolverPhaseScope);

    BruteForceStepScope bruteForceStepScope = createNextStepScope(bruteForceSolverPhaseScope, null);
    while (!termination.isPhaseTerminated(bruteForceSolverPhaseScope)
        && bruteForceEntityWalker.hasWalk()) {
      bruteForceEntityWalker.walk();
      Score score = bruteForceSolverPhaseScope.calculateScoreFromWorkingMemory();
      bruteForceStepScope.setScore(score);
      stepTaken(bruteForceStepScope);
      bruteForceStepScope = createNextStepScope(bruteForceSolverPhaseScope, bruteForceStepScope);
    }
    phaseEnded(bruteForceSolverPhaseScope);
  }
コード例 #2
0
 public void stepTaken(BruteForceStepScope bruteForceStepScope) {
   super.stepTaken(bruteForceStepScope);
   bruteForceEntityWalker.stepTaken(bruteForceStepScope);
   BruteForceSolverPhaseScope bruteForceSolverPhaseScope =
       bruteForceStepScope.getBruteForceSolverPhaseScope();
   // TODO The steps are too fine, so debug log is too much. Yet we still want some debug
   // indication
   logger.debug(
       "    Step index ({}), time spend ({}), score ({}), {} best score ({}).",
       new Object[] {
         bruteForceStepScope.getStepIndex(),
         bruteForceSolverPhaseScope.calculateSolverTimeMillisSpend(),
         bruteForceStepScope.getScore(),
         (bruteForceStepScope.getBestScoreImproved() ? "new" : "   "),
         bruteForceSolverPhaseScope.getBestScore()
       });
 }
コード例 #3
0
 private BruteForceStepScope createNextStepScope(
     BruteForceSolverPhaseScope bruteForceSolverPhaseScope,
     BruteForceStepScope completedBruteForceStepScope) {
   if (completedBruteForceStepScope == null) {
     completedBruteForceStepScope = new BruteForceStepScope(bruteForceSolverPhaseScope);
     completedBruteForceStepScope.setScore(bruteForceSolverPhaseScope.getStartingScore());
     completedBruteForceStepScope.setStepIndex(-1);
   }
   bruteForceSolverPhaseScope.setLastCompletedBruteForceStepScope(completedBruteForceStepScope);
   BruteForceStepScope bruteForceStepScope = new BruteForceStepScope(bruteForceSolverPhaseScope);
   bruteForceStepScope.setStepIndex(completedBruteForceStepScope.getStepIndex() + 1);
   bruteForceStepScope.setSolutionInitialized(true);
   return bruteForceStepScope;
 }