Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/04/13 16:16:38 (11 years ago)
Author:
sforsten
Message:

#1980:

  • deleted not needed interface IMatching
  • finished VariableVector encoding
  • the algorithm LearningClassifierSystem is now independent of a specific encoding. It still needs the ConditionActionEncoding.
  • merged r9191:9203 HeuristicLab.Core from trunk to branch
Location:
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3

    • Property svn:ignore set to
      obj
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs

    r9194 r9204  
    137137    public override double GetGenerality() {
    138138      double delta = max - min;
    139       double intervalWidth = 2 * currentSpread;
    140       double generality = intervalWidth / delta;
     139      double intervalInBoundsWidth = Math.Min(max, currentCenter + currentSpread) - Math.Max(min, currentCenter - currentSpread);
     140      double generality = intervalInBoundsWidth / delta;
    141141      return generality > 1 ? 1 : generality;
    142142    }
     
    159159      return crossed;
    160160    }
     161
     162    public override void Manipulate(IRandom random, string stringValue, int pos) {
     163      if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); }
     164      Manipulate(random, pos, 10);
     165    }
     166
     167    public void Manipulate(IRandom random, int pos, double percentage) {
     168      if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); }
     169      double delta = max - min;
     170      double maxChange = delta * (percentage / 100);
     171      double actualChange = (random.NextDouble() * maxChange * 2) - maxChange;
     172      if (pos == 0) {
     173        currentCenter += actualChange;
     174      } else if (pos == 1) {
     175        currentSpread += actualChange;
     176        //otherwise the interval could be corrupt and no input could match the rule.
     177        currentSpread = currentSpread > 0 ? currentSpread : 0;
     178      }
     179    }
     180
     181    public override void Cover(IRandom random, string stringValue, double changeSymbolProbability) {
     182      Cover(random, stringValue, 50);
     183    }
     184
     185    public void CoverWithSpreadPercentage(IRandom random, string stringValue, double spreadPercentage) {
     186      currentCenter = double.Parse(stringValue);
     187      double delta = max - min;
     188      currentSpread = random.NextDouble() * (delta * (spreadPercentage / 100));
     189    }
    161190  }
    162191}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IVariable.cs

    r9194 r9204  
    4141
    4242    IVariable CrossParentsAtPosition(IVariable parent2, int pos);
     43
     44    void Manipulate(IRandom random, string stringValue, int pos);
     45
     46    void Cover(IRandom random, string stringValue, double changeSymbolProbability);
    4347  }
    4448}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs

    r9194 r9204  
    8686
    8787    public override string ToString() {
    88       return currentValue.ToString();
     88      return Wildcard ? "#" : currentValue.ToString();
    8989    }
    9090
     
    145145      return this.GetSetCopy();
    146146    }
     147
     148    public override void Manipulate(IRandom random, string stringValue, int pos) {
     149      if (pos != 0) { throw new ArgumentOutOfRangeException(); }
     150      Wildcard = !Wildcard;
     151      if (!Wildcard) {
     152        currentValue = int.Parse(stringValue);
     153      }
     154    }
     155
     156    public override void Cover(IRandom random, string stringValue, double changeSymbolProbability) {
     157      Wildcard = random.NextDouble() < changeSymbolProbability;
     158      if (!Wildcard) {
     159        currentValue = int.Parse(stringValue);
     160      }
     161    }
    147162  }
    148163}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs

    r9194 r9204  
    134134
    135135    public override string ToString() {
    136       return CurrentStringValue;
     136      return Wildcard ? "#" : CurrentStringValue;
    137137    }
    138138
     
    197197      return this.GetSetCopy();
    198198    }
     199
     200    public override void Manipulate(IRandom random, string stringValue, int pos) {
     201      if (pos != 0) { throw new ArgumentOutOfRangeException(); }
     202      Wildcard = !Wildcard;
     203      if (!Wildcard) {
     204        int newValue = featureMapping.First(x => x.Value.Equals(stringValue)).Key;
     205        currentValue = newValue;
     206      }
     207    }
     208
     209    public override void Cover(IRandom random, string stringValue, double changeSymbolProbability) {
     210      Wildcard = random.NextDouble() < changeSymbolProbability;
     211      if (!Wildcard) {
     212        int newValue = featureMapping.First(x => x.Value.Equals(stringValue)).Key;
     213        currentValue = newValue;
     214      }
     215    }
    199216  }
    200217}
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/Variable.cs

    r9194 r9204  
    6969
    7070    public virtual IVariable CrossParentsAtPosition(IVariable parent2, int pos) { throw new NotSupportedException("This method is not supported."); }
     71
     72    public abstract void Manipulate(IRandom random, string stringValue, int pos);
     73
     74    public abstract void Cover(IRandom random, string stringValue, double changeSymbolProbability);
    7175  }
    7276}
Note: See TracChangeset for help on using the changeset viewer.