Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7395 for trunk/sources


Ignore:
Timestamp:
01/22/12 23:17:01 (13 years ago)
Author:
ascheibe
Message:

#1745 moved new Island GA to trunk

Location:
trunk/sources
Files:
6 added
4 edited

Legend:

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

    r7259 r7395  
    242242      OperatorGraph.InitialOperator = randomCreator;
    243243
    244       randomCreator.RandomParameter.ActualName = "Random";
     244      randomCreator.RandomParameter.ActualName = "GlobalRandom";
    245245      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
    246246      randomCreator.SeedParameter.Value = null;
     
    256256
    257257      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
     258      //don't create solutions in parallel because the hive engine would distribute these tasks
     259      solutionsCreator.ParallelParameter.Value = new BoolValue(false);
    258260      solutionsCreator.Successor = null;
    259261
     
    416418      }
    417419    }
     420    private void ParameterizeStochasticOperatorForIsland(IOperator op) {
     421      IStochasticOperator stochasticOp = op as IStochasticOperator;
     422      if (stochasticOp != null) {
     423        stochasticOp.RandomParameter.ActualName = "LocalRandom";
     424        stochasticOp.RandomParameter.Hidden = true;
     425      }
     426    }
    418427    private void ParameterizeSelectors() {
    419428      foreach (ISelector selector in SelectorParameter.ValidValues) {
     
    421430        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSize.Value - Elites.Value));
    422431        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
    423         ParameterizeStochasticOperator(selector);
     432        ParameterizeStochasticOperatorForIsland(selector);
    424433      }
    425434      foreach (ISelector selector in EmigrantsSelectorParameter.ValidValues) {
     
    489498      ICrossover oldCrossover = CrossoverParameter.Value;
    490499      CrossoverParameter.ValidValues.Clear();
    491       foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
     500      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) {
     501        ParameterizeStochasticOperatorForIsland(crossover);
    492502        CrossoverParameter.ValidValues.Add(crossover);
     503      }
    493504      if (oldCrossover != null) {
    494505        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
     
    499510      IManipulator oldMutator = MutatorParameter.Value;
    500511      MutatorParameter.ValidValues.Clear();
    501       foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
     512      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) {
     513        ParameterizeStochasticOperatorForIsland(mutator);
    502514        MutatorParameter.ValidValues.Add(mutator);
     515      }
    503516      if (oldMutator != null) {
    504517        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs

    r7259 r7395  
    104104      get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
    105105    }
     106    public LookupParameter<IntValue> IslandGenerations {
     107      get { return (LookupParameter<IntValue>)Parameters["IslandGenerations"]; }
     108    }
     109    public LookupParameter<IntValue> IslandEvaluatedSolutions {
     110      get { return (LookupParameter<IntValue>)Parameters["IslandEvaluatedSolutions"]; }
     111    }
     112    public ValueLookupParameter<BoolValue> Migrate {
     113      get { return (ValueLookupParameter<BoolValue>)Parameters["Migrate"]; }
     114    }
    106115    #endregion
    107116
     
    133142      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
    134143      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
    135       Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
     144      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
    136145      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
    137146      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
     
    139148      Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
    140149      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times a solution has been evaluated."));
     150      Parameters.Add(new LookupParameter<IntValue>("IslandGenerations", "The number of generations calculated on one island."));
     151      Parameters.Add(new LookupParameter<IntValue>("IslandEvaluatedSolutions", "The number of times a solution has been evaluated on one island."));
     152      Parameters.Add(new ValueLookupParameter<BoolValue>("Migrate", "Migrate the island?"));
    141153      #endregion
    142154
     
    146158      VariableCreator islandVariableCreator = new VariableCreator();
    147159      Placeholder islandAnalyzer1 = new Placeholder();
     160      LocalRandomCreator localRandomCreator = new LocalRandomCreator();
    148161      Placeholder analyzer1 = new Placeholder();
    149162      ResultsCollector resultsCollector1 = new ResultsCollector();
    150163      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
     164      Assigner generationsAssigner = new Assigner();
     165      Assigner evaluatedSolutionsAssigner = new Assigner();
    151166      Placeholder selector = new Placeholder();
    152167      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
     
    164179      RightReducer rightReducer = new RightReducer();
    165180      MergingReducer mergingReducer = new MergingReducer();
    166       IntCounter generationsCounter = new IntCounter();
    167       UniformSubScopesProcessor uniformSubScopesProcessor4 = new UniformSubScopesProcessor();
     181      IntCounter islandGenerationsCounter = new IntCounter();
     182      Comparator checkIslandGenerationsReachedMaximum = new Comparator();
     183      ConditionalBranch checkContinueEvolution = new ConditionalBranch();
     184      DataReducer generationsReducer = new DataReducer();
     185      DataReducer evaluatedSolutionsReducer = new DataReducer();
    168186      Placeholder islandAnalyzer2 = new Placeholder();
    169       IntCounter generationsSinceLastMigrationCounter = new IntCounter();
    170       Comparator migrationComparator = new Comparator();
    171       ConditionalBranch migrationBranch = new ConditionalBranch();
    172       Assigner resetGenerationsSinceLastMigrationAssigner = new Assigner();
    173       IntCounter migrationsCounter = new IntCounter();
    174187      UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
    175188      Placeholder emigrantsSelector = new Placeholder();
     189      IntCounter migrationsCounter = new IntCounter();
    176190      Placeholder migrator = new Placeholder();
    177191      UniformSubScopesProcessor uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
     
    181195      ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
    182196
     197
    183198      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
    184199      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
     
    186201
    187202      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
     203      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandGenerations", new IntValue(0)));
     204      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));
    188205
    189206      islandAnalyzer1.Name = "Island Analyzer (placeholder)";
     
    198215      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
    199216
     217      uniformSubScopesProcessor1.Parallel.Value = true;
     218
     219      generationsAssigner.Name = "Initialize Island Generations";
     220      generationsAssigner.LeftSideParameter.ActualName = IslandGenerations.Name;
     221      generationsAssigner.RightSideParameter.Value = new IntValue(0);
     222
     223      evaluatedSolutionsAssigner.Name = "Initialize Island evaluated solutions";
     224      evaluatedSolutionsAssigner.LeftSideParameter.ActualName = IslandEvaluatedSolutions.Name;
     225      evaluatedSolutionsAssigner.RightSideParameter.Value = new IntValue(0);
     226
    200227      selector.Name = "Selector (placeholder)";
    201228      selector.OperatorParameter.ActualName = SelectorParameter.Name;
     
    207234
    208235      stochasticBranch.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
    209       stochasticBranch.RandomParameter.ActualName = RandomParameter.Name;
     236      //set it to the random number generator of the island
     237      stochasticBranch.RandomParameter.ActualName = "LocalRandom";
    210238
    211239      mutator.Name = "Mutator (placeholder)";
     
    214242      subScopesRemover.RemoveAllSubScopes = true;
    215243
    216       uniformSubScopesProcessor3.Parallel.Value = true;
    217 
    218244      evaluator.Name = "Evaluator (placeholder)";
    219245      evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
    220246
    221247      subScopesCounter.Name = "Increment EvaluatedSolutions";
    222       subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     248      subScopesCounter.ValueParameter.ActualName = IslandEvaluatedSolutions.Name;
    223249
    224250      bestSelector.CopySelected = new BoolValue(false);
     
    227253      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
    228254
     255      islandGenerationsCounter.Name = "Increment island generatrions";
     256      islandGenerationsCounter.ValueParameter.ActualName = IslandGenerations.Name;
     257      islandGenerationsCounter.Increment = new IntValue(1);
     258
     259      checkIslandGenerationsReachedMaximum.LeftSideParameter.ActualName = IslandGenerations.Name;
     260      checkIslandGenerationsReachedMaximum.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
     261      checkIslandGenerationsReachedMaximum.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     262      checkIslandGenerationsReachedMaximum.ResultParameter.ActualName = Migrate.Name;
     263
     264      checkContinueEvolution.Name = "Migrate?";
     265      checkContinueEvolution.ConditionParameter.ActualName = Migrate.Name;
     266      checkContinueEvolution.FalseBranch = selector;
     267
    229268      islandAnalyzer2.Name = "Island Analyzer (placeholder)";
    230269      islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
    231270
    232       generationsCounter.Name = "Generations + 1";
    233       generationsCounter.Increment = new IntValue(1);
    234       generationsCounter.ValueParameter.ActualName = "Generations";
    235 
    236       generationsSinceLastMigrationCounter.Name = "GenerationsSinceLastMigration + 1";
    237       generationsSinceLastMigrationCounter.ValueParameter.ActualName = "GenerationsSinceLastMigration";
    238       generationsSinceLastMigrationCounter.Increment = new IntValue(1);
    239 
    240       migrationComparator.Name = "GenerationsSinceLastMigration = MigrationInterval ?";
    241       migrationComparator.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
    242       migrationComparator.Comparison = new Comparison(ComparisonType.Equal);
    243       migrationComparator.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
    244       migrationComparator.ResultParameter.ActualName = "Migrate";
    245 
    246       migrationBranch.Name = "Migrate?";
    247       migrationBranch.ConditionParameter.ActualName = "Migrate";
    248 
    249       resetGenerationsSinceLastMigrationAssigner.Name = "Reset GenerationsSinceLastMigration";
    250       resetGenerationsSinceLastMigrationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
    251       resetGenerationsSinceLastMigrationAssigner.RightSideParameter.Value = new IntValue(0);
    252 
    253       migrationsCounter.Name = "Migrations + 1";
    254       migrationsCounter.IncrementParameter.Value = new IntValue(1);
    255       migrationsCounter.ValueParameter.ActualName = "Migrations";
     271      generationsReducer.Name = "Increment Generations";
     272      generationsReducer.ParameterToReduce.ActualName = islandGenerationsCounter.ValueParameter.ActualName;
     273      generationsReducer.TargetParameter.ActualName = "Generations";
     274      generationsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Min);
     275      generationsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     276
     277      evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions";
     278      evaluatedSolutionsReducer.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
     279      evaluatedSolutionsReducer.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
     280      evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     281      evaluatedSolutionsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
    256282
    257283      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
    258284      emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
     285
     286      migrationsCounter.Name = "Increment number of Migrations";
     287      migrationsCounter.ValueParameter.ActualName = "Migrations";
     288      migrationsCounter.Increment = new IntValue(1);
    259289
    260290      migrator.Name = "Migrator (placeholder)";
     
    283313      uniformSubScopesProcessor0.Successor = analyzer1;
    284314      islandVariableCreator.Successor = islandAnalyzer1;
    285       islandAnalyzer1.Successor = null;
     315      islandAnalyzer1.Successor = localRandomCreator;
     316      localRandomCreator.Successor = null;
    286317      analyzer1.Successor = resultsCollector1;
    287318      resultsCollector1.Successor = uniformSubScopesProcessor1;
    288       uniformSubScopesProcessor1.Operator = selector;
    289       uniformSubScopesProcessor1.Successor = generationsCounter;
     319      uniformSubScopesProcessor1.Operator = generationsAssigner;
     320      uniformSubScopesProcessor1.Successor = generationsReducer;
     321      generationsReducer.Successor = evaluatedSolutionsReducer;
     322      evaluatedSolutionsReducer.Successor = migrationsCounter;
     323      migrationsCounter.Successor = uniformSubScopesProcessor5;
     324      generationsAssigner.Successor = evaluatedSolutionsAssigner;
     325      evaluatedSolutionsAssigner.Successor = selector;
    290326      selector.Successor = subScopesProcessor1;
    291327      subScopesProcessor1.Operators.Add(new EmptyOperator());
     
    305341      evaluator.Successor = null;
    306342      subScopesCounter.Successor = null;
     343      subScopesCounter.Successor = null;
    307344      subScopesProcessor2.Operators.Add(bestSelector);
    308345      subScopesProcessor2.Operators.Add(new EmptyOperator());
    309346      subScopesProcessor2.Successor = mergingReducer;
     347      mergingReducer.Successor = islandAnalyzer2;
    310348      bestSelector.Successor = rightReducer;
    311349      rightReducer.Successor = null;
    312       mergingReducer.Successor = null;
    313       generationsCounter.Successor = uniformSubScopesProcessor4;
    314       uniformSubScopesProcessor4.Operator = islandAnalyzer2;
    315       uniformSubScopesProcessor4.Successor = generationsSinceLastMigrationCounter;
    316       islandAnalyzer2.Successor = null;
    317       generationsSinceLastMigrationCounter.Successor = migrationComparator;
    318       migrationComparator.Successor = migrationBranch;
    319       migrationBranch.TrueBranch = resetGenerationsSinceLastMigrationAssigner;
    320       migrationBranch.FalseBranch = null;
    321       migrationBranch.Successor = generationsComparator;
    322       resetGenerationsSinceLastMigrationAssigner.Successor = migrationsCounter;
    323       migrationsCounter.Successor = uniformSubScopesProcessor5;
     350      islandAnalyzer2.Successor = islandGenerationsCounter;
     351      islandGenerationsCounter.Successor = checkIslandGenerationsReachedMaximum;
     352      checkIslandGenerationsReachedMaximum.Successor = checkContinueEvolution;
    324353      uniformSubScopesProcessor5.Operator = emigrantsSelector;
     354      emigrantsSelector.Successor = null;
    325355      uniformSubScopesProcessor5.Successor = migrator;
    326356      migrator.Successor = uniformSubScopesProcessor6;
    327357      uniformSubScopesProcessor6.Operator = immigrationReplacer;
    328       uniformSubScopesProcessor6.Successor = null;
     358      uniformSubScopesProcessor6.Successor = generationsComparator;
    329359      generationsComparator.Successor = analyzer2;
    330360      analyzer2.Successor = generationsTerminationCondition;
  • trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj

    r6866 r7395  
    142142    </Compile>
    143143    <Compile Include="Plugin.cs" />
     144    <Compile Include="ReductionOperationView.cs">
     145      <SubType>UserControl</SubType>
     146    </Compile>
     147    <Compile Include="ReductionOperationView.Designer.cs">
     148      <DependentUpon>ReductionOperationView.cs</DependentUpon>
     149    </Compile>
    144150    <Compile Include="ValuesCollectorView.cs">
    145151      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r6866 r7395  
    118118    <Compile Include="Assigner.cs" />
    119119    <Compile Include="AlgorithmOperator.cs" />
     120    <Compile Include="DataReducer.cs" />
     121    <Compile Include="LocalRandomCreator.cs" />
    120122    <Compile Include="MultiOperator.cs" />
    121123    <Compile Include="Operator.cs" />
     
    123125    <Compile Include="IntCounter.cs" />
    124126    <Compile Include="Plugin.cs" />
     127    <Compile Include="ReductionOperation.cs" />
     128    <Compile Include="ReductionOperations.cs" />
    125129    <Compile Include="ScopeCleaner.cs" />
    126130    <Compile Include="StochasticBranch.cs" />
Note: See TracChangeset for help on using the changeset viewer.