Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Various/PolyTen.cs @ 14419

Last change on this file since 14419 was 14229, checked in by gkronber, 8 years ago

#2371: removed usage of C# 6.0 readonly properties

File size: 3.5 KB
RevLine 
[7849]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[7849]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
[14228]25using HeuristicLab.Random;
[7849]26
27namespace HeuristicLab.Problems.Instances.DataAnalysis {
28  public class PolyTen : ArtificialRegressionDataDescriptor {
29
30    public override string Name { get { return "Poly-10 y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10"; } }
31    public override string Description {
32      get {
33        return "Paper: A Simple but Theoretically-motivated Method to Control Bloat in Genetic Programming" + Environment.NewLine
34        + "Authors: Riccardo Poli" + Environment.NewLine
35        + "Function: y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10" + Environment.NewLine
36        + "Terminal set: x1, x2, x3, x4, x5, x6, x7, x8, x9, x10" + Environment.NewLine
37        + "Fitness was minus the sum of the absolute values of the errors made over 50 fitness cases. "
38        + "These were generated by randomly assigning values to the variables xiin the range [1, 1].";
39      }
40    }
41    protected override string TargetVariable { get { return "Y"; } }
[8825]42    protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "Y" }; } }
[7849]43    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10" }; } }
44    protected override int TrainingPartitionStart { get { return 0; } }
45    protected override int TrainingPartitionEnd { get { return 250; } }
46    protected override int TestPartitionStart { get { return 250; } }
47    protected override int TestPartitionEnd { get { return 500; } }
[14229]48    public int Seed { get; private set; }
[7849]49
[14228]50    public PolyTen() : this((int)DateTime.Now.Ticks) { }
51
52    public PolyTen(int seed) : base() {
53      Seed = seed;
54    }
[7849]55    protected override List<List<double>> GenerateValues() {
56      List<List<double>> data = new List<List<double>>();
[14228]57      var rand = new MersenneTwister((uint)Seed);
58
[7849]59      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
[14228]60        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, -1, 1).ToList());
[7849]61      }
62
63      double x1, x2, x3, x4, x5, x6, x7, x8, x9, x10;
64      List<double> results = new List<double>();
65      for (int i = 0; i < data[0].Count; i++) {
66        x1 = data[0][i];
67        x2 = data[1][i];
68        x3 = data[2][i];
69        x4 = data[3][i];
70        x5 = data[4][i];
71        x6 = data[5][i];
72        x7 = data[6][i];
73        x8 = data[7][i];
74        x9 = data[8][i];
75        x10 = data[9][i];
76        results.Add(x1 * x2 + x3 * x4 + x5 * x6 + x1 * x7 * x9 + x3 * x6 * x10);
77      }
78      data.Add(results);
79
80      return data;
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.