Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9475


Ignore:
Timestamp:
05/09/13 18:57:22 (12 years ago)
Author:
sforsten
Message:

#1980: several small bug fixes

Location:
branches/LearningClassifierSystems
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListSolution.cs

    r9411 r9475  
    137137      double theoryLength;
    138138      var estimatedTraining = Model.Evaluate(originalTrainingCondition, out aliveRules, out theoryLength);
    139       TrainingNumberOfAliveRules = aliveRules.Count;
     139      TrainingNumberOfAliveRules = aliveRules.Count + (Model.DefaultAction != null ? 1 : 0);
    140140      TrainingAliveRules = aliveRules;
    141141      TrainingTheoryLength = theoryLength;
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs

    r9392 r9475  
    145145
    146146    // default rule cannot be deleted, but it has to be considered in the rule set size
    147     private void DoRuleDeletion(DecisionList dl, ItemSet<Rule> aliveRules, int minRules) {
     147    private void DoRuleDeletion(DecisionList dl, IEnumerable<Rule> aliveRules, int minRules) {
    148148      int ruleSetSize = dl.RuleSetSize;
    149149      if (ruleSetSize <= minRules) { return; }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformActionManipulator.cs

    r9242 r9475  
    5252    }
    5353
    54     protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child) {
     54    protected override VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double spreadpercentage) {
    5555      return Manipulate(random, child, PossibleActionsParameter.ActualValue);
    5656    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformOnePositionInConditionManipulator.cs

    r9392 r9475  
    4545    }
    4646
    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);
    4949    }
    5050
    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) {
    5252      VariableVectorCondition condition = child.Condition;
    5353      if (index >= condition.VirtualLength) {
     
    6161        keyEnumerator.MoveNext();
    6262      }
    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);
    6464      return child;
    6565    }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Manipulator/UniformSomePositionManipulator.cs

    r9204 r9475  
    5555    }
    5656
    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);
    5959    }
    6060
    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);
    6363      return ManipulateAction(random, child, probability, possibleActions);
    6464    }
    6565
    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) {
    6767      for (int index = 0; index < child.Condition.VirtualLength; index++) {
    6868        if (random.NextDouble() < probability) {
    69           child = UniformOnePositionInConditionManipulator.Manipulate(random, input, child, index);
     69          child = UniformOnePositionInConditionManipulator.Manipulate(random, input, child, index, spreadPercentage);
    7070        }
    7171      }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs

    r9467 r9475  
    124124      double delta = Max - Min;
    125125      CurrentCenter = random.NextDouble() * delta + Min;
    126       CurrentSpread = random.NextDouble() * (delta * (spreadPercentage / 100));
     126      CurrentSpread = random.NextDouble() * (delta * spreadPercentage);
    127127    }
    128128
     
    162162    }
    163163
     164    public override void Manipulate(IRandom random, string stringValue, int pos,
     165                                   double spreadPercentage) {
     166      Manipulate(random, pos, spreadPercentage);
     167    }
     168
    164169    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.");
    167171    }
    168172
     
    170174      if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); }
    171175      double delta = max - min;
    172       double maxChange = delta * (percentage / 100);
     176      double maxChange = delta * percentage;
    173177      double actualChange = (random.NextDouble() * maxChange * 2) - maxChange;
    174178      if (pos == 0) {
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IVariable.cs

    r9467 r9475  
    4646    void Manipulate(IRandom random, string stringValue, int pos);
    4747
     48    void Manipulate(IRandom random, string stringValue, int pos, double spreadPercentage);
     49
    4850    void Cover(IRandom random, string stringValue, double changeSymbolProbability);
    4951  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs

    r9467 r9475  
    166166    }
    167167
     168    public override void Manipulate(IRandom random, string stringValue, int pos,
     169                                   double spreadPercentage) {
     170      Manipulate(random, stringValue, pos);
     171    }
     172
    168173    public override void Manipulate(IRandom random, string stringValue, int pos) {
    169174      if (pos != 0) { throw new ArgumentOutOfRangeException(); }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs

    r9467 r9475  
    8787      featureMapping = new Dictionary<int, string>();
    8888      var distinctValuesEnumerator = variableValues.Distinct().GetEnumerator();
    89       possibleFeatures = Enumerable.Range(0, variableValues.Count());
     89      possibleFeatures = Enumerable.Range(0, variableValues.Count()).ToList();
    9090      var possibleFeaturesEnumerator = possibleFeatures.GetEnumerator();
    9191      while (possibleFeaturesEnumerator.MoveNext() && distinctValuesEnumerator.MoveNext()) {
     
    111111        throw new ArgumentException("featureMapping values have to be distinct.");
    112112      }
    113       this.possibleFeatures = featureMapping.Keys;
     113      this.possibleFeatures = featureMapping.Keys.ToList();
    114114      this.featureMapping = featureMapping;
    115115      Wildcard = false;
     
    212212    }
    213213
     214    public override void Manipulate(IRandom random, string stringValue, int pos,
     215                                    double spreadPercentage) {
     216      Manipulate(random, stringValue, pos);
     217    }
     218
    214219    public override void Manipulate(IRandom random, string stringValue, int pos) {
    215220      if (pos != 0) { throw new ArgumentOutOfRangeException(); }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/Variable.cs

    r9467 r9475  
    7272    public abstract void Manipulate(IRandom random, string stringValue, int pos);
    7373
     74    public abstract void Manipulate(IRandom random, string stringValue, int pos, double spreadPercentage);
     75
    7476    public abstract void Cover(IRandom random, string stringValue, double changeSymbolProbability);
    7577  }
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorManipulator.cs

    r9204 r9475  
    4242      get { return (ILookupParameter<VariableVectorInput>)Parameters["Input"]; }
    4343    }
     44    public IValueLookupParameter<IVariableVectorClassificationProblemData> ProblemDataParameter {
     45      get { return (IValueLookupParameter<IVariableVectorClassificationProblemData>)Parameters["ProblemData"]; }
     46    }
    4447    #endregion
    4548
     
    5457      Parameters.Add(new LookupParameter<VariableVector>("Child"));
    5558      Parameters.Add(new LookupParameter<VariableVectorInput>("Input"));
     59      Parameters.Add(new ValueLookupParameter<IVariableVectorClassificationProblemData>("ProblemData", ""));
    5660    }
    5761
    5862    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);
    6064      return base.Apply();
    6165    }
    6266
    63     protected abstract VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child);
     67    protected abstract VariableVector Manipulate(IRandom random, VariableVectorInput input, VariableVector child, double spreadPercentage);
    6468  }
    6569}
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/GAssist/MDL/MDLCalculator.cs

    r9392 r9475  
    8282        double error = bestSolution.TrainingExceptionsLength;
    8383        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        }
    8488        theoryWeight = (initialTheoryLengthRatio / (1.0 - initialTheoryLengthRatio)) * (error / tl);
    8589        iterationsSinceBest = 0;
     
    8791
    8892      if (activated && !fixedWeight &&
    89         GetLastIterationsAccuracyAverage(weightAdaptionIterations) == 1.0) {
     93        GetLastIterationsAccuracyAverage(weightAdaptionIterations).IsAlmost(1.0)) {
    9094        fixedWeight = true;
    9195      }
    9296
    9397      if (activated && !fixedWeight) {
    94         if (bestSolution.TrainingAccuracy != 1.0) {
     98        if (bestSolution.TrainingAccuracy.IsAlmost(1.0)) {
    9599          if (iterationsSinceBest == weightAdaptionIterations) {
    96100            theoryWeight *= weightRelaxFactor;
     
    100104      }
    101105
    102       //if (currentIteration != 0) {
    103106      UpdateStatistic(bestSolution.TrainingAccuracy);
    104       //}
    105107    }
    106108
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Selection/NichingTournamentSelector.cs

    r9411 r9475  
    8383      //check if list with indexes is as long as the original scope list
    8484      //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) {
    8686        throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate.");
    8787      }
  • branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblem.cs

    r9467 r9475  
    132132      manipulator.FetchedInputParameter.ActualName = ClassifierFetcher.CurrentInputToMatchParameter.ActualName;
    133133      manipulator.PossibleActionsParameter.ActualName = PossibleActionsConcreteClassParameter.Name;
     134      manipulator.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    134135      return new List<IManipulator>() { manipulator };
    135136    }
  • branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs

    r9411 r9475  
    136136    protected override void ActionConditionVariablesChanged() {
    137137      SampleVariableVectorParameter.Value = GenerateSampleVariableVector(Dataset, AllowedConditionVariables, AllowedActionVariables);
     138      OnChanged();
    138139    }
    139140  }
Note: See TracChangeset for help on using the changeset viewer.