- Timestamp:
- 04/23/13 13:31:29 (11 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Crossover/SinglePointCrossover.cs
r9242 r9392 62 62 IList<IVariable> newCondition = new List<IVariable>(parent1Condition.VariableDictionary.Count); 63 63 64 var keyEnumerator = parent1Condition. Order.GetEnumerator();64 var keyEnumerator = parent1Condition.VariableDictionary.Keys.GetEnumerator(); 65 65 66 66 int index = 0; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformOnePositionInConditionManipulator.cs
r9242 r9392 54 54 throw new ArgumentOutOfRangeException(); 55 55 } 56 var keyEnumerator = condition. Order.GetEnumerator();56 var keyEnumerator = condition.VariableDictionary.Keys.GetEnumerator(); 57 57 int count = 0; 58 58 keyEnumerator.MoveNext(); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
r9242 r9392 130 130 var targetCast = target as DoubleVariable; 131 131 if (targetCast == null) { return false; } 132 if (variableName != targetCast.variableName || currentCenter.IsAlmost(targetCast.currentCenter)133 || currentSpread.IsAlmost(targetCast.currentSpread) ||max.IsAlmost(targetCast.max)134 || min.IsAlmost(targetCast.min)) { return false; }132 if (variableName != targetCast.variableName || !currentCenter.IsAlmost(targetCast.currentCenter) 133 || !currentSpread.IsAlmost(targetCast.currentSpread) || !max.IsAlmost(targetCast.max) 134 || !min.IsAlmost(targetCast.min)) { return false; } 135 135 136 136 return true; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs
r9242 r9392 133 133 || currentValue != targetCast.currentValue) { return false; } 134 134 135 if (possibleFeatures.Except(targetCast.possibleFeatures).Count() != 0 136 || targetCast.possibleFeatures.Except(possibleFeatures).Count() != 0) { return false; } 135 var thisEnumerator = possibleFeatures.GetEnumerator(); 136 var castEnumerator = targetCast.possibleFeatures.GetEnumerator(); 137 while (thisEnumerator.MoveNext() && castEnumerator.MoveNext()) { 138 if (thisEnumerator.Current != castEnumerator.Current) 139 return false; 140 } 137 141 138 return true;142 return !thisEnumerator.MoveNext() && !castEnumerator.MoveNext(); 139 143 } 140 144 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs
r9242 r9392 87 87 featureMapping = new Dictionary<int, string>(); 88 88 var distinctValuesEnumerator = variableValues.Distinct().GetEnumerator(); 89 possibleFeatures = Enumerable.Range(0, featureMapping.Count());89 possibleFeatures = Enumerable.Range(0, variableValues.Count()); 90 90 var possibleFeaturesEnumerator = possibleFeatures.GetEnumerator(); 91 91 while (possibleFeaturesEnumerator.MoveNext() && distinctValuesEnumerator.MoveNext()) { … … 178 178 || currentValue != targetCast.currentValue) { return false; } 179 179 180 if (featureMapping.Keys.Except(targetCast.featureMapping.Keys).Count() != 0 181 || targetCast.featureMapping.Keys.Except(featureMapping.Keys).Count() != 0) { return false; } 182 183 foreach (var keyValuePair in targetCast.featureMapping) { 184 if (!featureMapping[keyValuePair.Key].Equals(keyValuePair.Value)) { return false; } 185 } 186 187 return true; 180 var thisEnumerator = featureMapping.GetEnumerator(); 181 var castEnumerator = targetCast.featureMapping.GetEnumerator(); 182 while (thisEnumerator.MoveNext() && castEnumerator.MoveNext()) { 183 if (thisEnumerator.Current.Key != castEnumerator.Current.Key || 184 thisEnumerator.Current.Value != castEnumerator.Current.Value) 185 return false; 186 } 187 188 return !thisEnumerator.MoveNext() && !castEnumerator.MoveNext(); 188 189 } 189 190 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorActionComparer.cs
r9242 r9392 21 21 22 22 using System.Collections.Generic; 23 using System.Linq;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 43 42 44 43 public bool Equals(VariableVectorAction x, VariableVectorAction y) { 45 if (!x.Order.SequenceEqual(y.Order)) return false; 46 foreach (var key in x.VariableDictionary.Keys) { 47 if (!x.VariableDictionary[key].Identical(y.VariableDictionary[key])) { 48 return false; 44 //if (!x.Order.SequenceEqual(y.Order)) return false; 45 var xEnumerator = x.VariableDictionary.Keys.GetEnumerator(); 46 var yEnumerator = y.VariableDictionary.Keys.GetEnumerator(); 47 while (xEnumerator.MoveNext() && yEnumerator.MoveNext()) 48 foreach (var key in x.VariableDictionary.Keys) { 49 if (xEnumerator.Current != yEnumerator.Current || 50 !x.VariableDictionary[xEnumerator.Current].Identical(y.VariableDictionary[yEnumerator.Current])) { 51 return false; 52 } 49 53 } 50 } 51 return true; 54 return !xEnumerator.MoveNext() && !yEnumerator.MoveNext(); 52 55 } 53 56 -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorCondition.cs
r9242 r9392 39 39 protected set { variableDictionary = value; } 40 40 } 41 42 public IOrderedEnumerable<string> Order { get { return VariableDictionary.Keys.OrderBy(x => x); } }43 41 44 42 public int VirtualLength { get { return VariableDictionary.Values.Sum(x => x.VirtualLength); } } … … 110 108 111 109 public bool Identical(VariableVectorCondition target) { 112 if (!this.Order.SequenceEqual(target.Order)) { return false; } 113 foreach (var keyValuePair in target.VariableDictionary) { 114 if (!VariableDictionary[keyValuePair.Key].Identical(keyValuePair.Value)) { 110 var thisEnumerator = VariableDictionary.GetEnumerator(); 111 var targetEnumerator = target.VariableDictionary.GetEnumerator(); 112 113 while (thisEnumerator.MoveNext() && targetEnumerator.MoveNext()) { 114 if (thisEnumerator.Current.Key != targetEnumerator.Current.Key || 115 !thisEnumerator.Current.Value.Identical(targetEnumerator.Current.Value)) { 115 116 return false; 116 117 } 117 118 } 118 return true; 119 120 return !thisEnumerator.MoveNext() && !targetEnumerator.MoveNext(); 119 121 } 120 122 }
Note: See TracChangeset
for help on using the changeset viewer.