Changeset 4038
- Timestamp:
- 07/15/10 14:01:09 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionEvaluator.cs
r4035 r4038 35 35 using HeuristicLab.Operators; 36 36 using HeuristicLab.Problems.DataAnalysis.Symbolic; 37 using HeuristicLab.Random; 37 38 38 39 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic { … … 131 132 132 133 public override IOperation Apply() { 133 IEnumerable<int> rows = GenerateRowsToEvaluate(RelativeNumberOfEvaluatedSamples.Value, SamplesStart.Value, SamplesEnd.Value); 134 uint seed = (uint)Random.Next(); 135 IEnumerable<int> rows = GenerateRowsToEvaluate(seed, RelativeNumberOfEvaluatedSamples.Value, SamplesStart.Value, SamplesEnd.Value); 134 136 double quality = Evaluate(SymbolicExpressionTreeInterpreter, SymbolicExpressionTree, RegressionProblemData.Dataset, 135 137 RegressionProblemData.TargetVariable, rows); … … 140 142 141 143 //algorithm taken from progamming pearls page 127 142 private IEnumerable<int> GenerateRowsToEvaluate(double relativeAmount, int start, int end) { 144 //IMPORTANT because IEnumerables with yield are used the seed must best be specified to return always 145 //the same sequence of numbers without caching the values. 146 private static IEnumerable<int> GenerateRowsToEvaluate(uint seed, double relativeAmount, int start, int end) { 143 147 if (end < start) throw new ArgumentException("Start value is larger than end value."); 144 148 int count = (int)((end - start) * relativeAmount); … … 146 150 147 151 int remaining = end - start; 152 MersenneTwister random = new MersenneTwister(seed); 148 153 for (int i = start; i < end && count > 0; i++) { 149 double probabilty = Random.NextDouble();154 double probabilty = random.NextDouble(); 150 155 if (probabilty < ((double)count) / remaining) { 151 156 count--;
Note: See TracChangeset
for help on using the changeset viewer.