Changeset 9194 for branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding
- Timestamp:
- 01/28/13 17:54:46 (12 years ago)
- 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 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Text; … … 33 34 [StorableClass] 34 35 [Item("CombinedIntegerVector", "Represents a combined vector of integer values.")] 35 public class CombinedIntegerVector : IntegerVector, IClassifier {36 public class CombinedIntegerVector : IntegerVector, IClassifier, ICondition, IAction, IInput { 36 37 37 38 [Storable] … … 121 122 } 122 123 123 public IC lassifierCondition {124 public ICondition Condition { 124 125 get { 125 126 int[] condition = new int[Length - actionLength]; … … 129 130 } 130 131 131 public I ClassifierAction {132 public IAction Action { 132 133 get { 133 134 int[] action = new int[actionLength]; … … 152 153 } 153 154 154 public bool Match Condition(IClassifiertarget) {155 public bool MatchInput(IInput target) { 155 156 var targetVector = target as CombinedIntegerVector; 156 157 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; 158 159 159 160 int curbounds; … … 171 172 } 172 173 174 public bool MatchAction(IClassifier target) { 175 return MatchAction(target.Action); 176 } 177 173 178 // no "don't care" symbols have to be considered 174 public bool MatchAction(I Classifiertarget) {179 public bool MatchAction(IAction target) { 175 180 var targetVector = target as CombinedIntegerVector; 176 181 if (targetVector == null) return false; … … 188 193 189 194 public bool IsMoreGeneral(IClassifier target) { 195 return IsMoreGeneral(target as ICondition); 196 } 197 198 public bool IsMoreGeneral(ICondition target) { 190 199 var targetVector = target as CombinedIntegerVector; 191 200 int curbounds; … … 201 210 return true; 202 211 } 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 203 224 204 225 private int NumberOfGeneralSymbols() { … … 233 254 } 234 255 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; 245 258 if (cast == null) { return false; } 246 259 for (int i = 0; i < array.Length; i++) { … … 252 265 } 253 266 267 public override bool Equals(object obj) { 268 return base.Equals(obj); 269 } 270 254 271 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 } 260 316 } 261 317 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/CombinedIntegerVectorManipulator.cs
r9110 r9194 39 39 get { return (ILookupParameter<CombinedIntegerVector>)Parameters["Child"]; } 40 40 } 41 public ILookupParameter<CombinedIntegerVector> FetchedC lassifierParameter {41 public ILookupParameter<CombinedIntegerVector> FetchedConditionParameter { 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, FetchedC lassifierParameter.ActualValue, ChildParameter.ActualValue);59 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedConditionParameter.ActualValue, ChildParameter.ActualValue); 60 60 return base.Apply(); 61 61 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs
r9110 r9194 34 34 35 35 #region Parameter Properties 36 public ILookupParameter<I Classifier> CoverClassifierParameter {37 get { return (ILookupParameter<I Classifier>)Parameters["CoverClassifier"]; }36 public ILookupParameter<IInput> CoverInputParameter { 37 get { return (ILookupParameter<IInput>)Parameters["CoverInput"]; } 38 38 } 39 public ILookupParameter<I Classifier> ActionParameter {40 get { return (ILookupParameter<I Classifier>)Parameters["Action"]; }39 public ILookupParameter<IAction> ActionParameter { 40 get { return (ILookupParameter<IAction>)Parameters["Action"]; } 41 41 } 42 42 public IValueLookupParameter<IClassifier> CreatedClassifierParameter { … … 62 62 public CombinedIntegerVectorCoveringCreator() 63 63 : base() { 64 Parameters.Add(new LookupParameter<I Classifier>("CoverClassifier"));65 Parameters.Add(new LookupParameter<I Classifier>("Action"));64 Parameters.Add(new LookupParameter<IInput>("CoverInput")); 65 Parameters.Add(new LookupParameter<IAction>("Action")); 66 66 Parameters.Add(new ValueLookupParameter<IClassifier>("CreatedClassifier")); 67 67 Parameters.Add(new LookupParameter<PercentValue>("ChangeSymbolProbability")); … … 70 70 71 71 public override IOperation Apply() { 72 CombinedIntegerVector newCondition = (CombinedIntegerVector)Cover ClassifierParameter.ActualValue.Condition.Clone();72 CombinedIntegerVector newCondition = (CombinedIntegerVector)CoverInputParameter.ActualValue.Clone(); 73 73 74 CombinedIntegerVector condition = (CombinedIntegerVector)Cover ClassifierParameter.ActualValue.Condition;75 CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue .Action;74 CombinedIntegerVector condition = (CombinedIntegerVector)CoverInputParameter.ActualValue; 75 CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue; 76 76 77 77 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 89 89 <Private>False</Private> 90 90 </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>94 91 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 95 92 <Private>False</Private> … … 149 146 </ItemGroup> 150 147 <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> 151 152 <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj"> 152 153 <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project> -
branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Interfaces/ICombinedIntegerVectorManipulator.cs
r9110 r9194 29 29 public interface ICombinedIntegerVectorManipulator : IManipulator, ICombinedIntegerVectorOperator { 30 30 ILookupParameter<CombinedIntegerVector> ChildParameter { get; } 31 ILookupParameter<CombinedIntegerVector> FetchedC lassifierParameter { get; }31 ILookupParameter<CombinedIntegerVector> FetchedConditionParameter { get; } 32 32 } 33 33 }
Note: See TracChangeset
for help on using the changeset viewer.