Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/03/13 14:39:36 (11 years ago)
Author:
mkommend
Message:

#2038: Added reevaluation of elites in ES, IslandGA, IslandOSGA, OSGA, SASEGASA, and RAPGA.

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

Legend:

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

    r9456 r9569  
    9494      get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
    9595    }
     96    private IFixedValueParameter<BoolValue> ReevaluateElitesParameter {
     97      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; }
     98    }
    9699    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
    97100      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
     
    157160      get { return ElitesParameter.Value; }
    158161      set { ElitesParameter.Value = value; }
     162    }
     163    public bool ReevaluteElites {
     164      get { return ReevaluateElitesParameter.Value.Value; }
     165      set { ReevaluateElitesParameter.Value.Value = value; }
    159166    }
    160167    public MultiAnalyzer Analyzer {
     
    192199    private RAPGA(bool deserializing) : base(deserializing) { }
    193200    [StorableHook(HookType.AfterDeserialization)]
    194     private void AfterDeserialization() { Initialize(); }
     201    private void AfterDeserialization() {
     202      if (!Parameters.ContainsKey("ReevaluateElites")) {
     203        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 });
     204      }
     205      Initialize();
     206    }
    195207    private RAPGA(RAPGA original, Cloner cloner)
    196208      : base(original, cloner) {
     
    216228      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    217229      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
     230      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
    218231      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
    219232      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
     
    248261      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
    249262      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
     263      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
    250264      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
    251265      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
  • trunk/sources/HeuristicLab.Algorithms.RAPGA/3.3/RAPGAMainLoop.cs

    r9456 r9569  
    6565      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
    6666    }
     67    public IValueLookupParameter<BoolValue> ReevaluateElitesParameter {
     68      get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; }
     69    }
    6770    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
    6871      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
     
    129132      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."));
    130133      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
     134      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
    131135      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
    132136      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
     
    190194      Assigner assigner4 = new Assigner();
    191195      Assigner assigner5 = new Assigner();
     196      ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
     197      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
     198      Placeholder evaluator2 = new Placeholder();
     199      SubScopesCounter subScopesCounter4 = new SubScopesCounter();
    192200
    193201      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class RAPGA expects this to be called Generations
     
    338346      assigner5.LeftSideParameter.ActualName = "OffspringList";
    339347      assigner5.RightSideParameter.Value = new ScopeList();
     348
     349      reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
     350      reevaluateElitesBranch.Name = "Reevaluate elites ?";
     351
     352      uniformSubScopesProcessor2.Parallel.Value = true;
     353
     354      evaluator2.Name = "Evaluator (placeholder)";
     355      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
     356
     357      subScopesCounter4.Name = "Increment EvaluatedSolutions";
     358      subScopesCounter4.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    340359      #endregion
    341360
     
    378397      subScopesProcessor2.Successor = mergingReducer;
    379398      bestSelector.Successor = rightReducer2;
    380       rightReducer2.Successor = null;
     399      rightReducer2.Successor = reevaluateElitesBranch;
     400      reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor2;
     401      uniformSubScopesProcessor2.Operator = evaluator2;
     402      uniformSubScopesProcessor2.Successor = subScopesCounter4;
     403      evaluator2.Successor = null;
     404      subScopesCounter4.Successor = null;
     405      reevaluateElitesBranch.FalseBranch = null;
     406      reevaluateElitesBranch.Successor = null;
    381407      scopeCleaner.Successor = scopeRestorer;
    382408      mergingReducer.Successor = intCounter3;
Note: See TracChangeset for help on using the changeset viewer.