コード例 #1
0
 private LocalSearchDecider buildDecider(
     HeuristicConfigPolicy configPolicy, Termination termination) {
   LocalSearchDecider decider = new LocalSearchDecider();
   decider.setTermination(termination);
   MoveSelector moveSelector = buildMoveSelector(configPolicy);
   decider.setMoveSelector(moveSelector);
   AcceptorConfig acceptorConfig_ = acceptorConfig == null ? new AcceptorConfig() : acceptorConfig;
   decider.setAcceptor(acceptorConfig_.buildAcceptor(configPolicy));
   ForagerConfig foragerConfig_ = foragerConfig == null ? new ForagerConfig() : foragerConfig;
   Forager forager = foragerConfig_.buildForager(configPolicy);
   decider.setForager(forager);
   if (moveSelector.isNeverEnding() && !forager.supportsNeverEndingMoveSelector()) {
     throw new IllegalStateException(
         "The moveSelector ("
             + moveSelector
             + ") has neverEnding ("
             + moveSelector.isNeverEnding()
             + "), but the forager ("
             + forager
             + ") does not support it."
             + " Configure the <forager> with <acceptedCountLimit>.");
   }
   EnvironmentMode environmentMode = configPolicy.getEnvironmentMode();
   if (environmentMode.isNonIntrusiveFullAsserted()) {
     decider.setAssertMoveScoreFromScratch(true);
   }
   if (environmentMode.isIntrusiveFastAsserted()) {
     decider.setAssertExpectedUndoMoveScore(true);
   }
   return decider;
 }
コード例 #2
0
  @Parameterized.Parameters(name = "AcceptorType: {0}")
  public static Collection<Object[]> parameters() {
    Collection<Object[]> params = new ArrayList<Object[]>();

    AcceptorConfig acceptorConfig = new AcceptorConfig();
    LocalSearchForagerConfig localSearchForagerConfig = new LocalSearchForagerConfig();
    localSearchForagerConfig.setAcceptedCountLimit(N * N);
    acceptorConfig.setAcceptorTypeList(Arrays.asList(AcceptorType.HILL_CLIMBING));
    params.add(
        new Object[] {
          acceptorConfig,
          localSearchForagerConfig,
          Arrays.asList(
              new NQueensStepTracking(1, 5),
              new NQueensStepTracking(0, 1),
              new NQueensStepTracking(4, 3),
              new NQueensStepTracking(2, 2),
              new NQueensStepTracking(3, 5),
              new NQueensStepTracking(1, 4),
              new NQueensStepTracking(1, 5),
              new NQueensStepTracking(1, 4),
              new NQueensStepTracking(1, 5))
        });
    acceptorConfig = new AcceptorConfig();
    acceptorConfig.setAcceptorTypeList(Arrays.asList(AcceptorType.ENTITY_TABU));
    acceptorConfig.setEntityTabuSize(N - 1);
    localSearchForagerConfig = new LocalSearchForagerConfig();
    localSearchForagerConfig.setAcceptedCountLimit(N * N);
    params.add(
        new Object[] {
          acceptorConfig,
          localSearchForagerConfig,
          Arrays.asList(
              new NQueensStepTracking(1, 5),
              new NQueensStepTracking(0, 1),
              new NQueensStepTracking(4, 3),
              new NQueensStepTracking(2, 2),
              new NQueensStepTracking(3, 5),
              new NQueensStepTracking(5, 4),
              new NQueensStepTracking(1, 4),
              new NQueensStepTracking(0, 0),
              new NQueensStepTracking(4, 1))
        });
    acceptorConfig = new AcceptorConfig();
    acceptorConfig.setAcceptorTypeList(Arrays.asList(AcceptorType.LATE_ACCEPTANCE));
    acceptorConfig.setLateAcceptanceSize(1);
    localSearchForagerConfig = new LocalSearchForagerConfig();
    localSearchForagerConfig.setAcceptedCountLimit(1);
    params.add(
        new Object[] {
          acceptorConfig,
          localSearchForagerConfig,
          Arrays.asList(
              new NQueensStepTracking(0, 1),
                  new NQueensStepTracking(0, 2), // (0, 0) is rejected due to high score
              new NQueensStepTracking(0, 1), new NQueensStepTracking(0, 2),
              new NQueensStepTracking(0, 1), new NQueensStepTracking(0, 2))
        });
    return params;
  }
コード例 #3
0
 public void inherit(LocalSearchSolverPhaseConfig inheritedConfig) {
   super.inherit(inheritedConfig);
   moveSelectorConfigList =
       ConfigUtils.inheritMergeableListProperty(
           moveSelectorConfigList, inheritedConfig.getMoveSelectorConfigList());
   if (acceptorConfig == null) {
     acceptorConfig = inheritedConfig.getAcceptorConfig();
   } else if (inheritedConfig.getAcceptorConfig() != null) {
     acceptorConfig.inherit(inheritedConfig.getAcceptorConfig());
   }
   if (foragerConfig == null) {
     foragerConfig = inheritedConfig.getForagerConfig();
   } else if (inheritedConfig.getForagerConfig() != null) {
     foragerConfig.inherit(inheritedConfig.getForagerConfig());
   }
 }