Changeset 9110 for branches/LearningClassifierSystems
- Timestamp:
- 01/04/13 20:46:18 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 4 added
- 1 deleted
- 16 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LCSAdaptedGeneticAlgorithm.cs
r9105 r9110 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.ConditionActionEncoding; 26 27 using HeuristicLab.Operators; 27 28 using HeuristicLab.Optimization.Operators; … … 36 37 [StorableClass] 37 38 public sealed class LCSAdaptedGeneticAlgorithm : AlgorithmOperator { 39 private const string TEMPID = "TempID"; 40 private const string SUBSUMEDBY = "SubsumedBy"; 41 private const string SUBSUMED = "Subsumed"; 42 38 43 #region Parameter properties 39 44 public ValueLookupParameter<IRandom> RandomParameter { … … 75 80 public ValueLookupParameter<IntValue> PopulationSizeParameter { 76 81 get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; } 82 } 83 public ValueLookupParameter<BoolValue> DoGASubsumptionParameter { 84 get { return (ValueLookupParameter<BoolValue>)Parameters["DoGASubsumption"]; } 77 85 } 78 86 private ScopeParameter CurrentScopeParameter { … … 113 121 Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 114 122 Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population.")); 123 Parameters.Add(new ValueLookupParameter<BoolValue>("DoGASubsumption", "Sets if GA subsumption is executed.")); 115 124 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied.")); 116 125 #endregion … … 126 135 Placeholder crossover = new Placeholder(); 127 136 Placeholder afterCrossover = new Placeholder(); 128 StochasticBranch stochasticBranch = new StochasticBranch();129 137 Placeholder mutator = new Placeholder(); 130 138 SubScopesRemover subScopesRemover = new SubScopesRemover(); … … 136 144 ConditionalBranch conditionalBranch = new ConditionalBranch(); 137 145 146 TempSubScopeIDAssigner tempIdAssigner = new TempSubScopeIDAssigner(); 147 ConditionalBranch doGASubsumptionBranch1 = new ConditionalBranch(); 148 UniformSubScopesProcessor setSubsumptionFalseSubScopesProcessor = new UniformSubScopesProcessor(); 149 Assigner setSubsumpByAssigner = new Assigner(); 150 Assigner setSubsumptionFalseAssigner = new Assigner(); 151 CheckGASubsumptionOperator checkGASubsumptionOperator = new CheckGASubsumptionOperator(); 152 ConditionalBranch doGASubsumptionBranch2 = new ConditionalBranch(); 153 ExecuteGASubsumptionOperator executeGAsubsumptionOperator = new ExecuteGASubsumptionOperator(); 154 ConditionalSelector subsumptionSelector = new ConditionalSelector(); 155 LeftReducer subsumptionLeftReducer = new LeftReducer(); 156 138 157 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations 139 158 … … 144 163 analyzer1.OperatorParameter.ActualName = "Analyzer"; 145 164 165 tempIdAssigner.LeftSideParameter.ActualName = TEMPID; 166 167 setSubsumpByAssigner.LeftSideParameter.ActualName = SUBSUMEDBY; 168 setSubsumpByAssigner.RightSideParameter.Value = new IntValue(-1); 169 170 setSubsumptionFalseAssigner.LeftSideParameter.ActualName = SUBSUMED; 171 setSubsumptionFalseAssigner.RightSideParameter.Value = new BoolValue(false); 172 146 173 selector.Name = "Selector"; 147 174 selector.OperatorParameter.ActualName = "Selector"; … … 155 182 afterCrossover.OperatorParameter.ActualName = "AfterCrossover"; 156 183 157 stochasticBranch.ProbabilityParameter.ActualName = "MutationProbability";158 stochasticBranch.RandomParameter.ActualName = "Random";159 160 184 mutator.Name = "Mutator"; 161 185 mutator.OperatorParameter.ActualName = "Mutator"; 162 186 187 doGASubsumptionBranch1.ConditionParameter.ActualName = DoGASubsumptionParameter.ActualName; 188 189 checkGASubsumptionOperator.ChildClassifiersParameter.ActualName = "CombinedIntegerVector"; 190 checkGASubsumptionOperator.ParentsClassifiersParameter.ActualName = "CombinedIntegerVector"; 191 checkGASubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity"; 192 checkGASubsumptionOperator.ExperiencesParameter.ActualName = "Experience"; 193 checkGASubsumptionOperator.ErrorsParameter.ActualName = "Error"; 194 checkGASubsumptionOperator.TempIDParameter.ActualName = TEMPID; 195 checkGASubsumptionOperator.ErrorZeroParameter.ActualName = "ErrorZero"; 196 checkGASubsumptionOperator.ThetaSubsumptionParameter.ActualName = "ThetaSubsumption"; 197 checkGASubsumptionOperator.SubsumedByParameter.ActualName = SUBSUMEDBY; 198 checkGASubsumptionOperator.SubsumedParameter.ActualName = SUBSUMED; 199 163 200 subScopesRemover.RemoveAllSubScopes = true; 201 202 doGASubsumptionBranch2.ConditionParameter.ActualName = DoGASubsumptionParameter.ActualName; 203 204 executeGAsubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity"; 205 executeGAsubsumptionOperator.TempIDParameter.ActualName = TEMPID; 206 executeGAsubsumptionOperator.SubsumedByParameter.ActualName = SUBSUMEDBY; 207 208 subsumptionSelector.ConditionParameter.ActualName = SUBSUMED; 209 subsumptionSelector.CopySelected = new BoolValue(false); 164 210 165 211 subScopesCounter.Name = "Increment EvaluatedSolutions"; … … 184 230 variableCreator.Successor = resultsCollector1; 185 231 resultsCollector1.Successor = analyzer1; 186 analyzer1.Successor = selector; 232 analyzer1.Successor = tempIdAssigner; 233 tempIdAssigner.Successor = setSubsumptionFalseSubScopesProcessor; 234 setSubsumptionFalseSubScopesProcessor.Operator = setSubsumpByAssigner; 235 setSubsumpByAssigner.Successor = setSubsumptionFalseAssigner; 236 setSubsumptionFalseAssigner.Successor = null; 237 setSubsumptionFalseSubScopesProcessor.Successor = selector; 187 238 selector.Successor = subScopesProcessor1; 188 239 subScopesProcessor1.Operators.Add(new EmptyOperator()); … … 193 244 uniformSubScopesProcessor1.Successor = subScopesCounter; 194 245 crossover.Successor = afterCrossover; 195 afterCrossover.Successor = stochasticBranch;196 stochasticBranch.FirstBranch = mutator;197 stochasticBranch.SecondBranch = null;198 stochasticBranch.Successor = subScopesRemover;199 mutator.Successor = null;246 afterCrossover.Successor = mutator; 247 mutator.Successor = doGASubsumptionBranch1; 248 doGASubsumptionBranch1.TrueBranch = checkGASubsumptionOperator; 249 doGASubsumptionBranch1.FalseBranch = new EmptyOperator(); 250 doGASubsumptionBranch1.Successor = subScopesRemover; 200 251 subScopesRemover.Successor = null; 201 252 subScopesCounter.Successor = null; 202 mergingReducer.Successor = intCounter; 253 mergingReducer.Successor = doGASubsumptionBranch2; 254 doGASubsumptionBranch2.TrueBranch = executeGAsubsumptionOperator; 255 doGASubsumptionBranch2.FalseBranch = new EmptyOperator(); 256 executeGAsubsumptionOperator.Successor = subsumptionSelector; 257 subsumptionSelector.Successor = subsumptionLeftReducer; 258 subsumptionLeftReducer.Successor = null; 259 doGASubsumptionBranch2.Successor = intCounter; 203 260 intCounter.Successor = comparator; 204 261 comparator.Successor = analyzer2; -
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs
r9105 r9110 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.CombinedIntegerVectorEncoding; 25 26 using HeuristicLab.Encodings.ConditionActionEncoding; 26 using HeuristicLab.Encodings.IntegerVectorEncoding;27 27 using HeuristicLab.Operators; 28 28 using HeuristicLab.Optimization; … … 39 39 [StorableClass] 40 40 public sealed class LearningClassifierSystemMainLoop : AlgorithmOperator { 41 private const string HASTOBEDELETED = "HasToBeDeleted"; 42 private const string HASBEENSUBSUMED = "HasBeenSubsumed"; 41 43 42 44 #region Parameter Properties … … 62 64 private DoDeletionBeforeCoveringOperator doDeletionBeforeCovering; 63 65 private CoveringOperator covering; 64 private ConditionalSelector subsumptionSelector; 66 67 private UniformSomePositionManipulator test; 65 68 66 69 private Placeholder evaluator; … … 88 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())); 89 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.")); 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 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)); 93 97 XCSAfterCrossoverOperator afterCrossover = new XCSAfterCrossoverOperator(); 94 98 Parameters.Add(new ConstrainedValueParameter<IOperator>("AfterCrossover", "The operator used to select solutions for reproduction.", new ItemSet<IOperator>() { new XCSAfterCrossoverOperator() }, afterCrossover)); … … 113 117 doDeletionBeforeCovering = new DoDeletionBeforeCoveringOperator(); 114 118 ConditionalBranch doDeletionBeforeCoveringConditionalBranch = new ConditionalBranch(); 115 MergingReducer matchSetMergingReducerForDeletion = new MergingReducer();116 SubScopeVariableCopier subscopeVariableCopier = new SubScopeVariableCopier();117 119 XCSDeletionOperator deletionOperator = new XCSDeletionOperator(); 118 120 ConditionalSelector deletionSelector = new ConditionalSelector(); 119 121 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 122 covering = new CoveringOperator(); 126 123 MergingReducer actionSetMergingReducer = new MergingReducer(); … … 134 131 UniformSubScopesProcessor updateParametersSubScopesProcessor = new UniformSubScopesProcessor(); 135 132 ConditionalBranch actionSetSubsumptionBranch = new ConditionalBranch(); 136 subsumptionSelector = new ConditionalSelector(); 133 UniformSubScopesProcessor setSubsumedToFalseSubScopeProcessor = new UniformSubScopesProcessor(); 134 Assigner setSubsumedToFalseAssigner = new Assigner(); 135 ConditionalSelector subsumptionSelector = new ConditionalSelector(); 137 136 LeftReducer leftReducer = new LeftReducer(); 138 137 XCSCheckIfGAShouldBeApplied checkIfGAShouldRun = new XCSCheckIfGAShouldBeApplied(); … … 143 142 IntCounter currentPopulationSizeCounter = new IntCounter(); 144 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(); 145 148 XCSDeletionOperator deletionOperatorAfterGA = new XCSDeletionOperator(); 146 149 ConditionalSelector deletionSelectorAfterGA = new ConditionalSelector(); … … 169 172 170 173 conditionMatchSelector.CopySelected = new BoolValue(false); 171 conditionMatchSelector.ConditionParameter.ActualName = "MatchCondition"; 172 173 conditionMatchSelectorAfterDeletion.CopySelected = new BoolValue(false); 174 conditionMatchSelectorAfterDeletion.ConditionParameter.ActualName = "MatchCondition"; 174 conditionMatchSelector.ConditionParameter.ActualName = matchConditionOperator.MatchConditionParameter.ActualName; 175 175 176 176 countNumberOfUniqueActions.ClassifiersParameter.ActualName = "CombinedIntegerVector"; 177 177 178 countNumberOfUniqueActionsAfterDeletion.ClassifiersParameter.ActualName = "CombinedIntegerVector"; 179 180 subscopeVariableCopier.SubScopeIndexParameter.Value = new IntValue(1); 181 178 doDeletionBeforeCovering.ClassifiersParameter.ActualName = "CombinedIntegerVector"; 179 doDeletionBeforeCovering.MatchConditionParameter.ActualName = matchConditionOperator.MatchConditionParameter.ActualName; 182 180 doDeletionBeforeCovering.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize"; 183 doDeletionBeforeCovering.NumberOfUniqueActionsParameter.ActualName = countNumberOfUniqueActions.NumberOfUniqueActionsParameter.ActualName;184 181 doDeletionBeforeCovering.PopulationSizeParameter.ActualName = "N"; 185 182 186 183 doDeletionBeforeCoveringConditionalBranch.ConditionParameter.ActualName = doDeletionBeforeCovering.DoDeletionParameter.ActualName; 187 184 185 setDeletionFalseAssigner.LeftSideParameter.ActualName = HASTOBEDELETED; 186 setDeletionFalseAssigner.RightSideParameter.Value = new BoolValue(false); 187 188 188 deletionOperator.NumberToDeleteParameter.ActualName = doDeletionBeforeCovering.NumberToDeleteParameter.ActualName; 189 deletionOperator.HasToBeDeletedParameter.ActualName = HASTOBEDELETED; 189 190 deletionOperator.AverageActionSetSizesParameter.ActualName = "AverageActionSetSize"; 190 191 deletionOperator.FitnessesParameter.ActualName = "Fitness"; … … 195 196 deletionOperator.RandomParameter.ActualName = "Random"; 196 197 197 deletionSelector.ConditionParameter.ActualName = deletionOperator.HasToBeDeletedVariableName;198 deletionSelector.ConditionParameter.ActualName = HASTOBEDELETED; 198 199 deletionSelector.CopySelected = new BoolValue(false); 199 200 … … 219 220 actionSetSubsumptionBranch.ConditionParameter.ActualName = "DoActionSetSubsumption"; 220 221 222 setSubsumedToFalseAssigner.LeftSideParameter.ActualName = HASBEENSUBSUMED; 223 setSubsumedToFalseAssigner.RightSideParameter.Value = new BoolValue(false); 224 225 subsumptionSelector.ConditionParameter.ActualName = HASBEENSUBSUMED; 221 226 subsumptionSelector.CopySelected = new BoolValue(false); 222 227 … … 274 279 adaptedGeneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = "ZeroIntValue"; 275 280 adaptedGeneticAlgorithmMainLoop.QualityParameter.ActualName = "Fitness"; 276 adaptedGeneticAlgorithmMainLoop.MutationProbabilityParameter. Value = new PercentValue(10);281 adaptedGeneticAlgorithmMainLoop.MutationProbabilityParameter.ActualName = "MutationProbability"; 277 282 adaptedGeneticAlgorithmMainLoop.MaximizationParameter.Value = new BoolValue(true); 278 283 adaptedGeneticAlgorithmMainLoop.AfterCrossoverParameter.ActualName = AfterCrossoverParameter.Name; … … 281 286 currentPopulationSizeCounter.Increment = new IntValue(2); 282 287 288 insertInPopulation.ClassifiersParameter.ActualName = "CombinedIntegerVector"; 289 insertInPopulation.NumerositiesParameter.ActualName = "Numerosity"; 290 insertInPopulation.HasToBeDeletedParameter.ActualName = HASTOBEDELETED; 291 insertInPopulation.InsertInPopulationParameter.ActualName = "InsertInPopulation"; 292 283 293 calculateNumberOfDeletions.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize"; 284 294 calculateNumberOfDeletions.PopulationSizeParameter.ActualName = "N"; 285 295 286 296 deletionOperatorAfterGA.NumberToDeleteParameter.ActualName = calculateNumberOfDeletions.NumberOfDeletionsParameter.ActualName; 297 deletionOperatorAfterGA.HasToBeDeletedParameter.ActualName = HASTOBEDELETED; 287 298 deletionOperatorAfterGA.AverageActionSetSizesParameter.ActualName = "AverageActionSetSize"; 288 299 deletionOperatorAfterGA.FitnessesParameter.ActualName = "Fitness"; … … 293 304 deletionOperatorAfterGA.RandomParameter.ActualName = "Random"; 294 305 295 deletionSelectorAfterGA.ConditionParameter.ActualName = deletionOperatorAfterGA.HasToBeDeletedVariableName;306 deletionSelectorAfterGA.ConditionParameter.ActualName = HASTOBEDELETED; 296 307 deletionSelectorAfterGA.CopySelected = new BoolValue(false); 297 308 #endregion … … 307 318 classifierFetcher.Successor = matchCondtionSubScopesProcessor; 308 319 matchCondtionSubScopesProcessor.Operator = matchConditionOperator; 309 matchCondtionSubScopesProcessor.Successor = conditionMatchSelector; 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; 310 330 conditionMatchSelector.Successor = matchSetSubScopesProcessor; 311 331 matchSetSubScopesProcessor.Operators.Add(new EmptyOperator()); 312 332 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 countNumberOfUniqueActions.Successor = covering; 334 matchSetSubScopesProcessor.Successor = matchSetMergingReducer; 333 335 covering.Successor = predictionArrayCalculator; 334 336 predictionArrayCalculator.Successor = actionSelector; … … 345 347 updateParametersSubScopesProcessor.Operator = evaluator; 346 348 updateParametersSubScopesProcessor.Successor = actionSetSubsumptionBranch; 347 actionSetSubsumptionBranch.TrueBranch = actionSetSubsumption; 349 actionSetSubsumptionBranch.TrueBranch = setSubsumedToFalseSubScopeProcessor; 350 setSubsumedToFalseSubScopeProcessor.Operator = setSubsumedToFalseAssigner; 351 setSubsumedToFalseSubScopeProcessor.Successor = actionSetSubsumption; 348 352 actionSetSubsumption.Successor = subsumptionSelector; 349 353 subsumptionSelector.Successor = leftReducer; … … 359 363 actionSetSubScopesProcessor.Successor = actionSetMergingReducer; 360 364 361 matchSetMergingReducer.Successor = calculateNumberOfDeletions; 365 matchSetMergingReducer.Successor = setDeletionFalseSubScopeProcessor2; 366 setDeletionFalseSubScopeProcessor2.Operator = setDeletionFalseAssigner; 367 setDeletionFalseSubScopeProcessor2.Successor = insertInPopulation; 368 insertInPopulation.Successor = calculateNumberOfDeletions; 362 369 calculateNumberOfDeletions.Successor = deletionOperatorAfterGA; 363 370 deletionOperatorAfterGA.Successor = deletionSelectorAfterGA; … … 388 395 classifierFetcher.OperatorParameter.ActualName = problem.ClassifierFetcherParameter.Name; 389 396 397 test.FetchedClassifierParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName; 398 test.PossibleActionsParameter.ActualName = problem.PossibleActionsConcreteClassParameter.Name; 399 390 400 actionExecuter.OperatorParameter.ActualName = problem.ActionExecuterParameter.Name; 391 401 … … 396 406 problem.ActionSetSubsumptionOperator.NumerositiesParameter.ActualName = "Numerosity"; 397 407 398 subsumptionSelector.ConditionParameter.ActualName = problem.ActionSetSubsumptionOperator.HasBeenSubsumedParameterName;408 problem.ActionSetSubsumptionOperator.HasBeenSubsumedParameter.ActualName = HASBEENSUBSUMED; 399 409 400 410 actionSetSubsumption.OperatorParameter.ActualName = problem.ActionSetSubsumptionOperatorParameter.Name; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVectorManipulator.cs
r9089 r9110 39 39 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Child"]; } 40 40 } 41 public ILookupParameter<CombinedIntegerVector> ParentParameter {41 public ILookupParameter<CombinedIntegerVector> FetchedClassifierParameter { 42 42 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Parent"]; } 43 43 } … … 57 57 58 58 public sealed override IOperation Apply() { 59 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, ChildParameter.ActualValue, ParentParameter.ActualValue);59 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedClassifierParameter.ActualValue, ChildParameter.ActualValue); 60 60 return base.Apply(); 61 61 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs
r9090 r9110 75 75 CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue.Action; 76 76 77 newCondition = UniformSomePosition InConditionManipulator.ManipulateCondition(RandomParameter.ActualValue, condition, newCondition, ChangeSymbolProbabilityParameter.ActualValue.Value);77 newCondition = UniformSomePositionManipulator.ManipulateCondition(RandomParameter.ActualValue, condition, newCondition, ChangeSymbolProbabilityParameter.ActualValue.Value); 78 78 79 79 CreatedClassifierParameter.ActualValue = new CombinedIntegerVector(newCondition, newCondition.Bounds, action, action.Bounds); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj
r9105 r9110 119 119 </Compile> 120 120 <Compile Include="Manipulator\UniformOnePositionInConditionManipulator.cs" /> 121 <Compile Include="Manipulator\UniformSomePosition InConditionManipulator.cs" />121 <Compile Include="Manipulator\UniformSomePositionManipulator.cs" /> 122 122 <Compile Include="Plugin.cs" /> 123 123 <None Include="Properties\AssemblyInfo.cs.frame" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorManipulator.cs
r9089 r9110 29 29 public interface ICombinedIntegerVectorManipulator : IManipulator, ICombinedIntegerVectorOperator { 30 30 ILookupParameter<CombinedIntegerVector> ChildParameter { get; } 31 ILookupParameter<CombinedIntegerVector> ParentParameter { get; }31 ILookupParameter<CombinedIntegerVector> FetchedClassifierParameter { get; } 32 32 } 33 33 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Manipulator/UniformSomePositionManipulator.cs
r9106 r9110 27 27 28 28 namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding { 29 public class UniformSomePosition InConditionManipulator : CombinedIntegerVectorManipulator {29 public class UniformSomePositionManipulator : CombinedIntegerVectorManipulator { 30 30 31 31 public IValueLookupParameter<PercentValue> ProbabilityParameter { … … 37 37 38 38 [StorableConstructor] 39 protected UniformSomePosition InConditionManipulator(bool deserializing) : base(deserializing) { }40 protected UniformSomePosition InConditionManipulator(UniformSomePositionInConditionManipulator original, Cloner cloner)39 protected UniformSomePositionManipulator(bool deserializing) : base(deserializing) { } 40 protected UniformSomePositionManipulator(UniformSomePositionManipulator original, Cloner cloner) 41 41 : base(original, cloner) { 42 42 } 43 43 public override IDeepCloneable Clone(Cloner cloner) { 44 return new UniformSomePosition InConditionManipulator(this, cloner);44 return new UniformSomePositionManipulator(this, cloner); 45 45 } 46 public UniformSomePosition InConditionManipulator()46 public UniformSomePositionManipulator() 47 47 : base() { 48 48 Parameters.Add(new ValueLookupParameter<PercentValue>("Probability", "The probability for each dimension to be manipulated.", new PercentValue(0.5))); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/CoveringOperator.cs
r9105 r9110 101 101 throw new ArgumentException("More classifiers with unique actions shall be created than unique actions are available."); 102 102 } 103 if (count > 0) { 104 CurrentPopulationSizeParameter.ActualValue.Value += count; 103 105 104 CurrentPopulationSizeParameter.ActualValue.Value += count; 106 int current = CurrentScope.SubScopes.Count; 107 for (int i = 0; i < count; i++) { 108 CurrentScope.SubScopes.Add(new Scope((current + i).ToString())); 109 } 105 110 106 int current = CurrentScope.SubScopes.Count; 107 for (int i = 0; i < count; i++) { 108 CurrentScope.SubScopes.Add(new Scope((current + i).ToString())); 111 creator.ActionParameter.ActualName = "Action"; 112 OperationCollection variableCreation = new OperationCollection() { Parallel = parallel }; 113 OperationCollection creation = new OperationCollection(); 114 OperationCollection evaluation = new OperationCollection() { Parallel = parallel }; 115 for (int i = 0; i < count; i++) { 116 VariableCreator variableCreator = new VariableCreator(); 117 int pos = RandomParameter.ActualValue.Next(clone.Count); 118 IClassifier action = clone.ElementAt(pos); 119 clone.Remove(action); 120 variableCreator.CollectedValues.Add(new ValueParameter<IClassifier>("Action", action)); 121 variableCreation.Add(ExecutionContext.CreateOperation(variableCreator, CurrentScope.SubScopes[current + i])); 122 creation.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i])); 123 evaluation.Add(ExecutionContext.CreateOperation(evaluator, CurrentScope.SubScopes[current + i])); 124 } 125 OperationCollection next = new OperationCollection(); 126 next.Add(variableCreation); 127 next.Add(creation); 128 next.Add(evaluation); 129 next.Add(base.Apply()); 130 return next; 131 } else { 132 return base.Apply(); 109 133 } 110 111 creator.ActionParameter.ActualName = "Action";112 OperationCollection variableCreation = new OperationCollection() { Parallel = parallel };113 OperationCollection creation = new OperationCollection();114 OperationCollection evaluation = new OperationCollection() { Parallel = parallel };115 for (int i = 0; i < count; i++) {116 VariableCreator variableCreator = new VariableCreator();117 int pos = RandomParameter.ActualValue.Next(clone.Count);118 IClassifier action = clone.ElementAt(pos);119 clone.Remove(action);120 variableCreator.CollectedValues.Add(new ValueParameter<IClassifier>("Action", action));121 variableCreation.Add(ExecutionContext.CreateOperation(variableCreator, CurrentScope.SubScopes[current + i]));122 creation.Add(ExecutionContext.CreateOperation(creator, CurrentScope.SubScopes[current + i]));123 evaluation.Add(ExecutionContext.CreateOperation(evaluator, CurrentScope.SubScopes[current + i]));124 }125 OperationCollection next = new OperationCollection();126 next.Add(variableCreation);127 next.Add(creation);128 next.Add(evaluation);129 next.Add(base.Apply());130 return next;131 134 } 132 135 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/DoDeletionBeforeCovering.cs
r9105 r9110 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 33 34 34 35 #region Parameter Properties 36 public ILookupParameter<ItemArray<IClassifier>> ClassifiersParameter { 37 get { return (ILookupParameter<ItemArray<IClassifier>>)Parameters["Classifiers"]; } 38 } 39 public ILookupParameter<ItemArray<BoolValue>> MatchConditionParameter { 40 get { return (ILookupParameter<ItemArray<BoolValue>>)Parameters["MatchCondition"]; } 41 } 35 42 public ILookupParameter<IntValue> MinimalNumberOfUniqueActionsParameter { 36 43 get { return (ILookupParameter<IntValue>)Parameters["MinimalNumberOfUniqueActions"]; } 37 }38 public ILookupParameter<IntValue> NumberOfUniqueActionsParameter {39 get { return (ILookupParameter<IntValue>)Parameters["NumberOfUniqueActions"]; }40 44 } 41 45 public ILookupParameter<IntValue> CurrentPopulationSizeParameter { … … 60 64 public DoDeletionBeforeCoveringOperator() 61 65 : base() { 66 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("Classifiers")); 67 Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("MatchCondition")); 62 68 Parameters.Add(new LookupParameter<IntValue>("MinimalNumberOfUniqueActions")); 63 Parameters.Add(new LookupParameter<IntValue>("NumberOfUniqueActions"));64 69 Parameters.Add(new LookupParameter<IntValue>("CurrentPopulationSize")); 65 70 Parameters.Add(new LookupParameter<IntValue>("PopulationSize")); … … 72 77 73 78 public override IOperation Apply() { 79 IItemSet<IClassifier> uniqueActions = new ItemSet<IClassifier>(); 80 var classifiers = ClassifiersParameter.ActualValue; 81 var matchcondition = MatchConditionParameter.ActualValue; 82 83 if (classifiers.Length != matchcondition.Length) { 84 throw new ArgumentException("Number of classifiers is not equal to the number of 'MatchCondition' variables."); 85 } 86 87 for (int i = 0; i < classifiers.Length; i++) { 88 if (matchcondition[i].Value) { 89 uniqueActions.Add(classifiers[i].Action); 90 } 91 } 92 74 93 int populationAfterCovering = MinimalNumberOfUniqueActionsParameter.ActualValue.Value 75 - NumberOfUniqueActionsParameter.ActualValue.Value94 - uniqueActions.Count 76 95 + CurrentPopulationSizeParameter.ActualValue.Value; 77 96 BoolValue doDeletion = new BoolValue(populationAfterCovering > PopulationSizeParameter.ActualValue.Value); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Deletion/XCSDeletionOperator.cs
r9105 r9110 51 51 get { return (ILookupParameter<ItemArray<IntValue>>)Parameters["Experiences"]; } 52 52 } 53 public ILookupParameter<ItemArray<BoolValue>> HasToBeDeletedParameter { 54 get { return (ILookupParameter<ItemArray<BoolValue>>)Parameters["HasToBeDeleted"]; } 55 } 53 56 public ILookupParameter<IntValue> ThetaDeletionParameter { 54 57 get { return (ILookupParameter<IntValue>)Parameters["ThetaDeletion"]; } … … 63 66 get { return (ILookupParameter<IntValue>)Parameters["CurrentPopulationSize"]; } 64 67 } 65 protected ScopeParameter CurrentScopeParameter {66 get { return (ScopeParameter)Parameters["CurrentScope"]; }67 }68 public IScope CurrentScope {69 get { return CurrentScopeParameter.ActualValue; }70 }71 public string HasToBeDeletedVariableName { get { return "HasToBeDeleted"; } }72 68 #endregion 73 69 … … 89 85 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Fitnesses")); 90 86 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Experiences")); 87 Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("HasToBeDeleted")); 91 88 Parameters.Add(new LookupParameter<IntValue>("ThetaDeletion")); 92 89 Parameters.Add(new LookupParameter<PercentValue>("Delta")); 93 90 Parameters.Add(new LookupParameter<IRandom>("Random")); 94 Parameters.Add(new ScopeParameter("CurrentScope"));95 91 Parameters.Add(new LookupParameter<IntValue>("CurrentPopulationSize")); 96 92 } … … 104 100 var experiences = ExperiencesParameter.ActualValue; 105 101 var averageActionSetSizes = AverageActionSetSizesParameter.ActualValue; 106 var subscopes = CurrentScope.SubScopes;102 var hasToBeDeleted = HasToBeDeletedParameter.ActualValue; 107 103 double fitnessSum = fitnesses.Select(x => x.Value).Sum(); 108 104 double numerositySum = numerosities.Select(x => x.Value).Sum(); 109 105 110 if (fitnesses.Length != numerosities.Length && fitnesses.Length != experiences.Length && fitnesses.Length != subscopes.Count) {106 if (fitnesses.Length != numerosities.Length && fitnesses.Length != experiences.Length) { 111 107 throw new ArgumentException("Different number of fitness, numerosity and experience values."); 112 }113 114 for (int cl = 0; cl < fitnesses.Length; cl++) {115 if (subscopes[cl].Variables.ContainsKey(HasToBeDeletedVariableName)) {116 ((BoolValue)subscopes[cl].Variables[HasToBeDeletedVariableName].Value).Value = false;117 } else {118 subscopes[cl].Variables.Add(new Variable(HasToBeDeletedVariableName, new BoolValue(false)));119 }120 108 } 121 109 … … 131 119 voteSum = 0; 132 120 for (int cl = 0; cl < fitnesses.Length; cl++) { 133 if (numerosities[cl].Value > 0 ) {121 if (numerosities[cl].Value > 0 && !hasToBeDeleted[cl].Value) { 134 122 voteSum += DeletionVote(averageFitnessInPopulation, averageActionSetSizes[cl].Value, numerosities[cl].Value, fitnesses[cl].Value, experiences[cl].Value); 135 123 if (voteSum > choicePoint) { 136 124 if (numerosities[cl].Value <= 1) { 137 ((BoolValue)subscopes[cl].Variables[HasToBeDeletedVariableName].Value).Value = true;125 hasToBeDeleted[cl].Value = true; 138 126 fitnessSum -= fitnesses[cl].Value; 139 127 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Evaluators/XCSEvaluator.cs
r9089 r9110 56 56 public IValueLookupParameter<IntValue> NumerosityParameter { 57 57 get { return (IValueLookupParameter<IntValue>)Parameters["Numerosity"]; } 58 } 59 public IValueLookupParameter<BoolValue> InsertInPopulationParameter { 60 get { return (IValueLookupParameter<BoolValue>)Parameters["InsertInPopulation"]; } 58 61 } 59 62 public ILookupParameter<DoubleValue> InitialPredictionParameter { … … 156 159 Parameters.Add(new LookupParameter<DoubleValue>("AccuracySum", "")); 157 160 Parameters.Add(new ValueLookupParameter<IntValue>("Numerosity", "")); 161 Parameters.Add(new ValueLookupParameter<BoolValue>("InsertInPopulation", "")); 158 162 159 163 Parameters.Add(new LookupParameter<DoubleValue>("InitialPrediction")); … … 178 182 AverageActionSetSizeParameter.ActualValue = new DoubleValue(1); 179 183 NumerosityParameter.ActualValue = new IntValue(1); 184 InsertInPopulationParameter.ActualValue = new BoolValue(false); 180 185 } else { 181 186 Experience += 1; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/GA/XCSAfterCrossoverOperator.cs
r9105 r9110 55 55 get { return (IValueLookupParameter<DoubleValue>)Parameters["Fitness"]; } 56 56 } 57 public IValueLookupParameter<BoolValue> InsertInPopulationParameter { 58 get { return (IValueLookupParameter<BoolValue>)Parameters["InsertInPopulation"]; } 59 } 60 public IValueLookupParameter<IntValue> TempIDParameter { 61 get { return (IValueLookupParameter<IntValue>)Parameters["TempID"]; } 62 } 57 63 public ILookupParameter<IntValue> CurrentIterationParameter { 58 64 get { return (ILookupParameter<IntValue>)Parameters["CurrentIteration"]; } … … 86 92 Parameters.Add(new ValueLookupParameter<DoubleValue>("Error")); 87 93 Parameters.Add(new ValueLookupParameter<DoubleValue>("Fitness")); 94 Parameters.Add(new ValueLookupParameter<BoolValue>("InsertInPopulation")); 95 Parameters.Add(new ValueLookupParameter<IntValue>("TempID")); 88 96 Parameters.Add(new LookupParameter<IntValue>("CurrentIteration")); 89 97 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ParentAverageActionSetSize")); … … 108 116 ErrorParameter.ActualValue = new DoubleValue(0.25 * parentPrecisionError.Select(x => x.Value).Average()); 109 117 FitnessParameter.ActualValue = new DoubleValue(0.1 * parentFitness.Select(x => x.Value).Average()); 118 InsertInPopulationParameter.ActualValue = new BoolValue(true); 119 TempIDParameter.ActualValue = new IntValue(-1); 110 120 return base.Apply(); 111 121 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj
r9105 r9110 92 92 <Compile Include="Evaluators\IConditionActionEvaluator.cs" /> 93 93 <Compile Include="Evaluators\IXCSEvaluator.cs" /> 94 <Compile Include="GA\InsertInPopulationOperator.cs" /> 94 95 <Compile Include="GA\XCSAfterCrossoverOperator.cs" /> 95 96 <Compile Include="IClassifier.cs" /> … … 102 103 <Compile Include="Operator\MatchActionOperator.cs" /> 103 104 <Compile Include="Operator\MatchConditionOperator.cs" /> 104 <Compile Include="Operator\SubScopeVariableCopier.cs" />105 105 <Compile Include="Operator\SumAccuracy.cs" /> 106 <Compile Include="GA\TempSubScopeIDAssigner.cs" /> 106 107 <Compile Include="Properties\AssemblyInfo.cs" /> 107 108 <Compile Include="Plugin.cs" /> … … 111 112 <Compile Include="Selectors\IMatchSelector.cs" /> 112 113 <Compile Include="Selectors\MatchSelector.cs" /> 113 <Compile Include="Subsumption\ActionSetSubsumptionoperator.cs" /> 114 <Compile Include="Subsumption\ActionSetSubsumptionOperator.cs" /> 115 <Compile Include="Subsumption\CheckGASubsumptionOperator.cs" /> 116 <Compile Include="Subsumption\ExecuteGASubsumptionOperator.cs" /> 114 117 <Compile Include="Subsumption\IActionSetSubsumption.cs" /> 115 118 <None Include="Properties\AssemblyInfo.cs.frame" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblem.cs
r9105 r9110 33 33 IParameter ThetaMinimalNumberOfActionsParameter { get; } 34 34 35 IParameter PossibleActionsConcreteClassParameter { get; } 35 36 IParameter PossibleActionsParameter { get; } 36 IItemSet<IClassifier> PossibleActions { get; }37 //IItemSet<IClassifier> PossibleActions { get; } 37 38 38 39 ICoveringSolutionCreator CoveringSolutionCreator { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Operator/MatchConditionOperator.cs
r9089 r9110 31 31 [StorableClass] 32 32 public class MatchConditionOperator : SingleSuccessorOperator { 33 p rotectedILookupParameter<BoolValue> MatchConditionParameter {33 public ILookupParameter<BoolValue> MatchConditionParameter { 34 34 get { return (ILookupParameter<BoolValue>)Parameters["MatchCondition"]; } 35 35 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Subsumption/ActionSetSubsumptionOperator.cs
r9106 r9110 31 31 [Item("ActionSetSubsumptionoperator", "Description missing")] 32 32 [StorableClass] 33 public class ActionSetSubsumption operator : SingleSuccessorOperator, IActionSetSubsumption {33 public class ActionSetSubsumptionOperator : SingleSuccessorOperator, IActionSetSubsumption { 34 34 35 35 #region Parameter Properties … … 46 46 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Errors"]; } 47 47 } 48 public ILookupParameter<ItemArray<BoolValue>> HasBeenSubsumedParameter { 49 get { return (ILookupParameter<ItemArray<BoolValue>>)Parameters["HasBeenSubsumed"]; } 50 } 48 51 public ILookupParameter<DoubleValue> ErrorZeroParameter { 49 52 get { return (ILookupParameter<DoubleValue>)Parameters["ErrorZero"]; } … … 52 55 get { return (ILookupParameter<IntValue>)Parameters["ThetaSubsumption"]; } 53 56 } 54 protected ScopeParameter CurrentScopeParameter {55 get { return (ScopeParameter)Parameters["CurrentScope"]; }56 }57 public IScope CurrentScope {58 get { return CurrentScopeParameter.ActualValue; }59 }60 61 public string HasBeenSubsumedParameterName {62 get { return "HasBeenSubsumed"; }63 }64 57 #endregion 65 58 66 59 [StorableConstructor] 67 protected ActionSetSubsumption operator(bool deserializing) : base(deserializing) { }68 protected ActionSetSubsumption operator(ActionSetSubsumptionoperator original, Cloner cloner)60 protected ActionSetSubsumptionOperator(bool deserializing) : base(deserializing) { } 61 protected ActionSetSubsumptionOperator(ActionSetSubsumptionOperator original, Cloner cloner) 69 62 : base(original, cloner) { 70 63 } 71 public ActionSetSubsumption operator()64 public ActionSetSubsumptionOperator() 72 65 : base() { 73 66 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("Classifiers")); … … 75 68 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Experiences")); 76 69 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Errors")); 70 Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("HasBeenSubsumed")); 77 71 Parameters.Add(new LookupParameter<DoubleValue>("ErrorZero")); 78 72 Parameters.Add(new LookupParameter<IntValue>("ThetaSubsumption")); 79 Parameters.Add(new ScopeParameter("CurrentScope"));80 73 } 81 74 public override IDeepCloneable Clone(Cloner cloner) { 82 return new ActionSetSubsumption operator(this, cloner);75 return new ActionSetSubsumptionOperator(this, cloner); 83 76 } 84 77 85 78 public override IOperation Apply() { 86 var subscopes = CurrentScope.SubScopes;87 79 var classifiers = ClassifiersParameter.ActualValue; 88 80 var numerosities = NumerositiesParameter.ActualValue; 89 81 var experiences = ExperiencesParameter.ActualValue; 82 var hasBeenSubsumed = HasBeenSubsumedParameter.ActualValue; 90 83 var errors = ErrorsParameter.ActualValue; 91 if ( subscopes.Count != classifiers.Length || subscopes.Count!= numerosities.Length92 || subscopes.Count != experiences.Length || subscopes.Count != errors.Length) {93 throw new ArgumentException("The number of subscopes is not equal to the number of classifiers.");84 if (errors.Length != classifiers.Length || errors.Length != numerosities.Length 85 || errors.Length != experiences.Length || errors.Length != hasBeenSubsumed.Length) { 86 throw new ArgumentException("The number of classifiers, error, numerosity, hasBeenSubsumed and experience values is not equal."); 94 87 } 95 88 … … 108 101 if (classifiers[subsumptionClassifier].IsMoreGeneral(classifiers[i])) { 109 102 numerosities[subsumptionClassifier].Value += numerosities[i].Value; 110 AddVariableToScope(subscopes[i], new BoolValue(true)); 111 } else { 112 AddVariableToScope(subscopes[i], new BoolValue(false)); 103 hasBeenSubsumed[i].Value = true; 113 104 } 114 }115 } else {116 for (int i = 0; i < classifiers.Length; i++) {117 AddVariableToScope(subscopes[i], new BoolValue(false));118 105 } 119 106 } 120 107 121 108 return base.Apply(); 122 }123 124 private void AddVariableToScope(IScope scope, BoolValue boolValue) {125 if (scope.Variables.ContainsKey(HasBeenSubsumedParameterName)) {126 scope.Variables[HasBeenSubsumedParameterName].Value = boolValue;127 } else {128 scope.Variables.Add(new Variable(HasBeenSubsumedParameterName, boolValue));129 }130 109 } 131 110 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Subsumption/IActionSetSubsumption.cs
r9105 r9110 31 31 ILookupParameter<ItemArray<IntValue>> ExperiencesParameter { get; } 32 32 ILookupParameter<ItemArray<DoubleValue>> ErrorsParameter { get; } 33 ILookupParameter<ItemArray<BoolValue>> HasBeenSubsumedParameter { get; } 33 34 ILookupParameter<DoubleValue> ErrorZeroParameter { get; } 34 35 ILookupParameter<IntValue> ThetaSubsumptionParameter { get; } 35 36 string HasBeenSubsumedParameterName { get; }37 36 } 38 37 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs
r9105 r9110 70 70 get { return (IFixedValueParameter<ItemSet<IClassifier>>)Parameters["PossibleActions"]; } 71 71 } 72 public IFixedValueParameter<ItemSet<CombinedIntegerVector>> PossibleActionsConcreteClassParameter { 73 get { return (IFixedValueParameter<ItemSet<CombinedIntegerVector>>)Parameters["PossibleActionsConcreteClass"]; } 74 } 72 75 public IFixedValueParameter<IntValue> ThetaMinimalNumberOfActionsParameter { 73 76 get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; } … … 95 98 get { return ProblemDataParameter.Value; } 96 99 } 100 IParameter IConditionActionProblem.PossibleActionsConcreteClassParameter { 101 get { return PossibleActionsConcreteClassParameter; } 102 } 103 public ItemSet<CombinedIntegerVector> PossibleActionsConcreteClass { 104 get { return PossibleActionsConcreteClassParameter.Value; } 105 } 97 106 IParameter IConditionActionProblem.PossibleActionsParameter { 98 107 get { return PossibleActionsParameter; } 99 108 } 100 IItemSet<IClassifier> IConditionActionProblem.PossibleActions {101 get { return PossibleActions; }102 }109 //IItemSet<IClassifier> IConditionActionProblem.PossibleActions { 110 // get { return PossibleActions; } 111 //} 103 112 public ItemSet<IClassifier> PossibleActions { 104 113 get { return PossibleActionsParameter.Value; } … … 121 130 122 131 123 public ActionSetSubsumption operator ActionSetSubsumptionOperator {132 public ActionSetSubsumptionOperator ActionSetSubsumptionOperator { 124 133 get { return ActionSetSubsumptionOperatorParameter.Value; } 125 134 } 126 public ValueParameter<ActionSetSubsumption operator> ActionSetSubsumptionOperatorParameter {127 get { return (ValueParameter<ActionSetSubsumption operator>)Parameters[ActionSetSubsumptionOperatorParameterName]; }135 public ValueParameter<ActionSetSubsumptionOperator> ActionSetSubsumptionOperatorParameter { 136 get { return (ValueParameter<ActionSetSubsumptionOperator>)Parameters[ActionSetSubsumptionOperatorParameterName]; } 128 137 } 129 138 IActionSetSubsumption IConditionActionProblem.ActionSetSubsumptionOperator { get { return ActionSetSubsumptionOperator; } } … … 175 184 Parameters.Add(new ValueParameter<CombinedIntegerVectorClassifierFetcher>(ClassifierFetcherParameterName, "", new CombinedIntegerVectorClassifierFetcher())); 176 185 Parameters.Add(new FixedValueParameter<ItemSet<IClassifier>>("PossibleActions")); 186 Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass")); 177 187 Parameters.Add(new FixedValueParameter<IntValue>("ThetaMinimalNumberOfActions", "Minimal number of actions, which have to be present in the match set, or else covering will occure.", new IntValue(1))); 178 188 … … 180 190 Parameters.Add(new FixedValueParameter<PercentValue>("ChangeSymbolProbabilityInCovering", "", new PercentValue(0.5))); 181 191 182 Parameters.Add(new ValueParameter<ActionSetSubsumption operator>(ActionSetSubsumptionOperatorParameterName, "", new ActionSetSubsumptionoperator()));192 Parameters.Add(new ValueParameter<ActionSetSubsumptionOperator>(ActionSetSubsumptionOperatorParameterName, "", new ActionSetSubsumptionOperator())); 183 193 184 194 Evaluator.InitialErrorParameter.ActualName = "InitialError"; … … 237 247 } 238 248 PossibleActions.Clear(); 249 PossibleActionsConcreteClass.Clear(); 239 250 while (!done) { 240 251 PossibleActions.Add(new CombinedIntegerVector(curPos, actionLength, actionBounds)); 252 PossibleActionsConcreteClass.Add(new CombinedIntegerVector(curPos, actionLength, actionBounds)); 241 253 curPos = GetNextAction(curPos, actionBounds, out done); 242 254 }
Note: See TracChangeset
for help on using the changeset viewer.