Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3075 Added first part of feynman equations as instances

File size: 2.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 Feynman5 : FeynmanDescriptor{
11 public override string Name { get { return "Feynman I.9.18 F = G*m1*m2/((x2-x1)^2+(y2-y1)^2+(z2-z1)^2)"; } }
12
13 protected override string TargetVariable { get { return "F"; } }
14    protected override string[] VariableNames { get { return new string[] { "m1", "m2", "G", "x1", "x2", "y1", "y2", "z1", "z2", "F"}; } }
15    protected override string[] AllowedInputVariables { get { return new string[] {"m1", "m2", "G", "x1", "x2", "y1", "y2", "z1", "z2"}; } }
16    protected override int TrainingPartitionStart { get { return 0; } }
17    protected override int TrainingPartitionEnd { get { return 800000; } }
18    protected override int TestPartitionStart { get { return 800000; } }
19    protected override int TestPartitionEnd { get { return 1000000; } }
20    public int Seed { get; private set; }
21
22    public Feynman5() : this((int)System.DateTime.Now.Ticks) { }
23
24    public Feynman5(int seed) {
25      Seed = seed;
26    }
27
28    protected override List<List<double>> GenerateValues() {
29      var rand = new MersenneTwister((uint)Seed);
30
31      var data = new List<List<double>>();
32      var m1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 2).ToList();
33      var m2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 2).ToList();
34      var G = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 2).ToList();
35      var x1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 3, 4).ToList();
36      var x2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 2).ToList();
37      var y1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 3, 4).ToList();
38      var y2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 2).ToList();
39      var z1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 3, 4).ToList();
40      var z2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 2).ToList();
41
42      var F = new List<double>();
43
44      data.Add(m1);
45      data.Add(m2);
46      data.Add(G);
47      data.Add(x1);
48      data.Add(x2);
49      data.Add(y1);
50      data.Add(y2);
51      data.Add(z1);
52      data.Add(z2);
53      data.Add(F);
54
55      for (var i = 0; i < x1.Count; i++) {
56        var res = G[i] * m1[i] * m2[i] / (Math.Pow(x2[i] - x1[i], 2) + Math.Pow(y2[i] - y1[i], 2) + Math.Pow(z2[i] - z1[i], 2));
57        F.Add(res);
58      }
59
60
61      return data;
62    }
63  }
64}
Note: See TracBrowser for help on using the repository browser.