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/KornsFunctionOne.cs

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    5051    protected override int TestPartitionStart { get { return 10000; } }
    5152    protected override int TestPartitionEnd { get { return 20000; } }
     53    public int Seed { get; }
    5254
     55    public KornsFunctionOne() : this((int)System.DateTime.Now.Ticks) {
     56    }
     57    public KornsFunctionOne(int seed) : base() {
     58      Seed = seed;
     59    }
    5360    protected override List<List<double>> GenerateValues() {
    5461      List<List<double>> data = new List<List<double>>();
     62      var rand = new MersenneTwister((uint)Seed);
     63
    5564      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
    56         data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, -50, 50).ToList());
     65        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -50, 50).ToList());
    5766      }
    5867
Note: See TracChangeset for help on using the changeset viewer.