Changeset 10155


Ignore:
Timestamp:
11/26/13 09:45:11 (9 years ago)
Author:
mkommend
Message:

#1997: Added possibility to reevaluate immigrants to the IslandGA and IslandOSGA.

Location:
branches/DataAnalysis.IslandAlgorithms
Files:
4 edited

Legend:

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

    r10142 r10155  
    109109      get { return (ValueParameter<MultiAnalyzer>)Parameters["IslandAnalyzer"]; }
    110110    }
     111    protected IFixedValueParameter<BoolValue> ReevaluateImmigrantsParameter {
     112      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateImmigrants"]; }
     113    }
    111114    #endregion
    112115
     
    183186      get { return IslandAnalyzerParameter.Value; }
    184187      set { IslandAnalyzerParameter.Value = value; }
     188    }
     189    public bool ReevaluateImmigrants {
     190      get { return ReevaluateImmigrantsParameter.Value.Value; }
     191      set { ReevaluateImmigrantsParameter.Value.Value = value; }
    185192    }
    186193    protected RandomCreator RandomCreator {
     
    245252      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
    246253      Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
     254      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated.", new BoolValue(false)) { Hidden = true });
    247255
    248256      RandomCreator randomCreator = new RandomCreator();
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs

    r9756 r10155  
    115115    public ValueLookupParameter<BoolValue> Migrate {
    116116      get { return (ValueLookupParameter<BoolValue>)Parameters["Migrate"]; }
     117    }
     118
     119    public ValueLookupParameter<BoolValue> ReevaluateImmigrants {
     120      get { return (ValueLookupParameter<BoolValue>)Parameters["ReevaluateImmigrants"]; }
    117121    }
    118122    #endregion
     
    155159      Parameters.Add(new LookupParameter<IntValue>("IslandEvaluatedSolutions", "The number of times a solution has been evaluated on one island."));
    156160      Parameters.Add(new ValueLookupParameter<BoolValue>("Migrate", "Migrate the island?"));
     161      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated."));
    157162      #endregion
    158163
     
    193198      IntCounter migrationsCounter = new IntCounter();
    194199      Placeholder migrator = new Placeholder();
     200      ConditionalBranch reevaluateImmigrantsBranch = new ConditionalBranch();
     201      Assigner evaluatedSolutionsAssigner2 = new Assigner();
    195202      UniformSubScopesProcessor uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
     203      SubScopesProcessor subScopesProcessor3 = new SubScopesProcessor();
     204      DataReducer evaluatedSolutionsReducer2 = new DataReducer();
     205      UniformSubScopesProcessor uniformSubScopesProcessor7 = new UniformSubScopesProcessor();
    196206      Placeholder immigrationReplacer = new Placeholder();
    197207      Comparator generationsComparator = new Comparator();
     
    200210      ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
    201211
    202 
    203212      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
    204213      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
     
    295304      migrator.Name = "Migrator (placeholder)";
    296305      migrator.OperatorParameter.ActualName = MigratorParameter.Name;
     306
     307      reevaluateImmigrantsBranch.ConditionParameter.ActualName = "ReevaluateImmigrants";
     308      reevaluateImmigrantsBranch.Name = "Reevaluate Immigrants ?";
     309
     310      evaluatedSolutionsAssigner2.Name = "Reset Island evaluated solutions";
     311      evaluatedSolutionsAssigner2.LeftSideParameter.ActualName = IslandEvaluatedSolutions.Name;
     312      evaluatedSolutionsAssigner2.RightSideParameter.Value = new IntValue(0);
     313
     314      evaluatedSolutionsReducer2.Name = "Increment Evaluated Solutions";
     315      evaluatedSolutionsReducer2.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
     316      evaluatedSolutionsReducer2.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
     317      evaluatedSolutionsReducer2.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     318      evaluatedSolutionsReducer2.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
    297319
    298320      immigrationReplacer.Name = "Immigration Replacer (placeholder)";
     
    368390      emigrantsSelector.Successor = null;
    369391      uniformSubScopesProcessor5.Successor = migrator;
    370       migrator.Successor = uniformSubScopesProcessor6;
    371       uniformSubScopesProcessor6.Operator = immigrationReplacer;
    372       uniformSubScopesProcessor6.Successor = generationsComparator;
     392      migrator.Successor = reevaluateImmigrantsBranch;
     393      reevaluateImmigrantsBranch.FalseBranch = null;
     394      reevaluateImmigrantsBranch.Successor = uniformSubScopesProcessor7;
     395      reevaluateImmigrantsBranch.TrueBranch = uniformSubScopesProcessor6;
     396      uniformSubScopesProcessor6.Successor = evaluatedSolutionsReducer2;
     397      uniformSubScopesProcessor6.Operator = evaluatedSolutionsAssigner2;
     398      evaluatedSolutionsReducer2.Successor = null;
     399      evaluatedSolutionsAssigner2.Successor = subScopesProcessor3;
     400      subScopesProcessor3.Operators.Add(new EmptyOperator());
     401      subScopesProcessor3.Operators.Add(uniformSubScopesProcessor3);
     402      uniformSubScopesProcessor7.Operator = immigrationReplacer;
     403      uniformSubScopesProcessor7.Successor = generationsComparator;
    373404      generationsComparator.Successor = analyzer2;
    374405      analyzer2.Successor = generationsTerminationCondition;
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs

    r10152 r10155  
    133133      get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; }
    134134    }
     135    protected IFixedValueParameter<BoolValue> ReevaluateImmigrantsParameter {
     136      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateImmigrants"]; }
     137    }
    135138    #endregion
    136139
     
    235238      get { return MaximumEvaluatedSolutionsParameter.Value; }
    236239      set { MaximumEvaluatedSolutionsParameter.Value = value; }
     240    }
     241    public bool ReevaluateImmigrants {
     242      get { return ReevaluateImmigrantsParameter.Value.Value; }
     243      set { ReevaluateImmigrantsParameter.Value.Value = value; }
    237244    }
    238245    protected RandomCreator RandomCreator {
     
    315322      Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
    316323      Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue)));
     324      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated.", new BoolValue(false)) { Hidden = true });
    317325
    318326      RandomCreator randomCreator = new RandomCreator();
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithmMainLoop.cs

    r9756 r10155  
    129129    public LookupParameter<IntValue> EvaluatedSolutionsParameter {
    130130      get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
     131    }
     132    public ValueLookupParameter<BoolValue> ReevaluateImmigrants {
     133      get { return (ValueLookupParameter<BoolValue>)Parameters["ReevaluateImmigrants"]; }
    131134    }
    132135    #endregion
     
    174177      Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
    175178      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
     179      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated."));
    176180      #endregion
    177181
     
    204208      Placeholder emigrantsSelector = new Placeholder();
    205209      Placeholder migrator = new Placeholder();
     210      ConditionalBranch reevaluateImmigrantsBranch = new ConditionalBranch();
    206211      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
     212      SubScopesProcessor subScopesProcessor = new SubScopesProcessor();
     213      UniformSubScopesProcessor uniformSubScopesProcessor4 = new UniformSubScopesProcessor();
     214      Placeholder evaluator = new Placeholder();
     215      SubScopesCounter subScopesCounter = new SubScopesCounter();
     216      UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
    207217      Placeholder immigrationReplacer = new Placeholder();
    208218      Comparator generationsComparator = new Comparator();
     
    324334      migrator.Name = "Migrator (placeholder)";
    325335      migrator.OperatorParameter.ActualName = MigratorParameter.Name;
     336
     337      reevaluateImmigrantsBranch.ConditionParameter.ActualName = "ReevaluateImmigrants";
     338      reevaluateImmigrantsBranch.Name = "Reevaluate Immigrants ?";
     339
     340      evaluator.Name = "Evaluator (placeholder)";
     341      evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
     342
     343      subScopesCounter.Name = "Increment EvaluatedSolutions";
     344      subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    326345
    327346      immigrationReplacer.Name = "Immigration Replacer (placeholder)";
     
    398417      reviveIslandAssigner.Successor = emigrantsSelector;
    399418      emigrantsSelector.Successor = null;
    400       migrator.Successor = uniformSubScopesProcessor3;
    401       uniformSubScopesProcessor3.Operator = immigrationReplacer;
    402       uniformSubScopesProcessor3.Successor = null;
     419      migrator.Successor = reevaluateImmigrantsBranch;
     420      reevaluateImmigrantsBranch.FalseBranch = null;
     421      reevaluateImmigrantsBranch.Successor = uniformSubScopesProcessor5;
     422      reevaluateImmigrantsBranch.TrueBranch = uniformSubScopesProcessor3;
     423      uniformSubScopesProcessor3.Operator = subScopesProcessor;
     424      subScopesProcessor.Operators.Add(new EmptyOperator());
     425      subScopesProcessor.Operators.Add(uniformSubScopesProcessor4);
     426      uniformSubScopesProcessor4.Operator = evaluator;
     427      uniformSubScopesProcessor4.Successor = subScopesCounter;
     428      evaluator.Successor = null;
     429      uniformSubScopesProcessor5.Operator = immigrationReplacer;
     430      uniformSubScopesProcessor5.Successor = null;
    403431      immigrationReplacer.Successor = null;
    404432      generationsComparator.Successor = terminatedIslandsComparator;
Note: See TracChangeset for help on using the changeset viewer.