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/Korns/KornsFunctionNine.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    5152    protected override int TestPartitionStart { get { return 10000; } }
    5253    protected override int TestPartitionEnd { get { return 20000; } }
     54    public int Seed { get; }
    5355
     56    public KornsFunctionNine() : this((int)System.DateTime.Now.Ticks) {
     57    }
     58    public KornsFunctionNine(int seed) : base() {
     59      Seed = seed;
     60    }
    5461    protected override List<List<double>> GenerateValues() {
    5562      List<List<double>> data = new List<List<double>>();
    56       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, 0, 50).ToList()); // note: range is only [0,50] to prevent NaN values (deviates from gp benchmark paper)
    57       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, 0, 50).ToList()); // note: range is only [0,50] to prevent NaN values (deviates from gp benchmark paper)
    58       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, -50, 50).ToList());
    59       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, -50, 50).ToList());
    60       data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, -50, 50).ToList());
     63      var rand = new MersenneTwister((uint)Seed);
     64
     65      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0, 50).ToList()); // note: range is only [0,50] to prevent NaN values (deviates from gp benchmark paper)
     66      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0, 50).ToList()); // note: range is only [0,50] to prevent NaN values (deviates from gp benchmark paper)
     67      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -50, 50).ToList());
     68      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -50, 50).ToList());
     69      data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -50, 50).ToList());
    6170
    6271      double x0, x1, x2, x3;
Note: See TracChangeset for help on using the changeset viewer.