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/Nguyen/NguyenFunctionTen.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4546    protected override int TestPartitionStart { get { return 20; } }
    4647    protected override int TestPartitionEnd { get { return 1020; } }
     48    public int Seed { get; }
    4749
     50    public NguyenFunctionTen() : this((int)System.DateTime.Now.Ticks) { }
     51    public NguyenFunctionTen(int seed) : base() {
     52      Seed = seed;
     53    }
    4854    protected override List<List<double>> GenerateValues() {
    4955      List<List<double>> data = new List<List<double>>();
    50       data.Add(ValueGenerator.GenerateUniformDistributedValues(1020, 0, 1).ToList());
    51       data.Add(ValueGenerator.GenerateUniformDistributedValues(1020, 0, 1).ToList());
     56      var rand = new MersenneTwister((uint)Seed);
     57
     58      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 1020, 0, 1).ToList());
     59      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 1020, 0, 1).ToList());
    5260
    5361      double x, y;
Note: See TracChangeset for help on using the changeset viewer.