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

    r14185 r14228  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Random;
    2526
    2627namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4950    protected override int TestPartitionStart { get { return 10000; } }
    5051    protected override int TestPartitionEnd { get { return 20000; } }
     52    public int Seed { get; }
    5153
     54    public KornsFunctionThree() : this((int)System.DateTime.Now.Ticks) {
     55    }
     56    public KornsFunctionThree(int seed) : base() {
     57      Seed = seed;
     58    }
    5259    protected override List<List<double>> GenerateValues() {
    5360      List<List<double>> data = new List<List<double>>();
     61      var rand = new MersenneTwister((uint)Seed);
    5462      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
    55         data.Add(ValueGenerator.GenerateUniformDistributedValues(TestPartitionEnd, -50, 50).ToList());
     63        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -50, 50).ToList());
    5664      }
    5765
Note: See TracChangeset for help on using the changeset viewer.