Changeset 9110 for branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Subsumption
- Timestamp:
- 01/04/13 20:46:18 (12 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Subsumption
- Files:
-
- 2 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.