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/Keijzer/KeijzerFunctionFifteen.cs

    r14185 r14228  
    2424using System.Linq;
    2525using HeuristicLab.Common;
     26using HeuristicLab.Random;
    2627
    2728namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4647    protected override int TestPartitionStart { get { return 20; } }
    4748    protected override int TestPartitionEnd { get { return 20 + (601 * 601); } }
     49    public int Seed { get; }
    4850
     51    public KeijzerFunctionFifteen() : this((int)System.DateTime.Now.Ticks) {
     52    }
     53    public KeijzerFunctionFifteen(int seed) : base() {
     54      Seed = seed;
     55    }
    4956    protected override List<List<double>> GenerateValues() {
    5057      List<List<double>> data = new List<List<double>>();
     
    5360
    5461      var combinations = ValueGenerator.GenerateAllCombinationsOfValuesInLists(testData).ToList();
     62      var rand = new MersenneTwister((uint)Seed);
    5563
    5664      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
    57         data.Add(ValueGenerator.GenerateUniformDistributedValues(20, -3, 3).ToList());
     65        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 20, -3, 3).ToList());
    5866        data[i].AddRange(combinations[i]);
    5967      }
Note: See TracChangeset for help on using the changeset viewer.