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