Changeset 9475
- Timestamp:
- 05/09/13 18:57:22 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListSolution.cs
r9411 r9475 137 137 double theoryLength; 138 138 var estimatedTraining = Model.Evaluate(originalTrainingCondition, out aliveRules, out theoryLength); 139 TrainingNumberOfAliveRules = aliveRules.Count ;139 TrainingNumberOfAliveRules = aliveRules.Count + (Model.DefaultAction != null ? 1 : 0); 140 140 TrainingAliveRules = aliveRules; 141 141 TrainingTheoryLength = theoryLength; -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs
r9392 r9475 145 145 146 146 // default rule cannot be deleted, but it has to be considered in the rule set size 147 private void DoRuleDeletion(DecisionList dl, I temSet<Rule> aliveRules, int minRules) {147 private void DoRuleDeletion(DecisionList dl, IEnumerable<Rule> aliveRules, int minRules) { 148 148 int ruleSetSize = dl.RuleSetSize; 149 149 if (ruleSetSize <= minRules) { return; } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformActionManipulator.cs
r9242 r9475 52 52 } 53 53 54 protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child ) {54 protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double spreadpercentage) { 55 55 return Manipulate(random, child, PossibleActionsParameter.ActualValue); 56 56 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformOnePositionInConditionManipulator.cs
r9392 r9475 45 45 } 46 46 47 protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child ) {48 return Manipulate(random, input, child, random.Next(child.Condition.VirtualLength) );47 protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double spreadPercentage) { 48 return Manipulate(random, input, child, random.Next(child.Condition.VirtualLength), spreadPercentage); 49 49 } 50 50 51 public static VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, int index ) {51 public static VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, int index, double spreadPercentage) { 52 52 VariableVectorCondition condition = child.Condition; 53 53 if (index >= condition.VirtualLength) { … … 61 61 keyEnumerator.MoveNext(); 62 62 } 63 condition.VariableDictionary[keyEnumerator.Current].Manipulate(random, input.InputDictionary[keyEnumerator.Current], index - count );63 condition.VariableDictionary[keyEnumerator.Current].Manipulate(random, input.InputDictionary[keyEnumerator.Current], index - count, spreadPercentage); 64 64 return child; 65 65 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformSomePositionManipulator.cs
r9204 r9475 55 55 } 56 56 57 protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child ) {58 return Manipulate(random, input, child, ProbabilityParameter.ActualValue.Value, PossibleActionsParameter.ActualValue );57 protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double spreadPercentage) { 58 return Manipulate(random, input, child, ProbabilityParameter.ActualValue.Value, PossibleActionsParameter.ActualValue, spreadPercentage); 59 59 } 60 60 61 public static VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double probability, IItemSet<VariableVectorAction> possibleActions ) {62 child = ManipulateCondition(random, input, child, probability );61 public static VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double probability, IItemSet<VariableVectorAction> possibleActions, double spreadPercentage) { 62 child = ManipulateCondition(random, input, child, probability, spreadPercentage); 63 63 return ManipulateAction(random, child, probability, possibleActions); 64 64 } 65 65 66 public static VariableVector ManipulateCondition(IRandom random, VariableVectorInput input, VariableVector child, double probability ) {66 public static VariableVector ManipulateCondition(IRandom random, VariableVectorInput input, VariableVector child, double probability, double spreadPercentage) { 67 67 for (int index = 0; index < child.Condition.VirtualLength; index++) { 68 68 if (random.NextDouble() < probability) { 69 child = UniformOnePositionInConditionManipulator.Manipulate(random, input, child, index );69 child = UniformOnePositionInConditionManipulator.Manipulate(random, input, child, index, spreadPercentage); 70 70 } 71 71 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
r9467 r9475 124 124 double delta = Max - Min; 125 125 CurrentCenter = random.NextDouble() * delta + Min; 126 CurrentSpread = random.NextDouble() * (delta * (spreadPercentage / 100));126 CurrentSpread = random.NextDouble() * (delta * spreadPercentage); 127 127 } 128 128 … … 162 162 } 163 163 164 public override void Manipulate(IRandom random, string stringValue, int pos, 165 double spreadPercentage) { 166 Manipulate(random, pos, spreadPercentage); 167 } 168 164 169 public override void Manipulate(IRandom random, string stringValue, int pos) { 165 if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); } 166 Manipulate(random, pos, 10); 170 throw new NotImplementedException("DoubleVariable.Manipulate(IRandom, string, int) cannot be used. Use DoubleVariable.Manipulate(IRandom, string, int, double) or DoubleVariable.Manipulate(IRandom, int, double) instead."); 167 171 } 168 172 … … 170 174 if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); } 171 175 double delta = max - min; 172 double maxChange = delta * (percentage / 100);176 double maxChange = delta * percentage; 173 177 double actualChange = (random.NextDouble() * maxChange * 2) - maxChange; 174 178 if (pos == 0) { -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IVariable.cs
r9467 r9475 46 46 void Manipulate(IRandom random, string stringValue, int pos); 47 47 48 void Manipulate(IRandom random, string stringValue, int pos, double spreadPercentage); 49 48 50 void Cover(IRandom random, string stringValue, double changeSymbolProbability); 49 51 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs
r9467 r9475 166 166 } 167 167 168 public override void Manipulate(IRandom random, string stringValue, int pos, 169 double spreadPercentage) { 170 Manipulate(random, stringValue, pos); 171 } 172 168 173 public override void Manipulate(IRandom random, string stringValue, int pos) { 169 174 if (pos != 0) { throw new ArgumentOutOfRangeException(); } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs
r9467 r9475 87 87 featureMapping = new Dictionary<int, string>(); 88 88 var distinctValuesEnumerator = variableValues.Distinct().GetEnumerator(); 89 possibleFeatures = Enumerable.Range(0, variableValues.Count()) ;89 possibleFeatures = Enumerable.Range(0, variableValues.Count()).ToList(); 90 90 var possibleFeaturesEnumerator = possibleFeatures.GetEnumerator(); 91 91 while (possibleFeaturesEnumerator.MoveNext() && distinctValuesEnumerator.MoveNext()) { … … 111 111 throw new ArgumentException("featureMapping values have to be distinct."); 112 112 } 113 this.possibleFeatures = featureMapping.Keys ;113 this.possibleFeatures = featureMapping.Keys.ToList(); 114 114 this.featureMapping = featureMapping; 115 115 Wildcard = false; … … 212 212 } 213 213 214 public override void Manipulate(IRandom random, string stringValue, int pos, 215 double spreadPercentage) { 216 Manipulate(random, stringValue, pos); 217 } 218 214 219 public override void Manipulate(IRandom random, string stringValue, int pos) { 215 220 if (pos != 0) { throw new ArgumentOutOfRangeException(); } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/Variable.cs
r9467 r9475 72 72 public abstract void Manipulate(IRandom random, string stringValue, int pos); 73 73 74 public abstract void Manipulate(IRandom random, string stringValue, int pos, double spreadPercentage); 75 74 76 public abstract void Cover(IRandom random, string stringValue, double changeSymbolProbability); 75 77 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorManipulator.cs
r9204 r9475 42 42 get { return (ILookupParameter<VariableVectorInput>)Parameters["Input"]; } 43 43 } 44 public IValueLookupParameter<IVariableVectorClassificationProblemData> ProblemDataParameter { 45 get { return (IValueLookupParameter<IVariableVectorClassificationProblemData>)Parameters["ProblemData"]; } 46 } 44 47 #endregion 45 48 … … 54 57 Parameters.Add(new LookupParameter<VariableVector>("Child")); 55 58 Parameters.Add(new LookupParameter<VariableVectorInput>("Input")); 59 Parameters.Add(new ValueLookupParameter<IVariableVectorClassificationProblemData>("ProblemData", "")); 56 60 } 57 61 58 62 public sealed override IOperation Apply() { 59 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedInputParameter.ActualValue, ChildParameter.ActualValue );63 ChildParameter.ActualValue = Manipulate(RandomParameter.ActualValue, FetchedInputParameter.ActualValue, ChildParameter.ActualValue, ProblemDataParameter.ActualValue.SpreadPercentageParameter.Value.Value); 60 64 return base.Apply(); 61 65 } 62 66 63 protected abstract VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child );67 protected abstract VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double spreadPercentage); 64 68 } 65 69 } -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/MDL/MDLCalculator.cs
r9392 r9475 82 82 double error = bestSolution.TrainingExceptionsLength; 83 83 double tl = (bestSolution.TrainingTheoryLength * bestSolution.Classes) / bestSolution.TrainingNumberOfAliveRules; 84 if (tl.IsAlmost(0.0)) { 85 //as done in the original implementation 86 tl = 0.00000001; 87 } 84 88 theoryWeight = (initialTheoryLengthRatio / (1.0 - initialTheoryLengthRatio)) * (error / tl); 85 89 iterationsSinceBest = 0; … … 87 91 88 92 if (activated && !fixedWeight && 89 GetLastIterationsAccuracyAverage(weightAdaptionIterations) == 1.0) {93 GetLastIterationsAccuracyAverage(weightAdaptionIterations).IsAlmost(1.0)) { 90 94 fixedWeight = true; 91 95 } 92 96 93 97 if (activated && !fixedWeight) { 94 if (bestSolution.TrainingAccuracy != 1.0) {98 if (bestSolution.TrainingAccuracy.IsAlmost(1.0)) { 95 99 if (iterationsSinceBest == weightAdaptionIterations) { 96 100 theoryWeight *= weightRelaxFactor; … … 100 104 } 101 105 102 //if (currentIteration != 0) {103 106 UpdateStatistic(bestSolution.TrainingAccuracy); 104 //}105 107 } 106 108 -
branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Selection/NichingTournamentSelector.cs
r9411 r9475 83 83 //check if list with indexes is as long as the original scope list 84 84 //otherwise invalid quality values were filtered 85 if (qualities.Count != scopes.Count &&individuals.Count != scopes.Count) {85 if (qualities.Count != scopes.Count || individuals.Count != scopes.Count) { 86 86 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 87 87 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblem.cs
r9467 r9475 132 132 manipulator.FetchedInputParameter.ActualName = ClassifierFetcher.CurrentInputToMatchParameter.ActualName; 133 133 manipulator.PossibleActionsParameter.ActualName = PossibleActionsConcreteClassParameter.Name; 134 manipulator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 134 135 return new List<IManipulator>() { manipulator }; 135 136 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs
r9411 r9475 136 136 protected override void ActionConditionVariablesChanged() { 137 137 SampleVariableVectorParameter.Value = GenerateSampleVariableVector(Dataset, AllowedConditionVariables, AllowedActionVariables); 138 OnChanged(); 138 139 } 139 140 }
Note: See TracChangeset
for help on using the changeset viewer.