Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/28/13 17:54:46 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added necessary interface ICondition, IAction, IInput
  • removed not used class MatchSelector and interface IMatchSelector
  • added constructors to ItemDictionary
  • added new encoding
Location:
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVector.cs

    r9175 r9194  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Text;
     
    3334  [StorableClass]
    3435  [Item("CombinedIntegerVector", "Represents a combined vector of integer values.")]
    35   public class CombinedIntegerVector : IntegerVector, IClassifier {
     36  public class CombinedIntegerVector : IntegerVector, IClassifier, ICondition, IAction, IInput {
    3637
    3738    [Storable]
     
    121122    }
    122123
    123     public IClassifier Condition {
     124    public ICondition Condition {
    124125      get {
    125126        int[] condition = new int[Length - actionLength];
     
    129130    }
    130131
    131     public IClassifier Action {
     132    public IAction Action {
    132133      get {
    133134        int[] action = new int[actionLength];
     
    152153    }
    153154
    154     public bool MatchCondition(IClassifier target) {
     155    public bool MatchInput(IInput target) {
    155156      var targetVector = target as CombinedIntegerVector;
    156157      if (targetVector == null) return false;
    157       if (targetVector.Length != this.Length) return false;
     158      if (targetVector.Length - targetVector.actionLength != this.Length - this.actionLength) return false;
    158159
    159160      int curbounds;
     
    171172    }
    172173
     174    public bool MatchAction(IClassifier target) {
     175      return MatchAction(target.Action);
     176    }
     177
    173178    // no "don't care" symbols have to be considered
    174     public bool MatchAction(IClassifier target) {
     179    public bool MatchAction(IAction target) {
    175180      var targetVector = target as CombinedIntegerVector;
    176181      if (targetVector == null) return false;
     
    188193
    189194    public bool IsMoreGeneral(IClassifier target) {
     195      return IsMoreGeneral(target as ICondition);
     196    }
     197
     198    public bool IsMoreGeneral(ICondition target) {
    190199      var targetVector = target as CombinedIntegerVector;
    191200      int curbounds;
     
    201210      return true;
    202211    }
     212
     213    #region ICondition Members
     214    public bool Match(IInput target) {
     215      return MatchInput(target);
     216    }
     217    #endregion
     218
     219    #region IAction Members
     220    public bool Match(IAction target) {
     221      return MatchAction(target);
     222    }
     223    #endregion
    203224
    204225    private int NumberOfGeneralSymbols() {
     
    233254    }
    234255
    235     public override bool Equals(object obj) {
    236       var cast = obj as CombinedIntegerVector;
    237       if (cast != null) {
    238         return this.Equals(cast);
    239       }
    240       return false;
    241     }
    242 
    243     public bool Equals(IClassifier other) {
    244       var cast = other as CombinedIntegerVector;
     256    public bool Identical(IClassifier target) {
     257      var cast = target as CombinedIntegerVector;
    245258      if (cast == null) { return false; }
    246259      for (int i = 0; i < array.Length; i++) {
     
    252265    }
    253266
     267    public override bool Equals(object obj) {
     268      return base.Equals(obj);
     269    }
     270
    254271    public override int GetHashCode() {
    255       int result = actionLength;
    256       for (int i = 0; i < array.Length; i++) {
    257         result ^= array[i];
    258       }
    259       return result.GetHashCode();
     272      return base.GetHashCode();
     273    }
     274
     275    [StorableClass]
     276    [Item("CombinedIntegerVectorComparer", "")]
     277    public class CombinedIntegerVectorComparer : Item, IEqualityComparer<CombinedIntegerVector>, IClassifierComparer {
     278
     279      [StorableConstructor]
     280      protected CombinedIntegerVectorComparer(bool deserializing) : base(deserializing) { }
     281      protected CombinedIntegerVectorComparer(CombinedIntegerVectorComparer original, Cloner cloner)
     282        : base(original, cloner) {
     283      }
     284      public override IDeepCloneable Clone(Cloner cloner) {
     285        return new CombinedIntegerVectorComparer(this, cloner);
     286      }
     287      public CombinedIntegerVectorComparer() : base() { }
     288
     289      public bool Equals(CombinedIntegerVector x, CombinedIntegerVector y) {
     290        for (int i = 0; i < x.array.Length; i++) {
     291          if (!x.array[i].Equals(y.array[i])) {
     292            return false;
     293          }
     294        }
     295        return true;
     296      }
     297
     298      public int GetHashCode(CombinedIntegerVector obj) {
     299        int result = obj.actionLength;
     300        for (int i = 0; i < obj.array.Length; i++) {
     301          result ^= obj.array[i];
     302        }
     303        return result.GetHashCode();
     304      }
     305
     306      public bool Equals(IAction x, IAction y) {
     307        var xCast = x as CombinedIntegerVector;
     308        var yCast = y as CombinedIntegerVector;
     309        return x != null && y != null && Equals(xCast, yCast);
     310      }
     311
     312      public int GetHashCode(IAction obj) {
     313        var objCast = obj as CombinedIntegerVector;
     314        return objCast != null ? GetHashCode(objCast) : obj.GetHashCode();
     315      }
    260316    }
    261317  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVectorManipulator.cs

    r9110 r9194  
    3939      get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Child"]; }
    4040    }
    41     public ILookupParameter<CombinedIntegerVector> FetchedClassifierParameter {
     41    public ILookupParameter<CombinedIntegerVector> FetchedConditionParameter {
    4242      get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Parent"]; }
    4343    }
     
    5757
    5858    public sealed override IOperation Apply() {
    59       ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedClassifierParameter.ActualValue, ChildParameter.ActualValue);
     59      ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedConditionParameter.ActualValue, ChildParameter.ActualValue);
    6060      return base.Apply();
    6161    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs

    r9110 r9194  
    3434
    3535    #region Parameter Properties
    36     public ILookupParameter<IClassifier> CoverClassifierParameter {
    37       get { return (ILookupParameter<IClassifier>)Parameters["CoverClassifier"]; }
     36    public ILookupParameter<IInput> CoverInputParameter {
     37      get { return (ILookupParameter<IInput>)Parameters["CoverInput"]; }
    3838    }
    39     public ILookupParameter<IClassifier> ActionParameter {
    40       get { return (ILookupParameter<IClassifier>)Parameters["Action"]; }
     39    public ILookupParameter<IAction> ActionParameter {
     40      get { return (ILookupParameter<IAction>)Parameters["Action"]; }
    4141    }
    4242    public IValueLookupParameter<IClassifier> CreatedClassifierParameter {
     
    6262    public CombinedIntegerVectorCoveringCreator()
    6363      : base() {
    64       Parameters.Add(new LookupParameter<IClassifier>("CoverClassifier"));
    65       Parameters.Add(new LookupParameter<IClassifier>("Action"));
     64      Parameters.Add(new LookupParameter<IInput>("CoverInput"));
     65      Parameters.Add(new LookupParameter<IAction>("Action"));
    6666      Parameters.Add(new ValueLookupParameter<IClassifier>("CreatedClassifier"));
    6767      Parameters.Add(new LookupParameter<PercentValue>("ChangeSymbolProbability"));
     
    7070
    7171    public override IOperation Apply() {
    72       CombinedIntegerVector newCondition = (CombinedIntegerVector)CoverClassifierParameter.ActualValue.Condition.Clone();
     72      CombinedIntegerVector newCondition = (CombinedIntegerVector)CoverInputParameter.ActualValue.Clone();
    7373
    74       CombinedIntegerVector condition = (CombinedIntegerVector)CoverClassifierParameter.ActualValue.Condition;
    75       CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue.Action;
     74      CombinedIntegerVector condition = (CombinedIntegerVector)CoverInputParameter.ActualValue;
     75      CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue;
    7676
    7777      newCondition = UniformSomePositionManipulator.ManipulateCondition(RandomParameter.ActualValue, condition, newCondition, ChangeSymbolProbabilityParameter.ActualValue.Value);
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3.csproj

    r9154 r9194  
    8989      <Private>False</Private>
    9090    </Reference>
    91     <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    92       <Private>False</Private>
    93     </Reference>
    9491    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    9592      <Private>False</Private>
     
    149146  </ItemGroup>
    150147  <ItemGroup>
     148    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
     149      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
     150      <Name>HeuristicLab.Core-3.3</Name>
     151    </ProjectReference>
    151152    <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj">
    152153      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorManipulator.cs

    r9110 r9194  
    2929  public interface ICombinedIntegerVectorManipulator : IManipulator, ICombinedIntegerVectorOperator {
    3030    ILookupParameter<CombinedIntegerVector> ChildParameter { get; }
    31     ILookupParameter<CombinedIntegerVector> FetchedClassifierParameter { get; }
     31    ILookupParameter<CombinedIntegerVector> FetchedConditionParameter { get; }
    3232  }
    3333}
Note: See TracChangeset for help on using the changeset viewer.