Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8385


Ignore:
Timestamp:
08/02/12 13:22:47 (12 years ago)
Author:
jkarder
Message:

#1247:

  • added operator that evaluates expressions
  • added selection pressure analyzer
  • fixed bug in counting of evaluated solutions
Location:
branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/HeuristicLab.Algorithms.RAPGA-3.3.csproj

    r8378 r8385  
    9797  </ItemGroup>
    9898  <ItemGroup>
     99    <Compile Include="Analyzers\SelectionPressureAnalyzer.cs" />
    99100    <Compile Include="Analyzers\OffspringSuccessAnalyzer.cs" />
    100101    <Compile Include="Analyzers\PopulationSizeAnalyzer.cs" />
    101102    <Compile Include="DuplicatesSelector.cs" />
     103    <Compile Include="ExpressionEvaluator.cs" />
    102104    <Compile Include="OffspringRestorer.cs" />
    103105    <Compile Include="ProgressiveOffspringPreserver.cs" />
  • branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGA.cs

    r8378 r8385  
    185185    [Storable]
    186186    private OffspringSuccessAnalyzer offspringSuccessAnalyzer;
     187    [Storable]
     188    private SelectionPressureAnalyzer selectionPressureAnalyzer;
    187189    #endregion
    188190
     
    196198      populationSizeAnalyzer = cloner.Clone(original.populationSizeAnalyzer);
    197199      offspringSuccessAnalyzer = cloner.Clone(original.offspringSuccessAnalyzer);
     200      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
    198201      Initialize();
    199202    }
     
    263266      populationSizeAnalyzer = new PopulationSizeAnalyzer();
    264267      offspringSuccessAnalyzer = new OffspringSuccessAnalyzer();
     268      selectionPressureAnalyzer = new SelectionPressureAnalyzer();
    265269      ParameterizeAnalyzers();
    266270      UpdateAnalyzers();
     
    401405      offspringSuccessAnalyzer.ResultsParameter.ActualName = "Results";
    402406      offspringSuccessAnalyzer.ResultsParameter.Hidden = true;
     407      selectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
     408      selectionPressureAnalyzer.ResultsParameter.Hidden = true;
    403409      if (Problem != null) {
    404410        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    459465      Analyzer.Operators.Add(populationSizeAnalyzer, populationSizeAnalyzer.EnabledByDefault);
    460466      Analyzer.Operators.Add(offspringSuccessAnalyzer, offspringSuccessAnalyzer.EnabledByDefault);
     467      Analyzer.Operators.Add(selectionPressureAnalyzer, selectionPressureAnalyzer.EnabledByDefault);
    461468    }
    462469    private void UpdateSimilarityCalculators() {
  • branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGAMainLoop.cs

    r8379 r8385  
    158158      WeightedParentsQualityComparator weightedParentsQualityComparator = new WeightedParentsQualityComparator();
    159159      SubScopesRemover subScopesRemover = new SubScopesRemover();
    160       SubScopesCounter subScopesCounter1 = new SubScopesCounter();
    161160      IntCounter intCounter1 = new IntCounter();
     161      IntCounter intCounter2 = new IntCounter();
    162162      ConditionalSelector conditionalSelector = new ConditionalSelector();
    163163      RightReducer rightReducer1 = new RightReducer();
     
    177177      OffspringRestorer offspringRestorer = new OffspringRestorer();
    178178      MergingReducer mergingReducer = new MergingReducer();
    179       IntCounter intCounter2 = new IntCounter();
     179      Assigner assigner2 = new Assigner();
     180      IntCounter intCounter3 = new IntCounter();
    180181      SubScopesCounter subScopesCounter3 = new SubScopesCounter();
     182      ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator();
     183      Placeholder analyzer2 = new Placeholder();
    181184      Comparator comparator3 = new Comparator();
    182       Placeholder analyzer2 = new Placeholder();
    183185      ConditionalBranch conditionalBranch3 = new ConditionalBranch();
    184186      Comparator comparator4 = new Comparator();
    185187      ConditionalBranch conditionalBranch4 = new ConditionalBranch();
    186       Assigner assigner2 = new Assigner();
    187188      Assigner assigner3 = new Assigner();
    188189      Assigner assigner4 = new Assigner();
     190      Assigner assigner5 = new Assigner();
    189191
    190192      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class RAPGA expects this to be called Generations
    191193      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
     194      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("LastPopulationSize", new IntValue(0)));
    192195      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NumberOfCreatedOffspring", new IntValue(0)));
    193196      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NumberOfSuccessfulOffspring", new IntValue(0)));
     
    232235      subScopesRemover.RemoveAllSubScopes = true;
    233236
    234       subScopesCounter1.Name = "Increment NumberOfCreatedOffspring";
    235       subScopesCounter1.ValueParameter.ActualName = "NumberOfCreatedOffspring";
    236 
    237       intCounter1.Name = "Increment EvaluatedSolutions";
    238       intCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     237      intCounter1.Name = "Increment NumberOfCreatedOffspring";
     238      intCounter1.ValueParameter.ActualName = "NumberOfCreatedOffspring";
    239239      intCounter1.Increment = null;
    240       intCounter1.IncrementParameter.ActualName = "NumberOfCreatedOffspring";
     240      intCounter1.IncrementParameter.ActualName = BatchSizeParameter.Name;
     241
     242      intCounter2.Name = "Increment EvaluatedSolutions";
     243      intCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     244      intCounter2.Increment = null;
     245      intCounter2.IncrementParameter.ActualName = BatchSizeParameter.Name;
    241246
    242247      conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
     
    276281      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
    277282
    278       intCounter2.Name = "Increment Generations";
    279       intCounter2.Increment = new IntValue(1);
    280       intCounter2.ValueParameter.ActualName = "Generations";
    281       subScopesCounter3.Name = "Set CurrentPopulationSize";
    282 
     283      assigner2.Name = "Update LastPopulationSize";
     284      assigner2.LeftSideParameter.ActualName = "LastPopulationSize";
     285      assigner2.RightSideParameter.ActualName = "CurrentPopulationSize";
     286
     287      intCounter3.Name = "Increment Generations";
     288      intCounter3.Increment = new IntValue(1);
     289      intCounter3.ValueParameter.ActualName = "Generations";
     290
     291      subScopesCounter3.Name = "Update CurrentPopulationSize";
    283292      subScopesCounter3.ValueParameter.ActualName = "CurrentPopulationSize";
    284293      subScopesCounter3.AccumulateParameter.Value = new BoolValue(false);
     294
     295      expressionEvaluator.Name = "Evaluate ActualSelectionPressure";
     296      expressionEvaluator.CollectedValues.Add(new ValueLookupParameter<IntValue>("CurrentPopulationSize"));
     297      expressionEvaluator.CollectedValues.Add(new ValueLookupParameter<IntValue>("LastPopulationSize"));
     298      expressionEvaluator.CollectedValues.Add(new ValueLookupParameter<IntValue>("NumberOfCreatedOffspring"));
     299      expressionEvaluator.CollectedValues.Add(new ValueLookupParameter<IntValue>("NumberOfSuccessfulOffspring"));
     300      expressionEvaluator.ExpressionParameter.Value = new StringValue("CurrentPopulationSize NumberOfCreatedOffspring NumberOfSuccessfulOffspring - + LastPopulationSize /");
     301      expressionEvaluator.ExpressionResultParameter.ActualName = "ActualSelectionPressure";
     302
     303      analyzer2.Name = "Analyzer";
     304      analyzer2.OperatorParameter.ActualName = "Analyzer";
    285305
    286306      comparator3.Name = "Generations >= MaximumGenerations";
     
    290310      comparator3.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
    291311
    292       analyzer2.Name = "Analyzer";
    293       analyzer2.OperatorParameter.ActualName = "Analyzer";
    294 
    295312      conditionalBranch3.Name = "Terminate?";
    296313      conditionalBranch3.ConditionParameter.ActualName = "Terminate";
     
    305322      conditionalBranch4.ConditionParameter.ActualName = "Terminate";
    306323
    307       assigner2.Name = "Reset NumberOfCreatedOffspring";
    308       assigner2.LeftSideParameter.ActualName = "NumberOfCreatedOffspring";
    309       assigner2.RightSideParameter.Value = new IntValue(0);
    310 
    311       assigner3.Name = "Reset NumberOfSuccessfulOffspring";
    312       assigner3.LeftSideParameter.ActualName = "NumberOfSuccessfulOffspring";
     324      assigner3.Name = "Reset NumberOfCreatedOffspring";
     325      assigner3.LeftSideParameter.ActualName = "NumberOfCreatedOffspring";
    313326      assigner3.RightSideParameter.Value = new IntValue(0);
    314327
    315       assigner4.Name = "Reset OffspringList";
    316       assigner4.LeftSideParameter.ActualName = "OffspringList";
    317       assigner4.RightSideParameter.Value = new ScopeList();
     328      assigner4.Name = "Reset NumberOfSuccessfulOffspring";
     329      assigner4.LeftSideParameter.ActualName = "NumberOfSuccessfulOffspring";
     330      assigner4.RightSideParameter.Value = new IntValue(0);
     331
     332      assigner5.Name = "Reset OffspringList";
     333      assigner5.LeftSideParameter.ActualName = "OffspringList";
     334      assigner5.RightSideParameter.Value = new ScopeList();
    318335      #endregion
    319336
     
    330347      childrenCreator.Successor = uniformSubScopesProcessor;
    331348      uniformSubScopesProcessor.Operator = crossover;
    332       uniformSubScopesProcessor.Successor = subScopesCounter1;
     349      uniformSubScopesProcessor.Successor = intCounter1;
    333350      crossover.Successor = stochasticBranch;
    334351      stochasticBranch.FirstBranch = mutator;
     
    338355      evaluator.Successor = weightedParentsQualityComparator;
    339356      weightedParentsQualityComparator.Successor = subScopesRemover;
    340       subScopesCounter1.Successor = intCounter1;
    341       intCounter1.Successor = conditionalSelector;
     357      intCounter1.Successor = intCounter2;
     358      intCounter2.Successor = conditionalSelector;
    342359      conditionalSelector.Successor = rightReducer1;
    343360      rightReducer1.Successor = duplicateSelector;
     
    358375      rightReducer2.Successor = null;
    359376      scopeCleaner.Successor = offspringRestorer;
    360       mergingReducer.Successor = intCounter2;
    361       intCounter2.Successor = subScopesCounter3;
    362       subScopesCounter3.Successor = analyzer2;
     377      mergingReducer.Successor = assigner2;
     378      assigner2.Successor = intCounter3;
     379      intCounter3.Successor = subScopesCounter3;
     380      subScopesCounter3.Successor = expressionEvaluator;
     381      expressionEvaluator.Successor = analyzer2;
    363382      analyzer2.Successor = comparator3;
    364383      comparator3.Successor = conditionalBranch3;
     
    367386      conditionalBranch3.Successor = null;
    368387      comparator4.Successor = conditionalBranch4;
    369       conditionalBranch4.FalseBranch = assigner2;
     388      conditionalBranch4.FalseBranch = assigner3;
    370389      conditionalBranch4.TrueBranch = null;
    371390      conditionalBranch4.Successor = null;
    372       assigner2.Successor = assigner3;
    373391      assigner3.Successor = assigner4;
    374       assigner4.Successor = selector;
     392      assigner4.Successor = assigner5;
     393      assigner5.Successor = selector;
    375394
    376395      #endregion
Note: See TracChangeset for help on using the changeset viewer.