Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3075_aifeynman_instances/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Feynman/Feynman4.cs @ 17639

Last change on this file since 17639 was 17639, checked in by chaider, 4 years ago

#3075

  • Added rest of part I equations
  • Set Training/Test Partitions to 105
File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Common;
7using HeuristicLab.Random;
8
9namespace HeuristicLab.Problems.Instances.DataAnalysis {
10  public class Feynman4 : FeynmanDescriptor{
11 public override string Name { get { return "Feynman I.8.14 d = sqrt((x2-x1)^2+(y2-y1)^2)"; } }
12
13 protected override string TargetVariable { get { return "d"; } }
14    protected override string[] VariableNames { get { return new string[] { "x1", "x2", "y1", "y2", "d"}; } }
15    protected override string[] AllowedInputVariables { get { return new string[] {"x1", "x2", "y1", "y2"}; } }
16
17    public int Seed { get; private set; }
18
19    public Feynman4() : this((int)System.DateTime.Now.Ticks) { }
20
21    public Feynman4(int seed) {
22      Seed = seed;
23    }
24
25    protected override List<List<double>> GenerateValues() {
26      var rand = new MersenneTwister((uint)Seed);
27
28      var data = new List<List<double>>();
29      var x1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
30      var x2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
31      var y1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
32      var y2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
33
34      var d = new List<double>();
35
36      data.Add(x1);
37      data.Add(x2);
38      data.Add(y1);
39      data.Add(y2);
40      data.Add(d);
41
42
43      for (var i = 0; i < x1.Count; i++) {
44        var res = Math.Sqrt(Math.Pow((x2[i] - x1[i]), 2) + Math.Pow((y2[i] - y1[i]), 2));
45        d.Add(res);
46      }
47
48
49      return data;
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.