using System; using System.Collections; using System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Problems.DataAnalysis; using HeuristicLab.Random; namespace HeuristicLab.Problems.Instances.DataAnalysis { public class AzzaliBenchmark3 : ArtificialRegressionDataDescriptor { public override string Name { get { return "Azzali Benchmark2 B3 = "; } } 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."; } } protected override string TargetVariable { get { return "B3"; } } protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4" }; } } protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4" }; } } protected override int TrainingPartitionStart { get { return 0; } } protected override int TrainingPartitionEnd { get { return 70; } } protected override int TestPartitionStart { get { return 70; } } protected override int TestPartitionEnd { get { return 100; } } public int Seed { get; private set; } public AzzaliBenchmark3() : this((int)DateTime.Now.Ticks) { } public AzzaliBenchmark3(int seed) : base() { Seed = seed; } protected override List> GenerateValues() { return null; } protected override List GenerateValuesExtended() { var rand = new MersenneTwister((uint)Seed); var x1Column = new List(100); var x2Column = new List(100); var x3Column = new List(100); var x4Column = new List(100); var x5Column = new List(100); var b3Column = new List(100); for (int i = 0; i < 100; i++) { var x1 = rand.NextDoubleVector(10, 30, 20); var x2 = rand.NextDouble(50, 60); var x3 = rand.NextDouble(5, 10); var x4 = rand.NextDouble(-2, +2); var x5 = rand.NextDouble(0, 1); int p = 3, q = 3; var cumulativeMin = new DoubleVector( Enumerable.Range(0, x1.Count) .Select(idx => Enumerable.Range(idx - p, q)) // build index ranges for each target entry .Select(indices => indices.Select(idx => idx < 0 ? 0 : x1[idx])) // take the values from the vector (fill with 0 if outside) .Select(values => values.Min()) ); var b3 = (cumulativeMin * (x2 / x3)) + x4; x1Column.Add(x1); x2Column.Add(x2); x3Column.Add(x3); x4Column.Add(x4); b3Column.Add(b3); } return new List { x1Column, x2Column, x3Column, x4Column, x5Column, b3Column }; } } }