Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3075_aifeynman_instances/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Feynman/Feynman7.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.3 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 Feynman7 : FeynmanDescriptor{
11 public override string Name { get { return "Feynman I.11.19 A = x1*y1+x2*y2+x3*y3"; } }
12
13 protected override string TargetVariable { get { return "A"; } }
14    protected override string[] VariableNames { get { return new string[] { "x1", "x2", "x3", "y1", "y2", "y3", "A"}; } }
15    protected override string[] AllowedInputVariables { get { return new string[] {"x1", "x2", "x3", "y1", "y2", "y3"}; } }
16    protected override int TrainingPartitionStart { get { return 0; } }
17    protected override int TrainingPartitionEnd { get { return 80; } }
18    protected override int TestPartitionStart { get { return 80; } }
19    protected override int TestPartitionEnd { get { return 100; } }
20    public int Seed { get; private set; }
21
22    public Feynman7() : this((int)System.DateTime.Now.Ticks) { }
23
24    public Feynman7(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 x1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
33      var x2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
34      var x3 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
35      var y1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
36      var y2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
37      var y3 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
38
39      var A = new List<double>();
40
41      data.Add(x1);
42      data.Add(x2);
43      data.Add(x3);
44      data.Add(y1);
45      data.Add(y2);
46      data.Add(y3);
47      data.Add(A);
48
49      for (var i = 0; i < x1.Count; i++) {
50        var res = x1[i] * y1[i] + x2[i] * y2[i] + x3[i] * y3[i];
51        A.Add(res);
52      }
53
54
55      return data;
56    }
57  }
58}
Note: See TracBrowser for help on using the repository browser.