Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/AzzaliBenchmark3.cs @ 17400

Last change on this file since 17400 was 17400, checked in by pfleck, 4 years ago

#3040 Added Azzali benchmarks

File size: 2.8 KB
Line 
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5using HeuristicLab.Common;
6using HeuristicLab.Core;
7using HeuristicLab.Problems.DataAnalysis;
8using HeuristicLab.Random;
9
10namespace HeuristicLab.Problems.Instances.DataAnalysis {
11  public class AzzaliBenchmark3 : ArtificialRegressionDataDescriptor {
12    public override string Name { get { return "Azzali Benchmark2 B3 = "; } }
13    public override string Description { get { return "I. Azzali, L. Vanneschi, S. Silva, I. Bakurov, and M. Giacobini, “A Vectorial Approach to Genetic Programming,” EuroGP, pp. 213–227, 2019."; } }
14
15    protected override string TargetVariable { get { return "B3"; } }
16    protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4" }; } }
17    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4" }; } }
18    protected override int TrainingPartitionStart { get { return 0; } }
19    protected override int TrainingPartitionEnd { get { return 70; } }
20    protected override int TestPartitionStart { get { return 70; } }
21    protected override int TestPartitionEnd { get { return 100; } }
22
23    public int Seed { get; private set; }
24
25    public AzzaliBenchmark3()
26      : this((int)DateTime.Now.Ticks) { }
27    public AzzaliBenchmark3(int seed)
28      : base() {
29      Seed = seed;
30    }
31
32
33    protected override List<List<double>> GenerateValues() { return null; }
34    protected override List<IList> GenerateValuesExtended() {
35      var rand = new MersenneTwister((uint)Seed);
36
37      var x1Column = new List<DoubleVector>(100);
38      var x2Column = new List<double>(100);
39      var x3Column = new List<double>(100);
40      var x4Column = new List<double>(100);
41      var x5Column = new List<double>(100);
42      var b3Column = new List<DoubleVector>(100);
43
44      for (int i = 0; i < 100; i++) {
45        var x1 = rand.NextDoubleVector(10, 30, 20);
46        var x2 = rand.NextDouble(50, 60);
47        var x3 = rand.NextDouble(5, 10);
48        var x4 = rand.NextDouble(-2, +2);
49        var x5 = rand.NextDouble(0, 1);
50
51        int p = 3, q = 3;
52        var cumulativeMin = new DoubleVector(
53          Enumerable.Range(0, x1.Count)
54            .Select(idx => Enumerable.Range(idx - p, q)) // build index ranges for each target entry
55            .Select(indices => indices.Select(idx => idx < 0 ? 0 : x1[idx])) // take the values from the vector (fill with 0 if outside)
56            .Select(values => values.Min())
57          );
58        var b3 = (cumulativeMin * (x2 / x3)) + x4;
59
60        x1Column.Add(x1);
61        x2Column.Add(x2);
62        x3Column.Add(x3);
63        x4Column.Add(x4);
64        b3Column.Add(b3);
65      }
66
67      return new List<IList> { x1Column, x2Column, x3Column, x4Column, x5Column, b3Column };
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.