Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs @ 15870

Last change on this file since 15870 was 9467, checked in by sforsten, 12 years ago

#1980:

  • added ProportionalTournamentSelector for XCS
  • fixed bug: if an initial population is created in XCS, the initial population also creates general classifier, not only specific ones
  • merged r9204:9466 HeuristicLab.Core from trunk to branch
File size: 27.6 KB
RevLine 
[8941]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
[9089]25using HeuristicLab.Encodings.ConditionActionEncoding;
[8941]26using HeuristicLab.Operators;
27using HeuristicLab.Optimization.Operators;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Selection;
31
32namespace HeuristicLab.Algorithms.LearningClassifierSystems {
33  /// <summary>
34  /// An operator which represents the main loop of a learning classifier system.
35  /// </summary>
36  [Item("LearningClassifierSystemMainLoop", "An operator which represents the main loop of a learning classifier system.")]
37  [StorableClass]
[9089]38  public sealed class LearningClassifierSystemMainLoop : AlgorithmOperator {
[9110]39    private const string HASTOBEDELETED = "HasToBeDeleted";
40    private const string HASBEENSUBSUMED = "HasBeenSubsumed";
[8941]41
42    #region Parameter Properties
[9467]43    public ValueLookupParameter<IOperator> SelectorParameter {
44      get { return adaptedGeneticAlgorithmMainLoop.SelectorParameter; }
[8941]45    }
[9204]46    public ValueLookupParameter<PercentValue> CrossoverProbabilityParameter {
47      get { return adaptedGeneticAlgorithmMainLoop.CrossoverProbabilityParameter; }
[8941]48    }
[9204]49    public ValueLookupParameter<IOperator> CrossoverParameter {
50      get { return adaptedGeneticAlgorithmMainLoop.CrossoverParameter; }
[8941]51    }
[9204]52    public ValueLookupParameter<IOperator> MutatorParameter {
53      get { return adaptedGeneticAlgorithmMainLoop.MutatorParameter; }
54    }
[9167]55    public IConstrainedValueParameter<IOperator> AfterCopyingParentsParameter {
56      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCopyingParents"]; }
57    }
[9105]58    public IConstrainedValueParameter<IOperator> AfterCrossoverParameter {
59      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; }
60    }
[9154]61    public LookupParameter<IntValue> MaxIterationsParameter {
62      get { return (LookupParameter<IntValue>)Parameters["MaxIterations"]; }
63    }
64    public ValueLookupParameter<IOperator> AnalyzerParameter {
65      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
66    }
[9175]67    public ValueLookupParameter<IOperator> FinalAnalyzerParameter {
68      get { return (ValueLookupParameter<IOperator>)Parameters["FinalAnalyzer"]; }
69    }
[9242]70    public ValueLookupParameter<IntValue> AnalyzeInIterationParameter {
71      get { return (ValueLookupParameter<IntValue>)Parameters["AnalyzeInIteration"]; }
72    }
[8941]73    #endregion
74
[9089]75    #region private properties
76    private SolutionsCreator initialSolutionsCreator;
77    private MatchConditionOperator matchConditionOperator;
78    private PredictionArrayCalculator predictionArrayCalculator;
79    private ActionSelector actionSelector;
[9105]80    private DoDeletionBeforeCoveringOperator doDeletionBeforeCovering;
[9090]81    private CoveringOperator covering;
[9194]82    private CountNumberOfUniqueActions countNumberOfUniqueActions;
[9226]83    private MatchActionOperator matchActionOperator;
84    private InsertInPopulationOperator insertInPopulation;
[9089]85
[9204]86    private LCSAdaptedGeneticAlgorithm adaptedGeneticAlgorithmMainLoop;
[9110]87
[9089]88    private Placeholder evaluator;
89    private Placeholder actionExecuter;
90    private Placeholder classifierFetcher;
[9105]91    private Placeholder actionSetSubsumption;
[8941]92    #endregion
93
94    [StorableConstructor]
95    private LearningClassifierSystemMainLoop(bool deserializing) : base(deserializing) { }
[9089]96    private LearningClassifierSystemMainLoop(LearningClassifierSystemMainLoop original, Cloner cloner)
[8941]97      : base(original, cloner) {
98    }
99    public override IDeepCloneable Clone(Cloner cloner) {
100      return new LearningClassifierSystemMainLoop(this, cloner);
101    }
102    public LearningClassifierSystemMainLoop()
103      : base() {
104      Initialize();
105    }
106
107    private void Initialize() {
108      #region Create parameters
[9089]109      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."));
[9167]110      XCSAfterCopyingParentOperator afterCopyingParents = new XCSAfterCopyingParentOperator();
111      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCopyingParents", "", new ItemSet<IOperator>() { new XCSAfterCopyingParentOperator() }, afterCopyingParents));
[9105]112      XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator();
[9167]113      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover));
[9154]114      Parameters.Add(new LookupParameter<IntValue>("MaxIterations", "The maximum number of iterations the algorithm will do."));
115      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
[9175]116      Parameters.Add(new ValueLookupParameter<IOperator>("FinalAnalyzer", "The operator used to analyze the last generation."));
[9242]117      Parameters.Add(new ValueLookupParameter<IntValue>("AnalyzeInIteration", ""));
[8941]118      #endregion
119
120      #region Create operators
121      VariableCreator variableCreator = new VariableCreator();
[9154]122      ResultsCollector resultsCollector = new ResultsCollector();
[9242]123      ModuloOperator moduloOperator = new ModuloOperator();
124      Comparator analyzerComparator = new Comparator();
125      ConditionalBranch analyzerConditionalBranch = new ConditionalBranch();
[9175]126      Placeholder analyzer = new Placeholder();
[9154]127      Placeholder finalAnalyzer = new Placeholder();
[9089]128      ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch();
129      initialSolutionsCreator = new SolutionsCreator();
[9105]130      Assigner initialPopulationSizeAssigner = new Assigner();
[9154]131      Comparator maxIterationsComparator = new Comparator();
132      ConditionalBranch terminationConditionalBranch1 = new ConditionalBranch();
[9089]133      IntCounter iterationCounter = new IntCounter();
134      UniformSubScopesProcessor matchCondtionSubScopesProcessor = new UniformSubScopesProcessor();
135      matchConditionOperator = new MatchConditionOperator();
136      predictionArrayCalculator = new PredictionArrayCalculator();
137      actionSelector = new ActionSelector();
138      UniformSubScopesProcessor matchActionSubScopesProcessor = new UniformSubScopesProcessor();
[9226]139      matchActionOperator = new MatchActionOperator();
[9089]140      ConditionalSelector conditionMatchSelector = new ConditionalSelector();
141      ConditionalSelector actionMatchSelector = new ConditionalSelector();
[9090]142      SubScopesProcessor matchSetSubScopesProcessor = new SubScopesProcessor();
[9194]143      countNumberOfUniqueActions = new CountNumberOfUniqueActions();
[9105]144      doDeletionBeforeCovering = new DoDeletionBeforeCoveringOperator();
145      ConditionalBranch doDeletionBeforeCoveringConditionalBranch = new ConditionalBranch();
146      XCSDeletionOperator deletionOperator = new XCSDeletionOperator();
147      ConditionalSelector deletionSelector = new ConditionalSelector();
148      LeftReducer leftReducerAfterDeletionSelection = new LeftReducer();
[9090]149      covering = new CoveringOperator();
[9105]150      MergingReducer actionSetMergingReducer = new MergingReducer();
151      MergingReducer matchSetMergingReducer = new MergingReducer();
[9089]152      evaluator = new Placeholder();
153      SubScopesProcessor actionSetSubScopesProcessor = new SubScopesProcessor();
154      DataReducer actionSetSizeDataReducer = new DataReducer();
155      UniformSubScopesProcessor accuracySubScopesProcessor = new UniformSubScopesProcessor();
156      CalculateAccuracy calculateAccuracy = new CalculateAccuracy();
157      SumAccuracy sumAccuracy = new SumAccuracy();
158      UniformSubScopesProcessor updateParametersSubScopesProcessor = new UniformSubScopesProcessor();
[9105]159      ConditionalBranch actionSetSubsumptionBranch = new ConditionalBranch();
[9110]160      UniformSubScopesProcessor setSubsumedToFalseSubScopeProcessor = new UniformSubScopesProcessor();
161      Assigner setSubsumedToFalseAssigner = new Assigner();
162      ConditionalSelector subsumptionSelector = new ConditionalSelector();
[9105]163      LeftReducer leftReducer = new LeftReducer();
164      XCSCheckIfGAShouldBeApplied checkIfGAShouldRun = new XCSCheckIfGAShouldBeApplied();
165      ConditionalBranch runGAConditionalBranch = new ConditionalBranch();
166      UniformSubScopesProcessor timestampAssignerSubscopeProcessor = new UniformSubScopesProcessor();
167      Assigner timestampAssigner = new Assigner();
[9204]168      adaptedGeneticAlgorithmMainLoop = new LCSAdaptedGeneticAlgorithm();
[9105]169      IntCounter currentPopulationSizeCounter = new IntCounter();
170      CalculateNumberOfDeletionsOperator calculateNumberOfDeletions = new CalculateNumberOfDeletionsOperator();
[9110]171      UniformSubScopesProcessor setDeletionFalseSubScopeProcessor1 = new UniformSubScopesProcessor();
172      UniformSubScopesProcessor setDeletionFalseSubScopeProcessor2 = new UniformSubScopesProcessor();
173      Assigner setDeletionFalseAssigner = new Assigner();
[9226]174      insertInPopulation = new InsertInPopulationOperator();
[9105]175      XCSDeletionOperator deletionOperatorAfterGA = new XCSDeletionOperator();
176      ConditionalSelector deletionSelectorAfterGA = new ConditionalSelector();
177      LeftReducer leftReducerAfterGA = new LeftReducer();
[8941]178
[9089]179      classifierFetcher = new Placeholder();
180      actionExecuter = new Placeholder();
[9105]181      actionSetSubsumption = new Placeholder();
[8941]182
183      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("ZeroIntValue", new IntValue(0)));
184      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OneIntValue", new IntValue(1)));
[9089]185      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iteration", new IntValue(0)));
[9105]186      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
[8941]187
[9154]188      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iteration"));
189      resultsCollector.ResultsParameter.ActualName = "Results";
190
[9242]191      moduloOperator.LeftSideParameter.ActualName = "Iteration";
192      moduloOperator.RightSideParameter.ActualName = AnalyzeInIterationParameter.ActualName;
193      moduloOperator.ResultParameter.ActualName = "ModuloResult";
194
195      analyzerComparator.LeftSideParameter.ActualName = "ModuloResult";
196      analyzerComparator.RightSideParameter.Value = new IntValue(0);
197      analyzerComparator.ResultParameter.ActualName = "DoAnalyzing";
198
199      analyzerConditionalBranch.ConditionParameter.ActualName = "DoAnalyzing";
200
[9175]201      analyzer.Name = "Analyzer";
202      analyzer.OperatorParameter.ActualName = "Analyzer";
[9154]203
[9175]204      finalAnalyzer.Name = "FinalAnalyzer";
205      finalAnalyzer.OperatorParameter.ActualName = "FinalAnalyzer";
206
[9089]207      initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation";
208
209      initialSolutionsCreator.NumberOfSolutionsParameter.ActualName = "N";
210
[9105]211      initialPopulationSizeAssigner.LeftSideParameter.ActualName = "CurrentPopulationSize";
212      initialPopulationSizeAssigner.RightSideParameter.ActualName = "N";
213
[9154]214      maxIterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
215      maxIterationsComparator.LeftSideParameter.ActualName = "Iteration";
216      maxIterationsComparator.RightSideParameter.ActualName = MaxIterationsParameter.ActualName;
217      maxIterationsComparator.ResultParameter.ActualName = "TerminateMaxIterations";
218
219      terminationConditionalBranch1.ConditionParameter.ActualName = "TerminateMaxIterations";
220
[9089]221      iterationCounter.ValueParameter.ActualName = "Iteration";
222      iterationCounter.IncrementParameter.ActualName = "OneIntValue";
223
[8941]224      conditionMatchSelector.CopySelected = new BoolValue(false);
[9110]225      conditionMatchSelector.ConditionParameter.ActualName = matchConditionOperator.MatchConditionParameter.ActualName;
[8941]226
[9110]227      doDeletionBeforeCovering.MatchConditionParameter.ActualName = matchConditionOperator.MatchConditionParameter.ActualName;
[9105]228      doDeletionBeforeCovering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
229      doDeletionBeforeCovering.PopulationSizeParameter.ActualName = "N";
230
231      doDeletionBeforeCoveringConditionalBranch.ConditionParameter.ActualName = doDeletionBeforeCovering.DoDeletionParameter.ActualName;
232
[9110]233      setDeletionFalseAssigner.LeftSideParameter.ActualName = HASTOBEDELETED;
234      setDeletionFalseAssigner.RightSideParameter.Value = new BoolValue(false);
235
[9105]236      deletionOperator.NumberToDeleteParameter.ActualName = doDeletionBeforeCovering.NumberToDeleteParameter.ActualName;
[9110]237      deletionOperator.HasToBeDeletedParameter.ActualName = HASTOBEDELETED;
[9105]238      deletionOperator.AverageActionSetSizesParameter.ActualName = "AverageActionSetSize";
239      deletionOperator.FitnessesParameter.ActualName = "Fitness";
240      deletionOperator.NumerositiesParameter.ActualName = "Numerosity";
241      deletionOperator.ExperiencesParameter.ActualName = "Experience";
242      deletionOperator.ThetaDeletionParameter.ActualName = "ThetaDeletion";
243      deletionOperator.DeltaParameter.ActualName = "Delta";
244      deletionOperator.RandomParameter.ActualName = "Random";
245
[9110]246      deletionSelector.ConditionParameter.ActualName = HASTOBEDELETED;
[9105]247      deletionSelector.CopySelected = new BoolValue(false);
248
[9090]249      covering.ActionsInMatchSetParameter.ActualName = countNumberOfUniqueActions.UniqueActionsParameter.ActualName;
250      covering.ParallelParameter.Value.Value = true;
251      covering.RandomParameter.ActualName = "Random";
[9105]252      covering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
[8941]253
[9089]254      matchActionSubScopesProcessor.Operator = matchActionOperator;
[8941]255
[9089]256      matchActionOperator.TargetMatchParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
257
258      actionSelector.PredictionArrayParameter.ActualName = predictionArrayCalculator.PredictionArrayParameter.Name;
259      actionSelector.RandomParameter.ActualName = "Random";
260      actionSelector.ExplorationProbabilityParameter.ActualName = "ExplorationProbability";
261
[8941]262      actionMatchSelector.CopySelected = new BoolValue(false);
[9089]263      actionMatchSelector.ConditionParameter.ActualName = "MatchAction";
[8941]264
[9105]265      actionSetSubsumptionBranch.ConditionParameter.ActualName = "DoActionSetSubsumption";
266
[9110]267      setSubsumedToFalseAssigner.LeftSideParameter.ActualName = HASBEENSUBSUMED;
268      setSubsumedToFalseAssigner.RightSideParameter.Value = new BoolValue(false);
269
270      subsumptionSelector.ConditionParameter.ActualName = HASBEENSUBSUMED;
[9105]271      subsumptionSelector.CopySelected = new BoolValue(false);
272
[9089]273      evaluator.Name = "Evaluator";
[8941]274
[9089]275      classifierFetcher.Name = "ClassifierFetcher";
[8941]276
[9089]277      actionExecuter.Name = "ActionExecuter";
[8941]278
[9089]279      actionSetSizeDataReducer.TargetParameter.ActualName = "CurrentActionSetSize";
280      actionSetSizeDataReducer.ParameterToReduce.ActualName = "Numerosity";
281      actionSetSizeDataReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
282      actionSetSizeDataReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
283
284      calculateAccuracy.AlphaParameter.ActualName = "Alpha";
285      calculateAccuracy.ErrorParameter.ActualName = "Error";
286      calculateAccuracy.ErrorZeroParameter.ActualName = "ErrorZero";
287      calculateAccuracy.PowerParameter.ActualName = "v";
288
289      sumAccuracy.AccuracyParameter.ActualName = calculateAccuracy.AccuracyParameter.ActualName;
290      sumAccuracy.NumerosityParameter.ActualName = "Numerosity";
291
[9105]292      //BEGIN parameters have to be set differently
293      checkIfGAShouldRun.TimeStampsParameter.ActualName = "Timestamp";
294      checkIfGAShouldRun.NumerositiesParameter.ActualName = "Numerosity";
295      checkIfGAShouldRun.ThetaGAParameter.ActualName = "ThetaGA";
296      //END
297      checkIfGAShouldRun.IterationParameter.ActualName = iterationCounter.ValueParameter.ActualName;
298
299      runGAConditionalBranch.ConditionParameter.ActualName = checkIfGAShouldRun.RunGAParameter.ActualName;
300
301      timestampAssigner.LeftSideParameter.ActualName = "Timestamp";
302      timestampAssigner.RightSideParameter.ActualName = iterationCounter.ValueParameter.ActualName;
303
304      afterCrossover.NumerosityParameter.ActualName = "Numerosity";
305      afterCrossover.ExperienceParameter.ActualName = "Experience";
306      afterCrossover.TimestampParameter.ActualName = "Timestamp";
307      afterCrossover.CurrentIterationParameter.ActualName = "Iteration";
308      afterCrossover.FitnessParameter.ActualName = "Fitness";
309      afterCrossover.AverageActionSetSizeParameter.ActualName = "AverageActionSetSize";
310      afterCrossover.PredictionParameter.ActualName = "Prediction";
311      afterCrossover.ErrorParameter.ActualName = "Error";
312      afterCrossover.ParentFitnessParameter.ActualName = "Fitness";
313      afterCrossover.ParentErrorParameter.ActualName = "Error";
314      afterCrossover.ParentPredictionParameter.ActualName = "Prediction";
315      afterCrossover.ParentAverageActionSetSizeParameter.ActualName = "AverageActionSetSize";
316
[9089]317      adaptedGeneticAlgorithmMainLoop.RandomParameter.ActualName = "Random";
318      adaptedGeneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = "ZeroIntValue";
319      adaptedGeneticAlgorithmMainLoop.QualityParameter.ActualName = "Fitness";
[9110]320      adaptedGeneticAlgorithmMainLoop.MutationProbabilityParameter.ActualName = "MutationProbability";
[9089]321      adaptedGeneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true);
[9105]322      adaptedGeneticAlgorithmMainLoop.AfterCrossoverParameter.ActualName = AfterCrossoverParameter.Name;
[9167]323      adaptedGeneticAlgorithmMainLoop.AfterCopyingParentsParameter.ActualName = AfterCopyingParentsParameter.Name;
[9105]324
325      currentPopulationSizeCounter.ValueParameter.ActualName = "CurrentPopulationSize";
326      currentPopulationSizeCounter.Increment = new IntValue(2);
327
[9110]328      insertInPopulation.NumerositiesParameter.ActualName = "Numerosity";
329      insertInPopulation.HasToBeDeletedParameter.ActualName = HASTOBEDELETED;
330      insertInPopulation.InsertInPopulationParameter.ActualName = "InsertInPopulation";
331
[9105]332      calculateNumberOfDeletions.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
333      calculateNumberOfDeletions.PopulationSizeParameter.ActualName = "N";
334
335      deletionOperatorAfterGA.NumberToDeleteParameter.ActualName = calculateNumberOfDeletions.NumberOfDeletionsParameter.ActualName;
[9110]336      deletionOperatorAfterGA.HasToBeDeletedParameter.ActualName = HASTOBEDELETED;
[9105]337      deletionOperatorAfterGA.AverageActionSetSizesParameter.ActualName = "AverageActionSetSize";
338      deletionOperatorAfterGA.FitnessesParameter.ActualName = "Fitness";
339      deletionOperatorAfterGA.NumerositiesParameter.ActualName = "Numerosity";
340      deletionOperatorAfterGA.ExperiencesParameter.ActualName = "Experience";
341      deletionOperatorAfterGA.ThetaDeletionParameter.ActualName = "ThetaDeletion";
342      deletionOperatorAfterGA.DeltaParameter.ActualName = "Delta";
343      deletionOperatorAfterGA.RandomParameter.ActualName = "Random";
344
[9110]345      deletionSelectorAfterGA.ConditionParameter.ActualName = HASTOBEDELETED;
[9105]346      deletionSelectorAfterGA.CopySelected = new BoolValue(false);
[8941]347      #endregion
348
349      #region Create operator graph
350      OperatorGraph.InitialOperator = variableCreator;
[9089]351
[9154]352      variableCreator.Successor = resultsCollector;
353      resultsCollector.Successor = initialPopulationConditionalBranch;
[9089]354      initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator;
[9105]355      initialSolutionsCreator.Successor = initialPopulationSizeAssigner;
[9089]356      initialPopulationConditionalBranch.FalseBranch = new EmptyOperator();
[9154]357      initialPopulationConditionalBranch.Successor = maxIterationsComparator;
358      maxIterationsComparator.Successor = terminationConditionalBranch1;
[9175]359      terminationConditionalBranch1.TrueBranch = finalAnalyzer;
[9154]360      terminationConditionalBranch1.FalseBranch = classifierFetcher;
[9089]361      classifierFetcher.Successor = matchCondtionSubScopesProcessor;
[9105]362      matchCondtionSubScopesProcessor.Operator = matchConditionOperator;
[9110]363      matchCondtionSubScopesProcessor.Successor = doDeletionBeforeCovering;
364      doDeletionBeforeCovering.Successor = doDeletionBeforeCoveringConditionalBranch;
365      doDeletionBeforeCoveringConditionalBranch.TrueBranch = setDeletionFalseSubScopeProcessor1;
366      doDeletionBeforeCoveringConditionalBranch.FalseBranch = conditionMatchSelector;
367      setDeletionFalseSubScopeProcessor1.Operator = setDeletionFalseAssigner;
368      setDeletionFalseSubScopeProcessor1.Successor = deletionOperator;
369      deletionOperator.Successor = deletionSelector;
370      deletionSelector.Successor = leftReducerAfterDeletionSelection;
371      //if a classifier with a unique action for the match set has been deleted, then there are still to many classifiers in the population
372      leftReducerAfterDeletionSelection.Successor = doDeletionBeforeCovering;
[9090]373      conditionMatchSelector.Successor = matchSetSubScopesProcessor;
374      matchSetSubScopesProcessor.Operators.Add(new EmptyOperator());
375      matchSetSubScopesProcessor.Operators.Add(countNumberOfUniqueActions);
[9110]376      countNumberOfUniqueActions.Successor = covering;
377      matchSetSubScopesProcessor.Successor = matchSetMergingReducer;
[9090]378      covering.Successor = predictionArrayCalculator;
[9089]379      predictionArrayCalculator.Successor = actionSelector;
380      actionSelector.Successor = matchActionSubScopesProcessor;
381      matchActionSubScopesProcessor.Successor = actionMatchSelector;
382      actionMatchSelector.Successor = actionExecuter;
383      actionExecuter.Successor = actionSetSubScopesProcessor;
384      actionSetSubScopesProcessor.Operators.Add(new EmptyOperator());
385      actionSetSubScopesProcessor.Operators.Add(actionSetSizeDataReducer);
386      actionSetSizeDataReducer.Successor = accuracySubScopesProcessor;
387      accuracySubScopesProcessor.Operator = calculateAccuracy;
388      accuracySubScopesProcessor.Successor = sumAccuracy;
389      sumAccuracy.Successor = updateParametersSubScopesProcessor;
390      updateParametersSubScopesProcessor.Operator = evaluator;
[9105]391      updateParametersSubScopesProcessor.Successor = actionSetSubsumptionBranch;
[9110]392      actionSetSubsumptionBranch.TrueBranch = setSubsumedToFalseSubScopeProcessor;
393      setSubsumedToFalseSubScopeProcessor.Operator = setSubsumedToFalseAssigner;
394      setSubsumedToFalseSubScopeProcessor.Successor = actionSetSubsumption;
[9105]395      actionSetSubsumption.Successor = subsumptionSelector;
396      subsumptionSelector.Successor = leftReducer;
397      actionSetSubsumptionBranch.FalseBranch = new EmptyOperator();
398      actionSetSubsumptionBranch.Successor = checkIfGAShouldRun;
399      checkIfGAShouldRun.Successor = runGAConditionalBranch;
400      runGAConditionalBranch.TrueBranch = timestampAssignerSubscopeProcessor;
401      runGAConditionalBranch.FalseBranch = new EmptyOperator();
402      timestampAssignerSubscopeProcessor.Operator = timestampAssigner;
403      timestampAssignerSubscopeProcessor.Successor = adaptedGeneticAlgorithmMainLoop;
404      adaptedGeneticAlgorithmMainLoop.Successor = currentPopulationSizeCounter;
[9089]405
[9105]406      actionSetSubScopesProcessor.Successor = actionSetMergingReducer;
[9089]407
[9110]408      matchSetMergingReducer.Successor = setDeletionFalseSubScopeProcessor2;
409      setDeletionFalseSubScopeProcessor2.Operator = setDeletionFalseAssigner;
410      setDeletionFalseSubScopeProcessor2.Successor = insertInPopulation;
411      insertInPopulation.Successor = calculateNumberOfDeletions;
[9105]412      calculateNumberOfDeletions.Successor = deletionOperatorAfterGA;
413      deletionOperatorAfterGA.Successor = deletionSelectorAfterGA;
414      deletionSelectorAfterGA.Successor = leftReducerAfterGA;
415      leftReducerAfterGA.Successor = iterationCounter;
[9242]416      iterationCounter.Successor = moduloOperator;
417      moduloOperator.Successor = analyzerComparator;
418      analyzerComparator.Successor = analyzerConditionalBranch;
419      analyzerConditionalBranch.Successor = maxIterationsComparator;
420      analyzerConditionalBranch.TrueBranch = analyzer;
[8941]421      #endregion
422    }
423
[9089]424    internal void SetCurrentProblem(IConditionActionProblem problem) {
425      initialSolutionsCreator.SolutionCreatorParameter.ActualName = problem.SolutionCreatorParameter.Name;
426      initialSolutionsCreator.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;
427
428      problem.ActionExecuter.SelectedActionParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
429
430      problem.ClassifierFetcher.IterationParameter.ActualName = "Iteration";
431
432      evaluator.OperatorParameter.ActualName = problem.EvaluatorParameter.Name;
433
434      classifierFetcher.OperatorParameter.ActualName = problem.ClassifierFetcherParameter.Name;
435
436      actionExecuter.OperatorParameter.ActualName = problem.ActionExecuterParameter.Name;
437
[9105]438      problem.ActionSetSubsumptionOperator.ThetaSubsumptionParameter.ActualName = "ThetaSubsumption";
439      problem.ActionSetSubsumptionOperator.ErrorsParameter.ActualName = "Error";
440      problem.ActionSetSubsumptionOperator.ErrorZeroParameter.ActualName = "ErrorZero";
441      problem.ActionSetSubsumptionOperator.ExperiencesParameter.ActualName = "Experience";
442      problem.ActionSetSubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity";
443
[9110]444      problem.ActionSetSubsumptionOperator.HasBeenSubsumedParameter.ActualName = HASBEENSUBSUMED;
[9105]445
446      actionSetSubsumption.OperatorParameter.ActualName = problem.ActionSetSubsumptionOperatorParameter.Name;
447
[9194]448      matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentInputToMatchParameter.ActualName;
[9089]449
[9105]450      doDeletionBeforeCovering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name;
[9194]451      doDeletionBeforeCovering.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name;
[9105]452
[9090]453      covering.SolutionCreatorParameter.ActualName = problem.CoveringSolutionCreatorParameter.Name;
454      covering.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;
455      covering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name;
456      covering.PossibleActionsParameter.ActualName = problem.PossibleActionsParameter.Name;
457
[9089]458      predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName;
459      predictionArrayCalculator.FitnessParameter.ActualName = problem.Evaluator.FitnessParameter.ActualName;
[9194]460      predictionArrayCalculator.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name;
461
462      countNumberOfUniqueActions.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name;
[9226]463
464      matchConditionOperator.MatchParameter.ActualName = problem.ChildName;
465      countNumberOfUniqueActions.ClassifiersParameter.ActualName = problem.ChildName;
466      doDeletionBeforeCovering.ClassifiersParameter.ActualName = problem.ChildName;
467      matchActionOperator.MatchParameter.ActualName = problem.ChildName;
468      predictionArrayCalculator.MatchParameter.ActualName = problem.ChildName;
469      insertInPopulation.ClassifiersParameter.ActualName = problem.ChildName;
470
471      adaptedGeneticAlgorithmMainLoop.SetChildName(problem.ChildName);
[9089]472    }
[8941]473  }
474}
Note: See TracBrowser for help on using the repository browser.