Changeset 9090
- Timestamp:
- 12/29/12 20:15:48 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 1 added
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3
- Property svn:ignore
-
old new 1 1 *.user 2 2 Plugin.cs 3 obj
-
- Property svn:ignore
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystemMainLoop.cs
r9089 r9090 54 54 #region private properties 55 55 private SolutionsCreator initialSolutionsCreator; 56 private SolutionsCreator coveringMechanism;57 56 private MatchConditionOperator matchConditionOperator; 58 57 private PredictionArrayCalculator predictionArrayCalculator; 59 58 private ActionSelector actionSelector; 59 private CoveringOperator covering; 60 60 61 61 private Placeholder evaluator; … … 100 100 ConditionalSelector conditionMatchSelector = new ConditionalSelector(); 101 101 ConditionalSelector actionMatchSelector = new ConditionalSelector(); 102 SubScopesProcessor coveringSubScopesProcessor = new SubScopesProcessor(); 103 SubScopesCounter matchsetCounter = new SubScopesCounter(); 104 Comparator comparator = new Comparator(); 105 ConditionalBranch coveringConditionalBranch = new ConditionalBranch(); 102 SubScopesProcessor matchSetSubScopesProcessor = new SubScopesProcessor(); 103 CountNumberOfUniqueActions countNumberOfUniqueActions = new CountNumberOfUniqueActions(); 104 covering = new CoveringOperator(); 106 105 MergingReducer mergingReducer = new MergingReducer(); 107 106 MergingReducer mergingReducerWithSuccessor = new MergingReducer(); 108 coveringMechanism = new SolutionsCreator();109 107 evaluator = new Placeholder(); 110 108 SubScopesProcessor actionSetSubScopesProcessor = new SubScopesProcessor(); … … 137 135 conditionMatchSelector.ConditionParameter.ActualName = "MatchCondition"; 138 136 139 matchsetCounter.Name = "Count number of rules in match set"; 140 matchsetCounter.AccumulateParameter.Value = new BoolValue(false); 141 matchsetCounter.ValueParameter.ActualName = "MatchSetCount"; 142 143 comparator.Comparison = new Comparison(ComparisonType.LessOrEqual); 144 comparator.LeftSideParameter.ActualName = matchsetCounter.ValueParameter.ActualName; 145 comparator.ResultParameter.ActualName = "Covering"; 146 //more than zero solutions have to be selected 147 comparator.RightSideParameter.ActualName = "ZeroIntValue"; 148 149 coveringConditionalBranch.Name = "Covering Branch"; 150 coveringConditionalBranch.ConditionParameter.ActualName = "Covering"; 137 countNumberOfUniqueActions.ClassifiersParameter.ActualName = "CombinedIntegerVector"; 138 139 covering.ActionsInMatchSetParameter.ActualName = countNumberOfUniqueActions.UniqueActionsParameter.ActualName; 140 covering.ParallelParameter.Value.Value = true; 141 covering.RandomParameter.ActualName = "Random"; 151 142 152 143 matchActionSubScopesProcessor.Operator = matchActionOperator; … … 154 145 matchActionOperator.MatchParameter.ActualName = "CombinedIntegerVector"; 155 146 matchActionOperator.TargetMatchParameter.ActualName = actionSelector.SelectedActionParameter.ActualName; 156 157 coveringMechanism.NumberOfSolutionsParameter.ActualName = "OneIntValue";158 147 159 148 predictionArrayCalculator.MatchParameter.ActualName = "CombinedIntegerVector"; … … 211 200 //adaptedGeneticAlgorithmMainLoop.Successor = conditionMatchSelector; 212 201 213 conditionMatchSelector.Successor = coveringSubScopesProcessor; 214 coveringSubScopesProcessor.Operators.Add(new EmptyOperator()); 215 coveringSubScopesProcessor.Operators.Add(matchsetCounter); 216 coveringSubScopesProcessor.Successor = mergingReducerWithSuccessor; 217 matchsetCounter.Successor = comparator; 218 comparator.Successor = coveringConditionalBranch; 219 coveringConditionalBranch.TrueBranch = coveringMechanism; 220 coveringConditionalBranch.FalseBranch = new EmptyOperator(); 221 coveringConditionalBranch.Successor = predictionArrayCalculator; 202 conditionMatchSelector.Successor = matchSetSubScopesProcessor; 203 matchSetSubScopesProcessor.Operators.Add(new EmptyOperator()); 204 matchSetSubScopesProcessor.Operators.Add(countNumberOfUniqueActions); 205 matchSetSubScopesProcessor.Successor = mergingReducerWithSuccessor; 206 countNumberOfUniqueActions.Successor = covering; 207 covering.Successor = predictionArrayCalculator; 222 208 predictionArrayCalculator.Successor = actionSelector; 223 209 actionSelector.Successor = matchActionSubScopesProcessor; … … 253 239 initialSolutionsCreator.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name; 254 240 255 coveringMechanism.SolutionCreatorParameter.ActualName = problem.SolutionCreatorParameter.Name;256 coveringMechanism.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name;257 258 241 problem.ActionExecuter.SelectedActionParameter.ActualName = actionSelector.SelectedActionParameter.ActualName; 259 242 … … 266 249 actionExecuter.OperatorParameter.ActualName = problem.ActionExecuterParameter.Name; 267 250 268 matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.Name; 251 matchConditionOperator.TargetMatchParameter.ActualName = problem.ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName; 252 253 covering.SolutionCreatorParameter.ActualName = problem.CoveringSolutionCreatorParameter.Name; 254 covering.EvaluatorParameter.ActualName = problem.EvaluatorParameter.Name; 255 covering.MinimalNumberOfUniqueActionsParameter.ActualName = problem.ThetaMinimalNumberOfActionsParameter.Name; 256 covering.PossibleActionsParameter.ActualName = problem.PossibleActionsParameter.Name; 269 257 270 258 predictionArrayCalculator.PredictionParameter.ActualName = problem.Evaluator.PredictionParameter.ActualName; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3
- Property svn:ignore
-
old new 1 1 *.user 2 2 Plugin.cs 3 obj
-
- Property svn:ignore
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs
r9089 r9090 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding .Covering{30 namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding { 31 31 [Item("CombinedIntegerVectorCoveringCreator", "Description missing")] 32 32 [StorableClass] … … 43 43 get { return (IValueLookupParameter<IClassifier>)Parameters["CreatedClassifier"]; } 44 44 } 45 public I ValueLookupParameter<PercentValue> ChangeSymbolProbabilityParameter {46 get { return (I ValueLookupParameter<PercentValue>)Parameters["ChangeSymbolProbability"]; }45 public ILookupParameter<PercentValue> ChangeSymbolProbabilityParameter { 46 get { return (ILookupParameter<PercentValue>)Parameters["ChangeSymbolProbability"]; } 47 47 } 48 public ILookupParameter<IRandom> RandomParameter { 49 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 50 } 51 48 52 #endregion 49 53 … … 61 65 Parameters.Add(new LookupParameter<IClassifier>("Action")); 62 66 Parameters.Add(new ValueLookupParameter<IClassifier>("CreatedClassifier")); 63 Parameters.Add(new ValueLookupParameter<PercentValue>("ChangeSymbolProbability")); 67 Parameters.Add(new LookupParameter<PercentValue>("ChangeSymbolProbability")); 68 Parameters.Add(new LookupParameter<IRandom>("Random")); 64 69 } 65 70 66 71 public override IOperation Apply() { 72 CombinedIntegerVector newCondition = (CombinedIntegerVector)CoverClassifierParameter.ActualValue.Condition.Clone(); 73 67 74 CombinedIntegerVector condition = (CombinedIntegerVector)CoverClassifierParameter.ActualValue.Condition; 68 75 CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue.Action; 69 76 70 //TODO: manipulation77 newCondition = UniformSomePositionInConditionManipulator.ManipulateCondition(RandomParameter.ActualValue, condition, newCondition, ChangeSymbolProbabilityParameter.ActualValue.Value); 71 78 72 CreatedClassifierParameter.ActualValue = new CombinedIntegerVector( condition, condition.Bounds, action, action.Bounds);79 CreatedClassifierParameter.ActualValue = new CombinedIntegerVector(newCondition, newCondition.Bounds, action, action.Bounds); 73 80 return base.Apply(); 74 81 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Crossovers/SinglePointCrossover.cs
r9089 r9090 38 38 } 39 39 40 public static CombinedIntegerVector Apply(IRandom random, CombinedIntegerVector parent1, CombinedIntegerVector parent2) { 41 if (parent1.Length != parent2.Length && parent1.ActionLength != parent2.ActionLength && parent1.Bounds.Equals(parent2.Bounds)) 42 throw new ArgumentException("SinglePointCrossover: The parents are of different length."); 43 44 int length = parent1.Length; 45 int actionLength = parent1.ActionLength; 46 int conditionLength = length - actionLength; 47 int[] result = new int[length]; 48 int breakPoint = random.Next(1, conditionLength); 49 50 for (int i = 0; i < breakPoint; i++) { 51 result[i] = parent1[i]; 52 } 53 for (int i = breakPoint; i < conditionLength; i++) { 54 result[i] = parent2[i]; 55 } 56 57 CombinedIntegerVector actionParent = random.Next(2) == 1 ? parent1 : parent2; 58 for (int i = conditionLength; i < length; i++) { 59 result[i] = actionParent[i]; 60 } 61 62 return new CombinedIntegerVector(result, actionLength, parent1.Bounds); 63 } 64 40 65 protected override CombinedIntegerVector Cross(IRandom random, ItemArray<CombinedIntegerVector> parents) { 41 66 if (parents.Length != 2) throw new ArgumentException("ERROR in SinglePointCrossover: The number of parents is not equal to 2"); 42 return new CombinedIntegerVector(HeuristicLab.Encodings.IntegerVectorEncoding.SinglePointCrossover.Apply(random, parents[0], parents[1]), parents[0].ActionLength, parents[0].Bounds);67 return Apply(random, parents[0], parents[1]); 43 68 } 44 69 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj
r9089 r9090 118 118 </Compile> 119 119 <Compile Include="Manipulator\UniformOnePositionInConditionManipulator.cs" /> 120 <Compile Include="Manipulator\UniformSomePosition sManipulator.cs" />120 <Compile Include="Manipulator\UniformSomePositionInConditionManipulator.cs" /> 121 121 <Compile Include="Plugin.cs" /> 122 122 <None Include="Properties\AssemblyInfo.cs.frame" /> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Manipulator/UniformOnePositionInConditionManipulator.cs
r9089 r9090 46 46 47 47 public static CombinedIntegerVector Manipulate(CombinedIntegerVector parent, CombinedIntegerVector child, int index) { 48 int max = child.Bounds[index % child.Bounds.Rows, 1] ;48 int max = child.Bounds[index % child.Bounds.Rows, 1] - 1; 49 49 if (child[index].Equals(max)) { 50 50 child[index] = parent[index]; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3
-
Property
svn:ignore
set to
obj
Plugin.cs
-
Property
svn:ignore
set to
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/CoveringOperator.cs
r9089 r9090 35 35 36 36 #region Parameter Properties 37 public ILookupParameter<IClassifier> CoverClassifierParameter {38 get { return (ILookupParameter<IClassifier>)Parameters["CoverClassifier"]; }39 }40 37 public ILookupParameter<IItemSet<IClassifier>> ActionsInMatchSetParameter { 41 38 get { return (ILookupParameter<IItemSet<IClassifier>>)Parameters["ActionsInMatchSet"]; } … … 48 45 } 49 46 public IValueLookupParameter<IOperator> EvaluatorParameter { 50 get { return (IValueLookupParameter<IOperator>)Parameters[" 47 get { return (IValueLookupParameter<IOperator>)Parameters["Evaluator"]; } 51 48 } 52 49 public IValueLookupParameter<ICoveringSolutionCreator> SolutionCreatorParameter { … … 78 75 : base() { 79 76 Parameters.Add(new LookupParameter<IClassifier>("CoverClassifier")); 80 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("ActionsInMatchSet"));81 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("PossibleActions"));77 Parameters.Add(new LookupParameter<IItemSet<IClassifier>>("ActionsInMatchSet")); 78 Parameters.Add(new LookupParameter<IItemSet<IClassifier>>("PossibleActions")); 82 79 Parameters.Add(new LookupParameter<IntValue>("MinimalNumberOfUniqueActions")); 83 80 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator")); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/ICovering.cs
r9089 r9090 26 26 namespace HeuristicLab.Encodings.ConditionActionEncoding { 27 27 public interface ICovering : IStochasticOperator { 28 ILookupParameter<IClassifier> CoverClassifierParameter { get; }29 28 ILookupParameter<IItemSet<IClassifier>> ActionsInMatchSetParameter { get; } 30 29 ILookupParameter<IItemSet<IClassifier>> PossibleActionsParameter { get; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Covering/ICoveringSolutionCreator.cs
r9089 r9090 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 26 using HeuristicLab.Optimization; 25 27 26 28 namespace HeuristicLab.Encodings.ConditionActionEncoding { 27 public interface ICoveringSolutionCreator : IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable {29 public interface ICoveringSolutionCreator : IOperator, IParameterizedNamedItem, INamedItem, IParameterizedItem, IItem, IContent, IDeepCloneable, ICloneable, IStochasticOperator { 28 30 ILookupParameter<IClassifier> CoverClassifierParameter { get; } 29 31 ILookupParameter<IClassifier> ActionParameter { get; } 30 32 31 33 IValueLookupParameter<IClassifier> CreatedClassifierParameter { get; } 34 ILookupParameter<PercentValue> ChangeSymbolProbabilityParameter { get; } 32 35 } 33 36 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Interfaces/IConditionActionProblem.cs
r9089 r9090 31 31 IParameter ClassifierFetcherParameter { get; } 32 32 IClassifierFetcher ClassifierFetcher { get; } 33 IParameter ThetaMinimalNumberOfActionsParameter { get; } 33 34 34 35 IParameter PossibleActionsParameter { get; } 35 36 IItemSet<IClassifier> PossibleActions { get; } 36 37 38 ICoveringSolutionCreator CoveringSolutionCreator { get; } 39 IParameter CoveringSolutionCreatorParameter { get; } 40 37 41 new IXCSEvaluator Evaluator { get; } 38 42 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Operator/CountNumberOfUniqueActions.cs
r9089 r9090 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 24 25 using HeuristicLab.Operators; 25 26 using HeuristicLab.Parameters; … … 37 38 get { return (IValueLookupParameter<IItemSet<IClassifier>>)Parameters["UniqueActions"]; } 38 39 } 40 public IValueLookupParameter<IntValue> NumberOfUniqueActionsParameter { 41 get { return (IValueLookupParameter<IntValue>)Parameters["NumberOfUniqueActions"]; } 42 } 39 43 40 44 [StorableConstructor] … … 50 54 Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("Classifiers")); 51 55 Parameters.Add(new ValueLookupParameter<IItemSet<IClassifier>>("UniqueActions")); 56 Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfUniqueActions")); 52 57 } 58 53 59 public override IOperation Apply() { 54 60 ItemSet<IClassifier> actions = new ItemSet<IClassifier>(); … … 56 62 actions.Add(classifier.Action); 57 63 } 58 UniqueActionsParameter.Value = actions; 64 UniqueActionsParameter.ActualValue = actions; 65 NumberOfUniqueActionsParameter.ActualValue = new IntValue(actions.Count); 59 66 return base.Apply(); 60 67 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Properties
-
Property
svn:ignore
set to
AssemblyInfo.cs
-
Property
svn:ignore
set to
-
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3
-
Property
svn:ignore
set to
obj
Plugin.cs
-
Property
svn:ignore
set to
-
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs
r9089 r9090 45 45 get { return (IValueParameter<ConditionActionClassificationProblemData>)Parameters["ProblemData"]; } 46 46 } 47 public IValueParameter<ICoveringSolutionCreator> CoveringSolutionCreatorParameter { 48 get { return (IValueParameter<ICoveringSolutionCreator>)Parameters["CoveringSolutionCreator"]; } 49 } 50 public IFixedValueParameter<PercentValue> ChangeSymbolProbabilityInCoveringParameter { 51 get { return (IFixedValueParameter<PercentValue>)Parameters["ChangeSymbolProbabilityInCovering"]; } 52 } 47 53 public IFixedValueParameter<DoubleValue> PositiveRewardParameter { 48 54 get { return (IFixedValueParameter<DoubleValue>)Parameters["PositiveReward"]; } … … 60 66 get { return (IFixedValueParameter<DoubleValue>)Parameters["InitialFitness"]; } 61 67 } 62 public IFixedValueParameter<I ItemSet<IClassifier>> PossibleActionsParameter {63 get { return (IFixedValueParameter<I ItemSet<IClassifier>>)Parameters["PossibleActions"]; }64 } 65 p rivateIFixedValueParameter<IntValue> ThetaMinimalNumberOfActionsParameter {68 public IFixedValueParameter<ItemSet<IClassifier>> PossibleActionsParameter { 69 get { return (IFixedValueParameter<ItemSet<IClassifier>>)Parameters["PossibleActions"]; } 70 } 71 public IFixedValueParameter<IntValue> ThetaMinimalNumberOfActionsParameter { 66 72 get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; } 67 73 } … … 94 100 get { return PossibleActions; } 95 101 } 96 public I ItemSet<IClassifier> PossibleActions {102 public ItemSet<IClassifier> PossibleActions { 97 103 get { return PossibleActionsParameter.Value; } 98 104 } … … 115 121 private IntValue ThetaMinimalNumberOfActions { 116 122 get { return ThetaMinimalNumberOfActionsParameter.Value; } 123 } 124 IParameter IConditionActionProblem.ThetaMinimalNumberOfActionsParameter { 125 get { return ThetaMinimalNumberOfActionsParameter; } 126 } 127 public ICoveringSolutionCreator CoveringSolutionCreator { 128 get { return CoveringSolutionCreatorParameter.Value; } 129 } 130 IParameter IConditionActionProblem.CoveringSolutionCreatorParameter { 131 get { return CoveringSolutionCreatorParameter; } 117 132 } 118 133 #endregion … … 130 145 this(new ConditionActionClassificationProblemData(new Dataset(ConditionActionClassificationProblemData.defaultVariableNames, ConditionActionClassificationProblemData.defaultData), 131 146 ConditionActionClassificationProblemData.defaultVariableNames.Take(ConditionActionClassificationProblemData.defaultVariableNames.Length - 1), ConditionActionClassificationProblemData.defaultVariableNames.Last().ToEnumerable()), 132 new XCSEvaluator(), new UniformRandomCombinedIntegerVectorCreator() ) {133 } 134 135 public ConditionActionClassificationProblem(ConditionActionClassificationProblemData problemData, XCSEvaluator evaluator, UniformRandomCombinedIntegerVectorCreator solutionCreator )147 new XCSEvaluator(), new UniformRandomCombinedIntegerVectorCreator(), new CombinedIntegerVectorCoveringCreator()) { 148 } 149 150 public ConditionActionClassificationProblem(ConditionActionClassificationProblemData problemData, XCSEvaluator evaluator, UniformRandomCombinedIntegerVectorCreator solutionCreator, ICoveringSolutionCreator coveringSolutionCreator) 136 151 : base(evaluator, solutionCreator) { 137 152 Parameters.Add(new FixedValueParameter<IntValue>("Length", "The operator to create a solution.", new IntValue(7))); … … 151 166 Parameters.Add(new FixedValueParameter<IntValue>("ThetaMinimalNumberOfActions", "Minimal number of actions, which have to be present in the match set, or else covering will occure.")); 152 167 168 Parameters.Add(new ValueParameter<ICoveringSolutionCreator>("CoveringSolutionCreator", "", coveringSolutionCreator)); 169 Parameters.Add(new FixedValueParameter<PercentValue>("ChangeSymbolProbabilityInCovering", "", new PercentValue(0.5))); 170 153 171 Evaluator.InitialErrorParameter.ActualName = "InitialError"; 154 172 Evaluator.InitialFitnessParameter.ActualName = "InitialFitness"; … … 158 176 SolutionCreator.LengthParameter.ActualName = LengthParameter.Name; 159 177 SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name; 178 179 coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name; 180 coveringSolutionCreator.CoverClassifierParameter.ActualName = ClassifierFetcher.CurrentClassifierToMatchParameter.ActualName; 181 coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector"; 160 182 161 183 ClassifierFetcher.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name; -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Properties
-
Property
svn:ignore
set to
AssemblyInfo.cs
-
Property
svn:ignore
set to
Note: See TracChangeset
for help on using the changeset viewer.