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

Last change on this file since 9105 was 9105, checked in by sforsten, 6 years ago

#1980:

  • included an adapted version of GA correctly
  • added action set subsumption
  • added deletion after GA and before covering
File size: 25.5 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.Encodings.IntegerVectorEncoding;
27using HeuristicLab.Operators;
28using HeuristicLab.Optimization;
29using HeuristicLab.Optimization.Operators;
30using HeuristicLab.Parameters;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32using HeuristicLab.Selection;
33
34namespace HeuristicLab.Algorithms.LearningClassifierSystems {
35  /// <summary>
36  /// An operator which represents the main loop of a learning classifier system.
37  /// </summary>
38  [Item("LearningClassifierSystemMainLoop", "An operator which represents the main loop of a learning classifier system.")]
39  [StorableClass]
40  public sealed class LearningClassifierSystemMainLoop : AlgorithmOperator {
41
42    #region Parameter Properties
43    public IConstrainedValueParameter<ISelector> SelectorParameter {
44      get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
45    }
46    public IConstrainedValueParameter<ICrossover> CrossoverParameter {
47      get { return (IConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
48    }
49    public IConstrainedValueParameter<IManipulator> MutatorParameter {
50      get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
51    }
52    public IConstrainedValueParameter<IOperator> AfterCrossoverParameter {
53      get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; }
54    }
55    #endregion
56
57    #region private properties
58    private SolutionsCreator initialSolutionsCreator;
59    private MatchConditionOperator matchConditionOperator;
60    private PredictionArrayCalculator predictionArrayCalculator;
61    private ActionSelector actionSelector;
62    private DoDeletionBeforeCoveringOperator doDeletionBeforeCovering;
63    private CoveringOperator covering;
64    private ConditionalSelector subsumptionSelector;
65
66    private Placeholder evaluator;
67    private Placeholder actionExecuter;
68    private Placeholder classifierFetcher;
69    private Placeholder actionSetSubsumption;
70    #endregion
71
72    [StorableConstructor]
73    private LearningClassifierSystemMainLoop(bool deserializing) : base(deserializing) { }
74    private LearningClassifierSystemMainLoop(LearningClassifierSystemMainLoop original, Cloner cloner)
75      : base(original, cloner) {
76    }
77    public override IDeepCloneable Clone(Cloner cloner) {
78      return new LearningClassifierSystemMainLoop(this, cloner);
79    }
80    public LearningClassifierSystemMainLoop()
81      : base() {
82      Initialize();
83    }
84
85    private void Initialize() {
86      #region Create parameters
87      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.", new ItemSet<ISelector>() { new ProportionalSelector() }, new ProportionalSelector()));
88      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.", new ItemSet<ICrossover>() { new HeuristicLab.Encodings.CombinedIntegerVectorEncoding.SinglePointCrossover() }, new HeuristicLab.Encodings.CombinedIntegerVectorEncoding.SinglePointCrossover()));
89      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."));
90      UniformOnePositionManipulator test = new UniformOnePositionManipulator();
91      test.IntegerVectorParameter.ActualName = "CombinedIntegerVector";
92      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.", new ItemSet<IManipulator>() { new UniformOnePositionManipulator() }, test));
93      XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator();
94      Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "The operator used to select solutions for reproduction.", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover));
95      #endregion
96
97      #region Create operators
98      VariableCreator variableCreator = new VariableCreator();
99      ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch();
100      initialSolutionsCreator = new SolutionsCreator();
101      Assigner initialPopulationSizeAssigner = new Assigner();
102      IntCounter iterationCounter = new IntCounter();
103      UniformSubScopesProcessor matchCondtionSubScopesProcessor = new UniformSubScopesProcessor();
104      matchConditionOperator = new MatchConditionOperator();
105      predictionArrayCalculator = new PredictionArrayCalculator();
106      actionSelector = new ActionSelector();
107      UniformSubScopesProcessor matchActionSubScopesProcessor = new UniformSubScopesProcessor();
108      MatchActionOperator matchActionOperator = new MatchActionOperator();
109      ConditionalSelector conditionMatchSelector = new ConditionalSelector();
110      ConditionalSelector actionMatchSelector = new ConditionalSelector();
111      SubScopesProcessor matchSetSubScopesProcessor = new SubScopesProcessor();
112      CountNumberOfUniqueActions countNumberOfUniqueActions = new CountNumberOfUniqueActions();
113      doDeletionBeforeCovering = new DoDeletionBeforeCoveringOperator();
114      ConditionalBranch doDeletionBeforeCoveringConditionalBranch = new ConditionalBranch();
115      MergingReducer matchSetMergingReducerForDeletion = new MergingReducer();
116      SubScopeVariableCopier subscopeVariableCopier = new SubScopeVariableCopier();
117      XCSDeletionOperator deletionOperator = new XCSDeletionOperator();
118      ConditionalSelector deletionSelector = new ConditionalSelector();
119      LeftReducer leftReducerAfterDeletionSelection = new LeftReducer();
120      UniformSubScopesProcessor matchConditionAfterDeletionSubScopesProcessor = new UniformSubScopesProcessor();
121      ConditionalSelector conditionMatchSelectorAfterDeletion = new ConditionalSelector();
122      SubScopesProcessor matchSetAfterDeletionSubScopesProcessor = new SubScopesProcessor();
123      CountNumberOfUniqueActions countNumberOfUniqueActionsAfterDeletion = new CountNumberOfUniqueActions();
124      SubScopesProcessor coveringAfterDeletionSubScopesProcessor = new SubScopesProcessor();
125      covering = new CoveringOperator();
126      MergingReducer actionSetMergingReducer = new MergingReducer();
127      MergingReducer matchSetMergingReducer = new MergingReducer();
128      evaluator = new Placeholder();
129      SubScopesProcessor actionSetSubScopesProcessor = new SubScopesProcessor();
130      DataReducer actionSetSizeDataReducer = new DataReducer();
131      UniformSubScopesProcessor accuracySubScopesProcessor = new UniformSubScopesProcessor();
132      CalculateAccuracy calculateAccuracy = new CalculateAccuracy();
133      SumAccuracy sumAccuracy = new SumAccuracy();
134      UniformSubScopesProcessor updateParametersSubScopesProcessor = new UniformSubScopesProcessor();
135      ConditionalBranch actionSetSubsumptionBranch = new ConditionalBranch();
136      subsumptionSelector = new ConditionalSelector();
137      LeftReducer leftReducer = new LeftReducer();
138      XCSCheckIfGAShouldBeApplied checkIfGAShouldRun = new XCSCheckIfGAShouldBeApplied();
139      ConditionalBranch runGAConditionalBranch = new ConditionalBranch();
140      UniformSubScopesProcessor timestampAssignerSubscopeProcessor = new UniformSubScopesProcessor();
141      Assigner timestampAssigner = new Assigner();
142      LCSAdaptedGeneticAlgorithm adaptedGeneticAlgorithmMainLoop = new LCSAdaptedGeneticAlgorithm();
143      IntCounter currentPopulationSizeCounter = new IntCounter();
144      CalculateNumberOfDeletionsOperator calculateNumberOfDeletions = new CalculateNumberOfDeletionsOperator();
145      XCSDeletionOperator deletionOperatorAfterGA = new XCSDeletionOperator();
146      ConditionalSelector deletionSelectorAfterGA = new ConditionalSelector();
147      LeftReducer leftReducerAfterGA = new LeftReducer();
148
149      classifierFetcher = new Placeholder();
150      actionExecuter = new Placeholder();
151      actionSetSubsumption = new Placeholder();
152
153      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("ZeroIntValue", new IntValue(0)));
154      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OneIntValue", new IntValue(1)));
155      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iteration", new IntValue(0)));
156      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
157
158      initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation";
159
160      initialSolutionsCreator.NumberOfSolutionsParameter.ActualName = "N";
161
162      initialPopulationSizeAssigner.LeftSideParameter.ActualName = "CurrentPopulationSize";
163      initialPopulationSizeAssigner.RightSideParameter.ActualName = "N";
164
165      iterationCounter.ValueParameter.ActualName = "Iteration";
166      iterationCounter.IncrementParameter.ActualName = "OneIntValue";
167
168      matchConditionOperator.MatchParameter.ActualName = "CombinedIntegerVector";
169
170      conditionMatchSelector.CopySelected = new BoolValue(false);
171      conditionMatchSelector.ConditionParameter.ActualName = "MatchCondition";
172
173      conditionMatchSelectorAfterDeletion.CopySelected = new BoolValue(false);
174      conditionMatchSelectorAfterDeletion.ConditionParameter.ActualName = "MatchCondition";
175
176      countNumberOfUniqueActions.ClassifiersParameter.ActualName = "CombinedIntegerVector";
177
178      countNumberOfUniqueActionsAfterDeletion.ClassifiersParameter.ActualName = "CombinedIntegerVector";
179
180      subscopeVariableCopier.SubScopeIndexParameter.Value = new IntValue(1);
181
182      doDeletionBeforeCovering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
183      doDeletionBeforeCovering.NumberOfUniqueActionsParameter.ActualName = countNumberOfUniqueActions.NumberOfUniqueActionsParameter.ActualName;
184      doDeletionBeforeCovering.PopulationSizeParameter.ActualName = "N";
185
186      doDeletionBeforeCoveringConditionalBranch.ConditionParameter.ActualName = doDeletionBeforeCovering.DoDeletionParameter.ActualName;
187
188      deletionOperator.NumberToDeleteParameter.ActualName = doDeletionBeforeCovering.NumberToDeleteParameter.ActualName;
189      deletionOperator.AverageActionSetSizesParameter.ActualName = "AverageActionSetSize";
190      deletionOperator.FitnessesParameter.ActualName = "Fitness";
191      deletionOperator.NumerositiesParameter.ActualName = "Numerosity";
192      deletionOperator.ExperiencesParameter.ActualName = "Experience";
193      deletionOperator.ThetaDeletionParameter.ActualName = "ThetaDeletion";
194      deletionOperator.DeltaParameter.ActualName = "Delta";
195      deletionOperator.RandomParameter.ActualName = "Random";
196
197      deletionSelector.ConditionParameter.ActualName = deletionOperator.HasToBeDeletedVariableName;
198      deletionSelector.CopySelected = new BoolValue(false);
199
200      covering.ActionsInMatchSetParameter.ActualName = countNumberOfUniqueActions.UniqueActionsParameter.ActualName;
201      covering.ParallelParameter.Value.Value = true;
202      covering.RandomParameter.ActualName = "Random";
203      covering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
204
205      matchActionSubScopesProcessor.Operator = matchActionOperator;
206
207      matchActionOperator.MatchParameter.ActualName = "CombinedIntegerVector";
208      matchActionOperator.TargetMatchParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
209
210      predictionArrayCalculator.MatchParameter.ActualName = "CombinedIntegerVector";
211
212      actionSelector.PredictionArrayParameter.ActualName = predictionArrayCalculator.PredictionArrayParameter.Name;
213      actionSelector.RandomParameter.ActualName = "Random";
214      actionSelector.ExplorationProbabilityParameter.ActualName = "ExplorationProbability";
215
216      actionMatchSelector.CopySelected = new BoolValue(false);
217      actionMatchSelector.ConditionParameter.ActualName = "MatchAction";
218
219      actionSetSubsumptionBranch.ConditionParameter.ActualName = "DoActionSetSubsumption";
220
221      subsumptionSelector.CopySelected = new BoolValue(false);
222
223      SelectorParameter.Value.CopySelected = new BoolValue(true);
224      SelectorParameter.Value.NumberOfSelectedSubScopesParameter.Value = new IntValue(4);
225
226      evaluator.Name = "Evaluator";
227
228      classifierFetcher.Name = "ClassifierFetcher";
229
230      actionExecuter.Name = "ActionExecuter";
231
232      actionSetSizeDataReducer.TargetParameter.ActualName = "CurrentActionSetSize";
233      actionSetSizeDataReducer.ParameterToReduce.ActualName = "Numerosity";
234      actionSetSizeDataReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
235      actionSetSizeDataReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
236
237      calculateAccuracy.AlphaParameter.ActualName = "Alpha";
238      calculateAccuracy.ErrorParameter.ActualName = "Error";
239      calculateAccuracy.ErrorZeroParameter.ActualName = "ErrorZero";
240      calculateAccuracy.PowerParameter.ActualName = "v";
241
242      sumAccuracy.AccuracyParameter.ActualName = calculateAccuracy.AccuracyParameter.ActualName;
243      sumAccuracy.NumerosityParameter.ActualName = "Numerosity";
244
245      //BEGIN parameters have to be set differently
246      checkIfGAShouldRun.TimeStampsParameter.ActualName = "Timestamp";
247      checkIfGAShouldRun.NumerositiesParameter.ActualName = "Numerosity";
248      checkIfGAShouldRun.ThetaGAParameter.ActualName = "ThetaGA";
249      //END
250      checkIfGAShouldRun.IterationParameter.ActualName = iterationCounter.ValueParameter.ActualName;
251
252      runGAConditionalBranch.ConditionParameter.ActualName = checkIfGAShouldRun.RunGAParameter.ActualName;
253
254      timestampAssigner.LeftSideParameter.ActualName = "Timestamp";
255      timestampAssigner.RightSideParameter.ActualName = iterationCounter.ValueParameter.ActualName;
256
257      afterCrossover.NumerosityParameter.ActualName = "Numerosity";
258      afterCrossover.ExperienceParameter.ActualName = "Experience";
259      afterCrossover.TimestampParameter.ActualName = "Timestamp";
260      afterCrossover.CurrentIterationParameter.ActualName = "Iteration";
261      afterCrossover.FitnessParameter.ActualName = "Fitness";
262      afterCrossover.AverageActionSetSizeParameter.ActualName = "AverageActionSetSize";
263      afterCrossover.PredictionParameter.ActualName = "Prediction";
264      afterCrossover.ErrorParameter.ActualName = "Error";
265      afterCrossover.ParentFitnessParameter.ActualName = "Fitness";
266      afterCrossover.ParentErrorParameter.ActualName = "Error";
267      afterCrossover.ParentPredictionParameter.ActualName = "Prediction";
268      afterCrossover.ParentAverageActionSetSizeParameter.ActualName = "AverageActionSetSize";
269
270      adaptedGeneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
271      adaptedGeneticAlgorithmMainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
272      adaptedGeneticAlgorithmMainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
273      adaptedGeneticAlgorithmMainLoop.RandomParameter.ActualName = "Random";
274      adaptedGeneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = "ZeroIntValue";
275      adaptedGeneticAlgorithmMainLoop.QualityParameter.ActualName = "Fitness";
276      adaptedGeneticAlgorithmMainLoop.MutationProbabilityParameter.Value = new PercentValue(10);
277      adaptedGeneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true);
278      adaptedGeneticAlgorithmMainLoop.AfterCrossoverParameter.ActualName = AfterCrossoverParameter.Name;
279
280      currentPopulationSizeCounter.ValueParameter.ActualName = "CurrentPopulationSize";
281      currentPopulationSizeCounter.Increment = new IntValue(2);
282
283      calculateNumberOfDeletions.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
284      calculateNumberOfDeletions.PopulationSizeParameter.ActualName = "N";
285
286      deletionOperatorAfterGA.NumberToDeleteParameter.ActualName = calculateNumberOfDeletions.NumberOfDeletionsParameter.ActualName;
287      deletionOperatorAfterGA.AverageActionSetSizesParameter.ActualName = "AverageActionSetSize";
288      deletionOperatorAfterGA.FitnessesParameter.ActualName = "Fitness";
289      deletionOperatorAfterGA.NumerositiesParameter.ActualName = "Numerosity";
290      deletionOperatorAfterGA.ExperiencesParameter.ActualName = "Experience";
291      deletionOperatorAfterGA.ThetaDeletionParameter.ActualName = "ThetaDeletion";
292      deletionOperatorAfterGA.DeltaParameter.ActualName = "Delta";
293      deletionOperatorAfterGA.RandomParameter.ActualName = "Random";
294
295      deletionSelectorAfterGA.ConditionParameter.ActualName = deletionOperatorAfterGA.HasToBeDeletedVariableName;
296      deletionSelectorAfterGA.CopySelected = new BoolValue(false);
297      #endregion
298
299      #region Create operator graph
300      OperatorGraph.InitialOperator = variableCreator;
301
302      variableCreator.Successor = initialPopulationConditionalBranch;
303      initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator;
304      initialSolutionsCreator.Successor = initialPopulationSizeAssigner;
305      initialPopulationConditionalBranch.FalseBranch = new EmptyOperator();
306      initialPopulationConditionalBranch.Successor = classifierFetcher;
307      classifierFetcher.Successor = matchCondtionSubScopesProcessor;
308      matchCondtionSubScopesProcessor.Operator = matchConditionOperator;
309      matchCondtionSubScopesProcessor.Successor = conditionMatchSelector;
310      conditionMatchSelector.Successor = matchSetSubScopesProcessor;
311      matchSetSubScopesProcessor.Operators.Add(new EmptyOperator());
312      matchSetSubScopesProcessor.Operators.Add(countNumberOfUniqueActions);
313      matchSetSubScopesProcessor.Successor = subscopeVariableCopier;
314      subscopeVariableCopier.Successor = doDeletionBeforeCovering;
315      doDeletionBeforeCovering.Successor = doDeletionBeforeCoveringConditionalBranch;
316      doDeletionBeforeCoveringConditionalBranch.TrueBranch = matchSetMergingReducerForDeletion;
317      matchSetMergingReducerForDeletion.Successor = deletionOperator;
318      deletionOperator.Successor = deletionSelector;
319      deletionSelector.Successor = leftReducerAfterDeletionSelection;
320      leftReducerAfterDeletionSelection.Successor = matchConditionAfterDeletionSubScopesProcessor;
321      doDeletionBeforeCoveringConditionalBranch.FalseBranch = coveringAfterDeletionSubScopesProcessor;
322      coveringAfterDeletionSubScopesProcessor.Operators.Add(new EmptyOperator());
323      coveringAfterDeletionSubScopesProcessor.Operators.Add(covering);
324      coveringAfterDeletionSubScopesProcessor.Successor = matchSetMergingReducer;
325      matchConditionAfterDeletionSubScopesProcessor.Operator = matchConditionOperator;
326      matchConditionAfterDeletionSubScopesProcessor.Successor = conditionMatchSelectorAfterDeletion;
327      conditionMatchSelectorAfterDeletion.Successor = matchSetAfterDeletionSubScopesProcessor;
328      matchSetAfterDeletionSubScopesProcessor.Operators.Add(new EmptyOperator());
329      matchSetAfterDeletionSubScopesProcessor.Operators.Add(countNumberOfUniqueActionsAfterDeletion);
330      matchSetAfterDeletionSubScopesProcessor.Successor = matchSetMergingReducer;
331      countNumberOfUniqueActionsAfterDeletion.Successor = covering;
332
333      covering.Successor = predictionArrayCalculator;
334      predictionArrayCalculator.Successor = actionSelector;
335      actionSelector.Successor = matchActionSubScopesProcessor;
336      matchActionSubScopesProcessor.Successor = actionMatchSelector;
337      actionMatchSelector.Successor = actionExecuter;
338      actionExecuter.Successor = actionSetSubScopesProcessor;
339      actionSetSubScopesProcessor.Operators.Add(new EmptyOperator());
340      actionSetSubScopesProcessor.Operators.Add(actionSetSizeDataReducer);
341      actionSetSizeDataReducer.Successor = accuracySubScopesProcessor;
342      accuracySubScopesProcessor.Operator = calculateAccuracy;
343      accuracySubScopesProcessor.Successor = sumAccuracy;
344      sumAccuracy.Successor = updateParametersSubScopesProcessor;
345      updateParametersSubScopesProcessor.Operator = evaluator;
346      updateParametersSubScopesProcessor.Successor = actionSetSubsumptionBranch;
347      actionSetSubsumptionBranch.TrueBranch = actionSetSubsumption;
348      actionSetSubsumption.Successor = subsumptionSelector;
349      subsumptionSelector.Successor = leftReducer;
350      actionSetSubsumptionBranch.FalseBranch = new EmptyOperator();
351      actionSetSubsumptionBranch.Successor = checkIfGAShouldRun;
352      checkIfGAShouldRun.Successor = runGAConditionalBranch;
353      runGAConditionalBranch.TrueBranch = timestampAssignerSubscopeProcessor;
354      runGAConditionalBranch.FalseBranch = new EmptyOperator();
355      timestampAssignerSubscopeProcessor.Operator = timestampAssigner;
356      timestampAssignerSubscopeProcessor.Successor = adaptedGeneticAlgorithmMainLoop;
357      adaptedGeneticAlgorithmMainLoop.Successor = currentPopulationSizeCounter;
358
359      actionSetSubScopesProcessor.Successor = actionSetMergingReducer;
360
361      matchSetMergingReducer.Successor = calculateNumberOfDeletions;
362      calculateNumberOfDeletions.Successor = deletionOperatorAfterGA;
363      deletionOperatorAfterGA.Successor = deletionSelectorAfterGA;
364      deletionSelectorAfterGA.Successor = leftReducerAfterGA;
365      leftReducerAfterGA.Successor = iterationCounter;
366      iterationCounter.Successor = classifierFetcher;
367      #endregion
368    }
369
370    private void ParameterizeStochasticOperator(IOperator op) {
371      IStochasticOperator stochasticOp = op as IStochasticOperator;
372      if (stochasticOp != null) {
373        stochasticOp.RandomParameter.ActualName = "Random";
374        stochasticOp.RandomParameter.Hidden = true;
375      }
376    }
377
378    internal void SetCurrentProblem(IConditionActionProblem problem) {
379      initialSolutionsCreator.SolutionCreatorParameter.ActualName = problem.SolutionCreatorParameter.Name;
380      initialSolutionsCreator.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;
381
382      problem.ActionExecuter.SelectedActionParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
383
384      problem.ClassifierFetcher.IterationParameter.ActualName = "Iteration";
385
386      evaluator.OperatorParameter.ActualName = problem.EvaluatorParameter.Name;
387
388      classifierFetcher.OperatorParameter.ActualName = problem.ClassifierFetcherParameter.Name;
389
390      actionExecuter.OperatorParameter.ActualName = problem.ActionExecuterParameter.Name;
391
392      problem.ActionSetSubsumptionOperator.ThetaSubsumptionParameter.ActualName = "ThetaSubsumption";
393      problem.ActionSetSubsumptionOperator.ErrorsParameter.ActualName = "Error";
394      problem.ActionSetSubsumptionOperator.ErrorZeroParameter.ActualName = "ErrorZero";
395      problem.ActionSetSubsumptionOperator.ExperiencesParameter.ActualName = "Experience";
396      problem.ActionSetSubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity";
397
398      subsumptionSelector.ConditionParameter.ActualName = problem.ActionSetSubsumptionOperator.HasBeenSubsumedParameterName;
399
400      actionSetSubsumption.OperatorParameter.ActualName = problem.ActionSetSubsumptionOperatorParameter.Name;
401
402      matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;
403
404      doDeletionBeforeCovering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name;
405
406      covering.SolutionCreatorParameter.ActualName = problem.CoveringSolutionCreatorParameter.Name;
407      covering.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;
408      covering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name;
409      covering.PossibleActionsParameter.ActualName = problem.PossibleActionsParameter.Name;
410
411      predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName;
412      predictionArrayCalculator.FitnessParameter.ActualName = problem.Evaluator.FitnessParameter.ActualName;
413    }
414    //private void ParameterizeSelectors() {
415    //  foreach (ISelector selector in SelectorParameter.ValidValues) {
416    //    selector.CopySelected = new BoolValue(true);
417    //    //set value by parameter!
418    //    selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(5);
419    //    selector.NumberOfSelectedSubScopesParameter.Hidden = true;
420    //    ParameterizeStochasticOperator(selector);
421    //  }
422    //  if (Problem != null) {
423    //    foreach (ISingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
424    //      selector.MaximizationParameter.Value = new BoolValue(true);
425    //      selector.MaximizationParameter.Hidden = true;
426    //      selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
427    //      selector.QualityParameter.Hidden = true;
428    //    }
429    //  }
430    //}
431  }
432}
Note: See TracBrowser for help on using the repository browser.