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/Vladislavleva/KotanchekFunction.cs

    r14185 r14228  
    2424using System.Linq;
    2525using HeuristicLab.Common;
     26using HeuristicLab.Random;
    2627
    2728namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4748    protected override int TestPartitionEnd { get { return 100 + (45 * 45); } }
    4849
     50    public int Seed { get; }
     51
     52    public KotanchekFunction() : this((int)DateTime.Now.Ticks) { }
     53
     54    public KotanchekFunction(int seed) : base() {
     55      Seed = seed;
     56    }
    4957    protected override List<List<double>> GenerateValues() {
    5058      List<List<double>> data = new List<List<double>>();
     
    5361      List<List<double>> testData = new List<List<double>>() { oneVariableTestData, oneVariableTestData };
    5462      var combinations = ValueGenerator.GenerateAllCombinationsOfValuesInLists(testData).ToList<IEnumerable<double>>();
     63      var rand = new MersenneTwister((uint)Seed);
     64
    5565      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
    56         data.Add(ValueGenerator.GenerateUniformDistributedValues(100, 0.3, 4).ToList());
     66        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 100, 0.3, 4).ToList());
    5767        data[i].AddRange(combinations[i]);
    5868      }
Note: See TracChangeset for help on using the changeset viewer.