Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/13 20:46:18 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added GA subsumption
  • simplified deletion before covering
  • simplified XCSDeletionOperator
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  
    3131  [Item("ActionSetSubsumptionoperator", "Description missing")]
    3232  [StorableClass]
    33   public class ActionSetSubsumptionoperator : SingleSuccessorOperator, IActionSetSubsumption {
     33  public class ActionSetSubsumptionOperator : SingleSuccessorOperator, IActionSetSubsumption {
    3434
    3535    #region Parameter Properties
     
    4646      get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Errors"]; }
    4747    }
     48    public ILookupParameter<ItemArray<BoolValue>> HasBeenSubsumedParameter {
     49      get { return (ILookupParameter<ItemArray<BoolValue>>)Parameters["HasBeenSubsumed"]; }
     50    }
    4851    public ILookupParameter<DoubleValue> ErrorZeroParameter {
    4952      get { return (ILookupParameter<DoubleValue>)Parameters["ErrorZero"]; }
     
    5255      get { return (ILookupParameter<IntValue>)Parameters["ThetaSubsumption"]; }
    5356    }
    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     }
    6457    #endregion
    6558
    6659    [StorableConstructor]
    67     protected ActionSetSubsumptionoperator(bool deserializing) : base(deserializing) { }
    68     protected ActionSetSubsumptionoperator(ActionSetSubsumptionoperator original, Cloner cloner)
     60    protected ActionSetSubsumptionOperator(bool deserializing) : base(deserializing) { }
     61    protected ActionSetSubsumptionOperator(ActionSetSubsumptionOperator original, Cloner cloner)
    6962      : base(original, cloner) {
    7063    }
    71     public ActionSetSubsumptionoperator()
     64    public ActionSetSubsumptionOperator()
    7265      : base() {
    7366      Parameters.Add(new ScopeTreeLookupParameter<IClassifier>("Classifiers"));
     
    7568      Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Experiences"));
    7669      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Errors"));
     70      Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("HasBeenSubsumed"));
    7771      Parameters.Add(new LookupParameter<DoubleValue>("ErrorZero"));
    7872      Parameters.Add(new LookupParameter<IntValue>("ThetaSubsumption"));
    79       Parameters.Add(new ScopeParameter("CurrentScope"));
    8073    }
    8174    public override IDeepCloneable Clone(Cloner cloner) {
    82       return new ActionSetSubsumptionoperator(this, cloner);
     75      return new ActionSetSubsumptionOperator(this, cloner);
    8376    }
    8477
    8578    public override IOperation Apply() {
    86       var subscopes = CurrentScope.SubScopes;
    8779      var classifiers = ClassifiersParameter.ActualValue;
    8880      var numerosities = NumerositiesParameter.ActualValue;
    8981      var experiences = ExperiencesParameter.ActualValue;
     82      var hasBeenSubsumed = HasBeenSubsumedParameter.ActualValue;
    9083      var errors = ErrorsParameter.ActualValue;
    91       if (subscopes.Count != classifiers.Length || subscopes.Count != numerosities.Length
    92         || 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.");
    9487      }
    9588
     
    108101          if (classifiers[subsumptionClassifier].IsMoreGeneral(classifiers[i])) {
    109102            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;
    113104          }
    114         }
    115       } else {
    116         for (int i = 0; i < classifiers.Length; i++) {
    117           AddVariableToScope(subscopes[i], new BoolValue(false));
    118105        }
    119106      }
    120107
    121108      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       }
    130109    }
    131110
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/Subsumption/IActionSetSubsumption.cs

    r9105 r9110  
    3131    ILookupParameter<ItemArray<IntValue>> ExperiencesParameter { get; }
    3232    ILookupParameter<ItemArray<DoubleValue>> ErrorsParameter { get; }
     33    ILookupParameter<ItemArray<BoolValue>> HasBeenSubsumedParameter { get; }
    3334    ILookupParameter<DoubleValue> ErrorZeroParameter { get; }
    3435    ILookupParameter<IntValue> ThetaSubsumptionParameter { get; }
    35 
    36     string HasBeenSubsumedParameterName { get; }
    3736  }
    3837}
Note: See TracChangeset for help on using the changeset viewer.