#region License Information /* HeuristicLab * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Random; namespace HeuristicLab.Problems.Instances.DataAnalysis { public class ScalingProblem5 : ArtificialRegressionDataDescriptor { public override string Name { get { return "JKK-5 F5(X1,X2,X3) = sqrt(X1/log(X2)) + X1/X3"; } } public override string Description { get { return "Function: F5(X1,X2,X3) = sqrt(X1/log(X2)) + X1/X3" + Environment.NewLine + "Data: 250 points X1, X3 = Rand(1, 2), X2 = Rand(2,100)" + Environment.NewLine + "Function Set: +, -, *, /, square, e^x, e^-x, x^eps, x + eps, x * eps"; } } protected override string TargetVariable { get { return "Y"; } } protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "Y" }; } } protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3" }; } } protected override int TrainingPartitionStart { get { return 0; } } protected override int TrainingPartitionEnd { get { return 250; } } protected override int TestPartitionStart { get { return 250; } } protected override int TestPartitionEnd { get { return 1000; } } public int Seed { get; private set; } public ScalingProblem5() : this((int)DateTime.Now.Ticks) { } public ScalingProblem5(int seed) : base() { Seed = seed; } protected override List> GenerateValues() { var rand = new MersenneTwister((uint)Seed); var data = Enumerable.Range(0, AllowedInputVariables.Count()).Select(_ => Enumerable.Range(0, TestPartitionEnd).Select(__ => rand.NextDouble() + 1).ToList()).ToList(); data[1] = Enumerable.Range(0, TestPartitionEnd).Select(_ => rand.NextDouble() * 99 + 1).ToList(); double x1, x2, x3; List results = new List(); for (int i = 0; i < data[0].Count; i++) { x1 = data[0][i]; x2 = data[1][i]; x3 = data[2][i]; results.Add(Math.Sqrt(x1 / (Math.Log(x2))) + (x1 / x3)); } data.Add(results); return data; } } }