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

    r14185 r14228  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Random;
    2425
    2526namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    3738      get { return "McDermott et al., 2012 \"Genetic Programming Needs Better Benchmarks\", in Proc. of GECCO 2012."; }
    3839    }
     40    public int Seed { get; }
     41
     42    public NguyenInstanceProvider() : this((int)System.DateTime.Now.Ticks) { }
     43    public NguyenInstanceProvider(int seed) : base() {
     44      Seed = seed;
     45    }
    3946
    4047    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    4148      List<IDataDescriptor> descriptorList = new List<IDataDescriptor>();
    42       descriptorList.Add(new NguyenFunctionOne());
    43       descriptorList.Add(new NguyenFunctionTwo());
    44       descriptorList.Add(new NguyenFunctionThree());
    45       descriptorList.Add(new NguyenFunctionFour());
    46       descriptorList.Add(new NguyenFunctionFive());
    47       descriptorList.Add(new NguyenFunctionSix());
    48       descriptorList.Add(new NguyenFunctionSeven());
    49       descriptorList.Add(new NguyenFunctionEight());
    50       descriptorList.Add(new NguyenFunctionNine());
    51       descriptorList.Add(new NguyenFunctionTen());
    52       descriptorList.Add(new NguyenFunctionEleven());
    53       descriptorList.Add(new NguyenFunctionTwelve());
     49      var rand = new MersenneTwister((uint)Seed);
     50      descriptorList.Add(new NguyenFunctionOne(rand.Next()));
     51      descriptorList.Add(new NguyenFunctionTwo(rand.Next()));
     52      descriptorList.Add(new NguyenFunctionThree(rand.Next()));
     53      descriptorList.Add(new NguyenFunctionFour(rand.Next()));
     54      descriptorList.Add(new NguyenFunctionFive(rand.Next()));
     55      descriptorList.Add(new NguyenFunctionSix(rand.Next()));
     56      descriptorList.Add(new NguyenFunctionSeven(rand.Next()));
     57      descriptorList.Add(new NguyenFunctionEight(rand.Next()));
     58      descriptorList.Add(new NguyenFunctionNine(rand.Next()));
     59      descriptorList.Add(new NguyenFunctionTen(rand.Next()));
     60      descriptorList.Add(new NguyenFunctionEleven(rand.Next()));
     61      descriptorList.Add(new NguyenFunctionTwelve(rand.Next()));
    5462      return descriptorList;
    5563    }
Note: See TracChangeset for help on using the changeset viewer.