[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 |
|
---|
| 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
[9089] | 25 | using HeuristicLab.Encodings.ConditionActionEncoding;
|
---|
[8941] | 26 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
| 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]
|
---|
[9089] | 40 | public sealed class LearningClassifierSystemMainLoop : AlgorithmOperator {
|
---|
[8941] | 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 | }
|
---|
[9105] | 52 | public IConstrainedValueParameter<IOperator> AfterCrossoverParameter {
|
---|
| 53 | get { return (IConstrainedValueParameter<IOperator>)Parameters["AfterCrossover"]; }
|
---|
| 54 | }
|
---|
[8941] | 55 | #endregion
|
---|
| 56 |
|
---|
[9089] | 57 | #region private properties
|
---|
| 58 | private SolutionsCreator initialSolutionsCreator;
|
---|
| 59 | private MatchConditionOperator matchConditionOperator;
|
---|
| 60 | private PredictionArrayCalculator predictionArrayCalculator;
|
---|
| 61 | private ActionSelector actionSelector;
|
---|
[9105] | 62 | private DoDeletionBeforeCoveringOperator doDeletionBeforeCovering;
|
---|
[9090] | 63 | private CoveringOperator covering;
|
---|
[9105] | 64 | private ConditionalSelector subsumptionSelector;
|
---|
[9089] | 65 |
|
---|
| 66 | private Placeholder evaluator;
|
---|
| 67 | private Placeholder actionExecuter;
|
---|
| 68 | private Placeholder classifierFetcher;
|
---|
[9105] | 69 | private Placeholder actionSetSubsumption;
|
---|
[8941] | 70 | #endregion
|
---|
| 71 |
|
---|
| 72 | [StorableConstructor]
|
---|
| 73 | private LearningClassifierSystemMainLoop(bool deserializing) : base(deserializing) { }
|
---|
[9089] | 74 | private LearningClassifierSystemMainLoop(LearningClassifierSystemMainLoop original, Cloner cloner)
|
---|
[8941] | 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()));
|
---|
[9089] | 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));
|
---|
[9105] | 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));
|
---|
[8941] | 95 | #endregion
|
---|
| 96 |
|
---|
| 97 | #region Create operators
|
---|
| 98 | VariableCreator variableCreator = new VariableCreator();
|
---|
[9089] | 99 | ConditionalBranch initialPopulationConditionalBranch = new ConditionalBranch();
|
---|
| 100 | initialSolutionsCreator = new SolutionsCreator();
|
---|
[9105] | 101 | Assigner initialPopulationSizeAssigner = new Assigner();
|
---|
[9089] | 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();
|
---|
[9090] | 111 | SubScopesProcessor matchSetSubScopesProcessor = new SubScopesProcessor();
|
---|
| 112 | CountNumberOfUniqueActions countNumberOfUniqueActions = new CountNumberOfUniqueActions();
|
---|
[9105] | 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();
|
---|
[9090] | 125 | covering = new CoveringOperator();
|
---|
[9105] | 126 | MergingReducer actionSetMergingReducer = new MergingReducer();
|
---|
| 127 | MergingReducer matchSetMergingReducer = new MergingReducer();
|
---|
[9089] | 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();
|
---|
[9105] | 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();
|
---|
[9089] | 142 | LCSAdaptedGeneticAlgorithm adaptedGeneticAlgorithmMainLoop = new LCSAdaptedGeneticAlgorithm();
|
---|
[9105] | 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();
|
---|
[8941] | 148 |
|
---|
[9089] | 149 | classifierFetcher = new Placeholder();
|
---|
| 150 | actionExecuter = new Placeholder();
|
---|
[9105] | 151 | actionSetSubsumption = new Placeholder();
|
---|
[8941] | 152 |
|
---|
| 153 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("ZeroIntValue", new IntValue(0)));
|
---|
| 154 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OneIntValue", new IntValue(1)));
|
---|
[9089] | 155 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iteration", new IntValue(0)));
|
---|
[9105] | 156 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
|
---|
[8941] | 157 |
|
---|
[9089] | 158 | initialPopulationConditionalBranch.ConditionParameter.ActualName = "CreateInitialPopulation";
|
---|
| 159 |
|
---|
| 160 | initialSolutionsCreator.NumberOfSolutionsParameter.ActualName = "N";
|
---|
| 161 |
|
---|
[9105] | 162 | initialPopulationSizeAssigner.LeftSideParameter.ActualName = "CurrentPopulationSize";
|
---|
| 163 | initialPopulationSizeAssigner.RightSideParameter.ActualName = "N";
|
---|
| 164 |
|
---|
[9089] | 165 | iterationCounter.ValueParameter.ActualName = "Iteration";
|
---|
| 166 | iterationCounter.IncrementParameter.ActualName = "OneIntValue";
|
---|
| 167 |
|
---|
| 168 | matchConditionOperator.MatchParameter.ActualName = "CombinedIntegerVector";
|
---|
| 169 |
|
---|
[8941] | 170 | conditionMatchSelector.CopySelected = new BoolValue(false);
|
---|
[9089] | 171 | conditionMatchSelector.ConditionParameter.ActualName = "MatchCondition";
|
---|
[8941] | 172 |
|
---|
[9105] | 173 | conditionMatchSelectorAfterDeletion.CopySelected = new BoolValue(false);
|
---|
| 174 | conditionMatchSelectorAfterDeletion.ConditionParameter.ActualName = "MatchCondition";
|
---|
| 175 |
|
---|
[9090] | 176 | countNumberOfUniqueActions.ClassifiersParameter.ActualName = "CombinedIntegerVector";
|
---|
[9089] | 177 |
|
---|
[9105] | 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 |
|
---|
[9090] | 200 | covering.ActionsInMatchSetParameter.ActualName = countNumberOfUniqueActions.UniqueActionsParameter.ActualName;
|
---|
| 201 | covering.ParallelParameter.Value.Value = true;
|
---|
| 202 | covering.RandomParameter.ActualName = "Random";
|
---|
[9105] | 203 | covering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
|
---|
[8941] | 204 |
|
---|
[9089] | 205 | matchActionSubScopesProcessor.Operator = matchActionOperator;
|
---|
[8941] | 206 |
|
---|
[9089] | 207 | matchActionOperator.MatchParameter.ActualName = "CombinedIntegerVector";
|
---|
| 208 | matchActionOperator.TargetMatchParameter.ActualName = actionSelector.SelectedActionParameter.ActualName;
|
---|
| 209 |
|
---|
| 210 | predictionArrayCalculator.MatchParameter.ActualName = "CombinedIntegerVector";
|
---|
[8941] | 211 |
|
---|
[9089] | 212 | actionSelector.PredictionArrayParameter.ActualName = predictionArrayCalculator.PredictionArrayParameter.Name;
|
---|
| 213 | actionSelector.RandomParameter.ActualName = "Random";
|
---|
| 214 | actionSelector.ExplorationProbabilityParameter.ActualName = "ExplorationProbability";
|
---|
| 215 |
|
---|
[8941] | 216 | actionMatchSelector.CopySelected = new BoolValue(false);
|
---|
[9089] | 217 | actionMatchSelector.ConditionParameter.ActualName = "MatchAction";
|
---|
[8941] | 218 |
|
---|
[9105] | 219 | actionSetSubsumptionBranch.ConditionParameter.ActualName = "DoActionSetSubsumption";
|
---|
| 220 |
|
---|
| 221 | subsumptionSelector.CopySelected = new BoolValue(false);
|
---|
| 222 |
|
---|
[8941] | 223 | SelectorParameter.Value.CopySelected = new BoolValue(true);
|
---|
[9105] | 224 | SelectorParameter.Value.NumberOfSelectedSubScopesParameter.Value = new IntValue(4);
|
---|
[8941] | 225 |
|
---|
[9089] | 226 | evaluator.Name = "Evaluator";
|
---|
[8941] | 227 |
|
---|
[9089] | 228 | classifierFetcher.Name = "ClassifierFetcher";
|
---|
[8941] | 229 |
|
---|
[9089] | 230 | actionExecuter.Name = "ActionExecuter";
|
---|
[8941] | 231 |
|
---|
[9089] | 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 |
|
---|
[9105] | 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 |
|
---|
[9089] | 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);
|
---|
[9105] | 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);
|
---|
[8941] | 297 | #endregion
|
---|
| 298 |
|
---|
| 299 | #region Create operator graph
|
---|
| 300 | OperatorGraph.InitialOperator = variableCreator;
|
---|
[9089] | 301 |
|
---|
| 302 | variableCreator.Successor = initialPopulationConditionalBranch;
|
---|
| 303 | initialPopulationConditionalBranch.TrueBranch = initialSolutionsCreator;
|
---|
[9105] | 304 | initialSolutionsCreator.Successor = initialPopulationSizeAssigner;
|
---|
[9089] | 305 | initialPopulationConditionalBranch.FalseBranch = new EmptyOperator();
|
---|
| 306 | initialPopulationConditionalBranch.Successor = classifierFetcher;
|
---|
| 307 | classifierFetcher.Successor = matchCondtionSubScopesProcessor;
|
---|
[9105] | 308 | matchCondtionSubScopesProcessor.Operator = matchConditionOperator;
|
---|
[9089] | 309 | matchCondtionSubScopesProcessor.Successor = conditionMatchSelector;
|
---|
[9090] | 310 | conditionMatchSelector.Successor = matchSetSubScopesProcessor;
|
---|
| 311 | matchSetSubScopesProcessor.Operators.Add(new EmptyOperator());
|
---|
| 312 | matchSetSubScopesProcessor.Operators.Add(countNumberOfUniqueActions);
|
---|
[9105] | 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 |
|
---|
[9090] | 333 | covering.Successor = predictionArrayCalculator;
|
---|
[9089] | 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;
|
---|
[9105] | 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;
|
---|
[9089] | 358 |
|
---|
[9105] | 359 | actionSetSubScopesProcessor.Successor = actionSetMergingReducer;
|
---|
[9089] | 360 |
|
---|
[9105] | 361 | matchSetMergingReducer.Successor = calculateNumberOfDeletions;
|
---|
| 362 | calculateNumberOfDeletions.Successor = deletionOperatorAfterGA;
|
---|
| 363 | deletionOperatorAfterGA.Successor = deletionSelectorAfterGA;
|
---|
| 364 | deletionSelectorAfterGA.Successor = leftReducerAfterGA;
|
---|
| 365 | leftReducerAfterGA.Successor = iterationCounter;
|
---|
[9089] | 366 | iterationCounter.Successor = classifierFetcher;
|
---|
[8941] | 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 | }
|
---|
[9089] | 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 |
|
---|
[9105] | 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 |
|
---|
[9090] | 402 | matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName;
|
---|
[9089] | 403 |
|
---|
[9105] | 404 | doDeletionBeforeCovering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name;
|
---|
| 405 |
|
---|
[9090] | 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 |
|
---|
[9089] | 411 | predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName;
|
---|
| 412 | predictionArrayCalculator.FitnessParameter.ActualName = problem.Evaluator.FitnessParameter.ActualName;
|
---|
| 413 | }
|
---|
[8941] | 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 | }
|
---|