Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9039 for trunk


Ignore:
Timestamp:
12/12/12 13:46:18 (12 years ago)
Author:
mkommend
Message:

#1996: Adapted IslandGA to created local RNG outside of the main loop.

Location:
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r8255 r9039  
    181181    }
    182182    private UniformSubScopesProcessor IslandProcessor {
    183       get { return ((RandomCreator.Successor as SubScopesCreator).Successor as UniformSubScopesProcessor); }
     183      get { return OperatorGraph.Iterate().OfType<UniformSubScopesProcessor>().First(x => x.Operator is SolutionsCreator); }
    184184    }
    185185    private SolutionsCreator SolutionsCreator {
     
    232232
    233233      RandomCreator randomCreator = new RandomCreator();
     234      UniformSubScopesProcessor ussp0 = new UniformSubScopesProcessor();
     235      LocalRandomCreator localRandomCreator = new LocalRandomCreator();
     236      RandomCreator globalRandomResetter = new RandomCreator();
    234237      SubScopesCreator populationCreator = new SubScopesCreator();
    235238      UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
     
    250253
    251254      populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name;
    252       populationCreator.Successor = ussp1;
     255      populationCreator.Successor = ussp0;
     256
     257      ussp0.Operator = localRandomCreator;
     258      ussp0.Successor = globalRandomResetter;
     259
     260      // BackwardsCompatibility3.3
     261      // the global random is resetted to ensure the same algorithm results
     262      #region Backwards compatible code, remove with 3.4
     263      globalRandomResetter.RandomParameter.ActualName = "GlobalRandom";
     264      globalRandomResetter.SeedParameter.ActualName = SeedParameter.Name;
     265      globalRandomResetter.SeedParameter.Value = null;
     266      globalRandomResetter.SetSeedRandomlyParameter.Value = new BoolValue(false);
     267      globalRandomResetter.Successor = ussp1;
     268      #endregion
    253269
    254270      ussp1.Operator = solutionsCreator;
     
    325341    protected override void OnProblemChanged() {
    326342      ParameterizeStochasticOperator(Problem.SolutionCreator);
    327       ParameterizeStochasticOperator(Problem.Evaluator);
     343      ParameterizeStochasticOperatorForIsland(Problem.Evaluator);
    328344      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
    329345      ParameterizeSolutionsCreator();
     
    345361    }
    346362    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
    347       ParameterizeStochasticOperator(Problem.Evaluator);
     363      ParameterizeStochasticOperatorForIsland(Problem.Evaluator);
    348364      ParameterizeSolutionsCreator();
    349365      ParameterizeMainLoop();
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs

    r7395 r9039  
    313313      uniformSubScopesProcessor0.Successor = analyzer1;
    314314      islandVariableCreator.Successor = islandAnalyzer1;
     315      // BackwardsCompatibility3.3
     316      //the local randoms are created by the island GA itself and are only here to ensure same algorithm results
     317      #region Backwards compatible code, remove with 3.4
    315318      islandAnalyzer1.Successor = localRandomCreator;
    316319      localRandomCreator.Successor = null;
     320      #endregion
    317321      analyzer1.Successor = resultsCollector1;
    318322      resultsCollector1.Successor = uniformSubScopesProcessor1;
Note: See TracChangeset for help on using the changeset viewer.