Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/05/13 15:21:24 (11 years ago)
Author:
mkommend
Message:

#1997: Added after deserialization hook for reevaluation of immigrants and made the analysis interval for the island GA configureable.

Location:
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r10155 r10197  
    6767      get { return (ValueParameter<IntValue>)Parameters["MigrationInterval"]; }
    6868    }
     69    protected IFixedValueParameter<IntValue> AnalysisIntervalParameter {
     70      get { return (IFixedValueParameter<IntValue>)Parameters["AnalysisInterval"]; }
     71    }
    6972    protected ValueParameter<PercentValue> MigrationRateParameter {
    7073      get { return (ValueParameter<PercentValue>)Parameters["MigrationRate"]; }
     
    130133      get { return MigrationIntervalParameter.Value; }
    131134      set { MigrationIntervalParameter.Value = value; }
     135    }
     136    public int AnalysisInterval {
     137      get { return AnalysisIntervalParameter.Value.Value; }
     138      set { AnalysisIntervalParameter.Value.Value = value; }
    132139    }
    133140    public PercentValue MigrationRate {
     
    218225        Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true });
    219226      }
     227      if (!Parameters.ContainsKey("ReevaluateImmigrants")) {
     228        Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated.", new BoolValue(false)) { Hidden = true });
     229      }
     230      if (!Parameters.ContainsKey("AnalysisInterval")) {
     231        Parameters.Add(new ValueParameter<IntValue>("AnalysisInterval", "The number of generations that should pass between the analyzers should be executed (should be <= MigrationInteval).", new IntValue(20)) { Hidden = true });
     232      }
    220233      #endregion
    221234
     
    238251      Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5)));
    239252      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20)));
     253      Parameters.Add(new ValueParameter<IntValue>("AnalysisInterval", "The number of generations that should pass between the analyzers should be executed (should be <= MigrationInteval).", new IntValue(20)) { Hidden = true });
    240254      Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15)));
    241255      Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs

    r10155 r10197  
    5656      get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
    5757    }
     58    public IValueLookupParameter<IntValue> AnalysisIntervalParameter {
     59      get { return (IValueLookupParameter<IntValue>)Parameters["AnalysisInterval"]; }
     60    }
    5861    public ValueLookupParameter<PercentValue> MigrationRateParameter {
    5962      get { return (ValueLookupParameter<PercentValue>)Parameters["MigrationRate"]; }
     
    115118    public ValueLookupParameter<BoolValue> Migrate {
    116119      get { return (ValueLookupParameter<BoolValue>)Parameters["Migrate"]; }
     120    }
     121    public ILookupParameter<BoolValue> RunAnalysis {
     122      get { return (ILookupParameter<BoolValue>)Parameters["RunAnalysis"]; }
    117123    }
    118124
     
    139145      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfIslands", "The number of islands."));
    140146      Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
     147      Parameters.Add(new ValueLookupParameter<IntValue>("AnalysisInterval", "The number of generations that should pass between the analyzers should be executed (should be <= MigrationInteval)."));
    141148      Parameters.Add(new ValueLookupParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
    142149      Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy."));
     
    159166      Parameters.Add(new LookupParameter<IntValue>("IslandEvaluatedSolutions", "The number of times a solution has been evaluated on one island."));
    160167      Parameters.Add(new ValueLookupParameter<BoolValue>("Migrate", "Migrate the island?"));
     168      Parameters.Add(new LookupParameter<BoolValue>("RunAnalysis", "Run Analyzers?"));
    161169      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated."));
    162170      #endregion
     
    189197      MergingReducer mergingReducer = new MergingReducer();
    190198      IntCounter islandGenerationsCounter = new IntCounter();
     199      IntCounter generationsSinceLastMigrationCounter = new IntCounter();
     200      IntCounter generationsSinceLastAnalysisCounter = new IntCounter();
    191201      Comparator checkIslandGenerationsReachedMaximum = new Comparator();
    192202      ConditionalBranch checkContinueEvolution = new ConditionalBranch();
     203      Assigner resetGenerationsSinceLastMigration = new Assigner();
     204      Comparator checkIslandGenerationsForAnalysis = new Comparator();
     205      ConditionalBranch checkRunAnalysis = new ConditionalBranch();
     206      Assigner resetGenerationsSinceLastAnalysis = new Assigner();
    193207      DataReducer generationsReducer = new DataReducer();
    194208      DataReducer evaluatedSolutionsReducer = new DataReducer();
     209      DataReducer migrationDataReducer = new DataReducer();
     210      ConditionalBranch migrateIndividuals = new ConditionalBranch();
    195211      Placeholder islandAnalyzer2 = new Placeholder();
    196212      UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
     
    211227
    212228      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
    213       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
    214229      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class IslandGeneticAlgorithm expects this to be called Generations
    215230
     
    217232      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandGenerations", new IntValue(0)));
    218233      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));
     234      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandGenerationsSinceLastMigration", new IntValue(0)));
     235      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandGenerationsSinceLastAnalysis", new IntValue(0)));
    219236
    220237      islandAnalyzer1.Name = "Island Analyzer (placeholder)";
     
    271288      islandGenerationsCounter.Increment = new IntValue(1);
    272289
    273       checkIslandGenerationsReachedMaximum.LeftSideParameter.ActualName = IslandGenerations.Name;
     290      generationsSinceLastMigrationCounter.Name = "Increment island generation since last migration";
     291      generationsSinceLastMigrationCounter.ValueParameter.ActualName = "IslandGenerationsSinceLastMigration";
     292      generationsSinceLastMigrationCounter.Increment = new IntValue(1);
     293
     294      generationsSinceLastAnalysisCounter.Name = "Increment island generation since last analysis";
     295      generationsSinceLastAnalysisCounter.ValueParameter.ActualName = "IslandGenerationsSinceLastAnalysis";
     296      generationsSinceLastAnalysisCounter.Increment = new IntValue(1);
     297
     298      checkIslandGenerationsReachedMaximum.LeftSideParameter.ActualName = "IslandGenerationsSinceLastMigration";
    274299      checkIslandGenerationsReachedMaximum.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
    275300      checkIslandGenerationsReachedMaximum.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
    276301      checkIslandGenerationsReachedMaximum.ResultParameter.ActualName = Migrate.Name;
    277302
     303      resetGenerationsSinceLastMigration.Name = "Reset generations since last migration";
     304      resetGenerationsSinceLastMigration.LeftSideParameter.ActualName = "IslandGenerationsSinceLastMigration";
     305      resetGenerationsSinceLastMigration.RightSideParameter.Value = new IntValue(0);
     306      resetGenerationsSinceLastMigration.Successor = resetGenerationsSinceLastAnalysis;
     307
    278308      checkContinueEvolution.Name = "Migrate?";
    279309      checkContinueEvolution.ConditionParameter.ActualName = Migrate.Name;
    280       checkContinueEvolution.FalseBranch = selector;
     310      checkContinueEvolution.TrueBranch = resetGenerationsSinceLastMigration;
     311      checkContinueEvolution.FalseBranch = checkIslandGenerationsForAnalysis;
     312
     313      checkIslandGenerationsForAnalysis.LeftSideParameter.ActualName = "IslandGenerationsSinceLastAnalysis";
     314      checkIslandGenerationsForAnalysis.RightSideParameter.ActualName = AnalysisIntervalParameter.Name;
     315      checkIslandGenerationsForAnalysis.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     316      checkIslandGenerationsForAnalysis.ResultParameter.ActualName = RunAnalysis.Name;
     317
     318      resetGenerationsSinceLastAnalysis.Name = "Reset generations since last analysis";
     319      resetGenerationsSinceLastAnalysis.LeftSideParameter.ActualName = "IslandGenerationsSinceLastAnalysis";
     320      resetGenerationsSinceLastAnalysis.RightSideParameter.Value = new IntValue(0);
     321
     322      checkRunAnalysis.Name = "Run Analyzers?";
     323      checkRunAnalysis.ConditionParameter.ActualName = RunAnalysis.Name;
     324      checkRunAnalysis.TrueBranch = resetGenerationsSinceLastAnalysis;
     325      checkRunAnalysis.FalseBranch = selector;
    281326
    282327      islandAnalyzer2.Name = "Island Analyzer (placeholder)";
     
    294339      evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
    295340      evaluatedSolutionsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     341
     342      migrationDataReducer.Name = "Collect Migration Flags";
     343      migrationDataReducer.ParameterToReduce.ActualName = Migrate.Name;
     344      migrationDataReducer.TargetParameter.ActualName = Migrate.Name;
     345      migrationDataReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.All);
     346      migrationDataReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
     347
     348      migrateIndividuals.Name = "Migrate?";
     349      migrateIndividuals.ConditionParameter.ActualName = Migrate.Name;
    296350
    297351      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
     
    354408      uniformSubScopesProcessor1.Successor = generationsReducer;
    355409      generationsReducer.Successor = evaluatedSolutionsReducer;
    356       evaluatedSolutionsReducer.Successor = migrationsCounter;
     410      evaluatedSolutionsReducer.Successor = migrationDataReducer;
     411      migrationDataReducer.Successor = migrateIndividuals;
     412      migrateIndividuals.TrueBranch = migrationsCounter;
     413      migrateIndividuals.FalseBranch = generationsComparator;
    357414      migrationsCounter.Successor = uniformSubScopesProcessor5;
    358415      generationsAssigner.Successor = evaluatedSolutionsAssigner;
     
    385442      reevaluateElitesBranch.Successor = null;
    386443      islandAnalyzer2.Successor = islandGenerationsCounter;
    387       islandGenerationsCounter.Successor = checkIslandGenerationsReachedMaximum;
     444      islandGenerationsCounter.Successor = generationsSinceLastMigrationCounter;
     445      generationsSinceLastMigrationCounter.Successor = generationsSinceLastAnalysisCounter;
     446      generationsSinceLastAnalysisCounter.Successor = checkIslandGenerationsReachedMaximum;
    388447      checkIslandGenerationsReachedMaximum.Successor = checkContinueEvolution;
     448      checkContinueEvolution.FalseBranch = checkIslandGenerationsForAnalysis;
     449      checkIslandGenerationsForAnalysis.Successor = checkRunAnalysis;
    389450      uniformSubScopesProcessor5.Operator = emigrantsSelector;
    390451      emigrantsSelector.Successor = null;
Note: See TracChangeset for help on using the changeset viewer.