Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/02/16 18:09:47 (8 years ago)
Author:
gkronber
Message:

#2371: added constructors to allow specification of random seeds for randomly generated regression problem instances (primarily for unit tests)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Various/BreimanOne.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Core;
    2526using HeuristicLab.Random;
    2627
     
    4344    protected override int TestPartitionEnd { get { return 10001; } }
    4445
    45     protected static FastRandom rand = new FastRandom();
     46    public int Seed { get; }
     47
     48    public BreimanOne() : this((int)DateTime.Now.Ticks) { }
     49    public BreimanOne(int seed) : base() {
     50      Seed = seed;
     51    }
    4652
    4753    protected override List<List<double>> GenerateValues() {
    4854      List<List<double>> data = new List<List<double>>();
    4955      List<int> values = new List<int>() { -1, 1 };
    50       data.Add(GenerateUniformIntegerDistribution(values, TestPartitionEnd));
     56      var rand = new MersenneTwister((uint)Seed);
     57      data.Add(GenerateUniformIntegerDistribution(rand, values, TestPartitionEnd));
    5158      values.Add(0);
    5259      for (int i = 0; i < AllowedInputVariables.Count() - 1; i++) {
    53         data.Add(GenerateUniformIntegerDistribution(values, TestPartitionEnd));
     60        data.Add(GenerateUniformIntegerDistribution(rand, values, TestPartitionEnd));
    5461      }
    55 
    5662      double x1, x2, x3, x4, x5, x6, x7;
    5763      double f;
     
    7985    }
    8086
    81     private List<double> GenerateUniformIntegerDistribution(List<int> classes, int amount) {
     87    private List<double> GenerateUniformIntegerDistribution(IRandom rand, List<int> classes, int amount) {
    8288      List<double> values = new List<double>();
    8389      for (int i = 0; i < amount; i++) {
Note: See TracChangeset for help on using the changeset viewer.