Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9844 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
Line 
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;
25using HeuristicLab.Encodings.ConditionActionEncoding;
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]
38  public sealed class LearningClassifierSystemMainLoop : AlgorithmOperator {
39    private const string HASTOBEDELETED = "HasToBeDeleted";
40    private const string HASBEENSUBSUMED = "HasBeenSubsumed";
41
42    #region Parameter Properties
43    public ValueLookupParameter<IOperator> SelectorParameter {
44      get { return adaptedGeneticAlgorithmMainLoop.SelectorParameter; }
45    }
46    public ValueLookupParameter<PercentValue> CrossoverProbabilityParameter {
47      get { return adaptedGeneticAlgorithmMainLoop.CrossoverProbabilityParameter; }
48    }
49    public ValueLookupParameter<IOperator> CrossoverParameter {
50      get { return adaptedGeneticAlgorithmMainLoop.CrossoverParameter; }
51    }
52    public ValueLookupParameter<IOperator> MutatorParameter {
53      get { return adaptedGeneticAlgorithmMainLoop.MutatorParameter; }
54    }
55    public IConstrainedValueParameter<IOperator> AfterCopyingParentsParameter {
56      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCopyingParents"]; }
57    }
58    public IConstrainedValueParameter<IOperator> AfterCrossoverParameter {
59      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; }
60    }
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    }
67    public ValueLookupParameter<IOperator> FinalAnalyzerParameter {
68      get { return (ValueLookupParameter<IOperator>)Parameters["FinalAnalyzer"]; }
69    }
70    public ValueLookupParameter<IntValue> AnalyzeInIterationParameter {
71      get { return (ValueLookupParameter<IntValue>)Parameters["AnalyzeInIteration"]; }
72    }
73    #endregion
74
75    #region private properties
76    private SolutionsCreator initialSolutionsCreator;
77    private MatchConditionOperator matchConditionOperator;
78    private PredictionArrayCalculator predictionArrayCalculator;
79    private ActionSelector actionSelector;
80    private DoDeletionBeforeCoveringOperator doDeletionBeforeCovering;
81    private CoveringOperator covering;
82    private CountNumberOfUniqueActions countNumberOfUniqueActions;
83    private MatchActionOperator matchActionOperator;
84    private InsertInPopulationOperator insertInPopulation;
85
86    private LCSAdaptedGeneticAlgorithm adaptedGeneticAlgorithmMainLoop;
87
88    private Placeholder evaluator;
89    private Placeholder actionExecuter;
90    private Placeholder classifierFetcher;
91    private Placeholder actionSetSubsumption;
92    #endregion
93
94    [StorableConstructor]
95    private LearningClassifierSystemMainLoop(bool deserializing) : base(deserializing) { }
96    private LearningClassifierSystemMainLoop(LearningClassifierSystemMainLoop original, Cloner cloner)
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
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."));
110      XCSAfterCopyingParentOperator afterCopyingParents = new XCSAfterCopyingParentOperator();
111      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCopyingParents", "", new ItemSet<IOperator>() { new XCSAfterCopyingParentOperator() }, afterCopyingParents));
112      XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator();
113      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover));
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."));
116      Parameters.Add(new ValueLookupParameter<IOperator>("FinalAnalyzer", "The operator used to analyze the last generation."));
117      Parameters.Add(new ValueLookupParameter<IntValue>("AnalyzeInIteration", ""));
118      #endregion
119
120      #region Create operators
121      VariableCreator variableCreator = new VariableCreator();
122      ResultsCollector resultsCollector = new ResultsCollector();
123      ModuloOperator moduloOperator = new ModuloOperator();
124      Comparator analyzerComparator = new Comparator();
125      ConditionalBranch analyzerConditionalBranch = new ConditionalBranch();
126      Placeholder analyzer = new Placeholder();
127      Placeholder finalAnalyzer = new Placeholder();
128      ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch();
129      initialSolutionsCreator = new SolutionsCreator();
130      Assigner initialPopulationSizeAssigner = new Assigner();
131      Comparator maxIterationsComparator = new Comparator();
132      ConditionalBranch terminationConditionalBranch1 = new ConditionalBranch();
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();
139      matchActionOperator = new MatchActionOperator();
140      ConditionalSelector conditionMatchSelector = new ConditionalSelector();
141      ConditionalSelector actionMatchSelector = new ConditionalSelector();
142      SubScopesProcessor matchSetSubScopesProcessor = new SubScopesProcessor();
143      countNumberOfUniqueActions = new CountNumberOfUniqueActions();
144      doDeletionBeforeCovering = new DoDeletionBeforeCoveringOperator();
145      ConditionalBranch doDeletionBeforeCoveringConditionalBranch = new ConditionalBranch();
146      XCSDeletionOperator deletionOperator = new XCSDeletionOperator();
147      ConditionalSelector deletionSelector = new ConditionalSelector();
148      LeftReducer leftReducerAfterDeletionSelection = new LeftReducer();
149      covering = new CoveringOperator();
150      MergingReducer actionSetMergingReducer = new MergingReducer();
151      MergingReducer matchSetMergingReducer = new MergingReducer();
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();
159      ConditionalBranch actionSetSubsumptionBranch = new ConditionalBranch();
160      UniformSubScopesProcessor setSubsumedToFalseSubScopeProcessor = new UniformSubScopesProcessor();
161      Assigner setSubsumedToFalseAssigner = new Assigner();
162      ConditionalSelector subsumptionSelector = new ConditionalSelector();
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();
168      adaptedGeneticAlgorithmMainLoop = new LCSAdaptedGeneticAlgorithm();
169      IntCounter currentPopulationSizeCounter = new IntCounter();
170      CalculateNumberOfDeletionsOperator calculateNumberOfDeletions = new CalculateNumberOfDeletionsOperator();
171      UniformSubScopesProcessor setDeletionFalseSubScopeProcessor1 = new UniformSubScopesProcessor();
172      UniformSubScopesProcessor setDeletionFalseSubScopeProcessor2 = new UniformSubScopesProcessor();
173      Assigner setDeletionFalseAssigner = new Assigner();
174      insertInPopulation = new InsertInPopulationOperator();
175      XCSDeletionOperator deletionOperatorAfterGA = new XCSDeletionOperator();
176      ConditionalSelector deletionSelectorAfterGA = new ConditionalSelector();
177      LeftReducer leftReducerAfterGA = new LeftReducer();
178
179      classifierFetcher = new Placeholder();
180      actionExecuter = new Placeholder();
181      actionSetSubsumption = new Placeholder();
182
183      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("ZeroIntValue", new IntValue(0)));
184      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OneIntValue", new IntValue(1)));
185      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iteration", new IntValue(0)));
186      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
187
188      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iteration"));
189      resultsCollector.ResultsParameter.ActualName = "Results";
190
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
201      analyzer.Name = "Analyzer";
202      analyzer.OperatorParameter.ActualName = "Analyzer";
203
204      finalAnalyzer.Name = "FinalAnalyzer";
205      finalAnalyzer.OperatorParameter.ActualName = "FinalAnalyzer";
206
207      initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation";
208
209      initialSolutionsCreator.NumberOfSolutionsParameter.ActualName = "N";
210
211      initialPopulationSizeAssigner.LeftSideParameter.ActualName = "CurrentPopulationSize";
212      initialPopulationSizeAssigner.RightSideParameter.ActualName = "N";
213
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
221      iterationCounter.ValueParameter.ActualName = "Iteration";
222      iterationCounter.IncrementParameter.ActualName = "OneIntValue";
223
224      conditionMatchSelector.CopySelected = new BoolValue(false);
225      conditionMatchSelector.ConditionParameter.ActualName = matchConditionOperator.MatchConditionParameter.ActualName;
226
227      doDeletionBeforeCovering.MatchConditionParameter.ActualName = matchConditionOperator.MatchConditionParameter.ActualName;
228      doDeletionBeforeCovering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
229      doDeletionBeforeCovering.PopulationSizeParameter.ActualName = "N";
230
231      doDeletionBeforeCoveringConditionalBranch.ConditionParameter.ActualName = doDeletionBeforeCovering.DoDeletionParameter.ActualName;
232
233      setDeletionFalseAssigner.LeftSideParameter.ActualName = HASTOBEDELETED;
234      setDeletionFalseAssigner.RightSideParameter.Value = new BoolValue(false);
235
236      deletionOperator.NumberToDeleteParameter.ActualName = doDeletionBeforeCovering.NumberToDeleteParameter.ActualName;
237      deletionOperator.HasToBeDeletedParameter.ActualName = HASTOBEDELETED;
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
246      deletionSelector.ConditionParameter.ActualName = HASTOBEDELETED;
247      deletionSelector.CopySelected = new BoolValue(false);
248
249      covering.ActionsInMatchSetParameter.ActualName = countNumberOfUniqueActions.UniqueActionsParameter.ActualName;
250      covering.ParallelParameter.Value.Value = true;
251      covering.RandomParameter.ActualName = "Random";
252      covering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
253
254      matchActionSubScopesProcessor.Operator = matchActionOperator;
255
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
262      actionMatchSelector.CopySelected = new BoolValue(false);
263      actionMatchSelector.ConditionParameter.ActualName = "MatchAction";
264
265      actionSetSubsumptionBranch.ConditionParameter.ActualName = "DoActionSetSubsumption";
266
267      setSubsumedToFalseAssigner.LeftSideParameter.ActualName = HASBEENSUBSUMED;
268      setSubsumedToFalseAssigner.RightSideParameter.Value = new BoolValue(false);
269
270      subsumptionSelector.ConditionParameter.ActualName = HASBEENSUBSUMED;
271      subsumptionSelector.CopySelected = new BoolValue(false);
272
273      evaluator.Name = "Evaluator";
274
275      classifierFetcher.Name = "ClassifierFetcher";
276
277      actionExecuter.Name = "ActionExecuter";
278
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
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
317      adaptedGeneticAlgorithmMainLoop.RandomParameter.ActualName = "Random";
318      adaptedGeneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = "ZeroIntValue";
319      adaptedGeneticAlgorithmMainLoop.QualityParameter.ActualName = "Fitness";
320      adaptedGeneticAlgorithmMainLoop.MutationProbabilityParameter.ActualName = "MutationProbability";
321      adaptedGeneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true);
322      adaptedGeneticAlgorithmMainLoop.AfterCrossoverParameter.ActualName = AfterCrossoverParameter.Name;
323      adaptedGeneticAlgorithmMainLoop.AfterCopyingParentsParameter.ActualName = AfterCopyingParentsParameter.Name;
324
325      currentPopulationSizeCounter.ValueParameter.ActualName = "CurrentPopulationSize";
326      currentPopulationSizeCounter.Increment = new IntValue(2);
327
328      insertInPopulation.NumerositiesParameter.ActualName = "Numerosity";
329      insertInPopulation.HasToBeDeletedParameter.ActualName = HASTOBEDELETED;
330      insertInPopulation.InsertInPopulationParameter.ActualName = "InsertInPopulation";
331
332      calculateNumberOfDeletions.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
333      calculateNumberOfDeletions.PopulationSizeParameter.ActualName = "N";
334
335      deletionOperatorAfterGA.NumberToDeleteParameter.ActualName = calculateNumberOfDeletions.NumberOfDeletionsParameter.ActualName;
336      deletionOperatorAfterGA.HasToBeDeletedParameter.ActualName = HASTOBEDELETED;
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
345      deletionSelectorAfterGA.ConditionParameter.ActualName = HASTOBEDELETED;
346      deletionSelectorAfterGA.CopySelected = new BoolValue(false);
347      #endregion
348
349      #region Create operator graph
350      OperatorGraph.InitialOperator = variableCreator;
351
352      variableCreator.Successor = resultsCollector;
353      resultsCollector.Successor = initialPopulationConditionalBranch;
354      initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator;
355      initialSolutionsCreator.Successor = initialPopulationSizeAssigner;
356      initialPopulationConditionalBranch.FalseBranch = new EmptyOperator();
357      initialPopulationConditionalBranch.Successor = maxIterationsComparator;
358      maxIterationsComparator.Successor = terminationConditionalBranch1;
359      terminationConditionalBranch1.TrueBranch = finalAnalyzer;
360      terminationConditionalBranch1.FalseBranch = classifierFetcher;
361      classifierFetcher.Successor = matchCondtionSubScopesProcessor;
362      matchCondtionSubScopesProcessor.Operator = matchConditionOperator;
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;
373      conditionMatchSelector.Successor = matchSetSubScopesProcessor;
374      matchSetSubScopesProcessor.Operators.Add(new EmptyOperator());
375      matchSetSubScopesProcessor.Operators.Add(countNumberOfUniqueActions);
376      countNumberOfUniqueActions.Successor = covering;
377      matchSetSubScopesProcessor.Successor = matchSetMergingReducer;
378      covering.Successor = predictionArrayCalculator;
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;
391      updateParametersSubScopesProcessor.Successor = actionSetSubsumptionBranch;
392      actionSetSubsumptionBranch.TrueBranch = setSubsumedToFalseSubScopeProcessor;
393      setSubsumedToFalseSubScopeProcessor.Operator = setSubsumedToFalseAssigner;
394      setSubsumedToFalseSubScopeProcessor.Successor = actionSetSubsumption;
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;
405
406      actionSetSubScopesProcessor.Successor = actionSetMergingReducer;
407
408      matchSetMergingReducer.Successor = setDeletionFalseSubScopeProcessor2;
409      setDeletionFalseSubScopeProcessor2.Operator = setDeletionFalseAssigner;
410      setDeletionFalseSubScopeProcessor2.Successor = insertInPopulation;
411      insertInPopulation.Successor = calculateNumberOfDeletions;
412      calculateNumberOfDeletions.Successor = deletionOperatorAfterGA;
413      deletionOperatorAfterGA.Successor = deletionSelectorAfterGA;
414      deletionSelectorAfterGA.Successor = leftReducerAfterGA;
415      leftReducerAfterGA.Successor = iterationCounter;
416      iterationCounter.Successor = moduloOperator;
417      moduloOperator.Successor = analyzerComparator;
418      analyzerComparator.Successor = analyzerConditionalBranch;
419      analyzerConditionalBranch.Successor = maxIterationsComparator;
420      analyzerConditionalBranch.TrueBranch = analyzer;
421      #endregion
422    }
423
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
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
444      problem.ActionSetSubsumptionOperator.HasBeenSubsumedParameter.ActualName = HASBEENSUBSUMED;
445
446      actionSetSubsumption.OperatorParameter.ActualName = problem.ActionSetSubsumptionOperatorParameter.Name;
447
448      matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentInputToMatchParameter.ActualName;
449
450      doDeletionBeforeCovering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name;
451      doDeletionBeforeCovering.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name;
452
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
458      predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName;
459      predictionArrayCalculator.FitnessParameter.ActualName = problem.Evaluator.FitnessParameter.ActualName;
460      predictionArrayCalculator.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name;
461
462      countNumberOfUniqueActions.ClassifierComparerParameter.ActualName = problem.ClassifierComparerParameter.Name;
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);
472    }
473  }
474}
Note: See TracBrowser for help on using the repository browser.