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/PolyTen.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 250; } }
    4647    protected override int TestPartitionEnd { get { return 500; } }
     48    public int Seed { get; }
    4749
     50    public PolyTen() : this((int)DateTime.Now.Ticks) { }
     51
     52    public PolyTen(int seed) : base() {
     53      Seed = seed;
     54    }
    4855    protected override List<List<double>> GenerateValues() {
    4956      List<List<double>> data = new List<List<double>>();
     57      var rand = new MersenneTwister((uint)Seed);
     58
    5059      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
    51         data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, -1, 1).ToList());
     60        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -1, 1).ToList());
    5261      }
    5362
Note: See TracChangeset for help on using the changeset viewer.