Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3075_aifeynman_instances/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Feynman/Feynman24.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 HeuristicLab.Random;
5
6namespace HeuristicLab.Problems.Instances.DataAnalysis {
7  public class Feynman24 : FeynmanDescriptor {
8    public override string Name { get { return "Feynman I.24.6 1/2*m*(omega**2+omega_0**2)*1/2*x**2"; } }
9
10    protected override string TargetVariable { get { return "E_n"; } }
11    protected override string[] VariableNames { get { return new[] {"m", "omega", "omega_0", "x", "E_n"}; } }
12    protected override string[] AllowedInputVariables { get { return new[] {"m", "omega", "omega_0", "x"}; } }
13
14    public int Seed { get; private set; }
15
16    public Feynman24() : this((int) DateTime.Now.Ticks) { }
17
18    public Feynman24(int seed) {
19      Seed = seed;
20    }
21
22    protected override List<List<double>> GenerateValues() {
23      var rand = new MersenneTwister((uint) Seed);
24
25      var data    = new List<List<double>>();
26      var m       = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
27      var omega   = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
28      var omega_0 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
29      var x       = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
30
31      var E_n = new List<double>();
32
33      data.Add(m);
34      data.Add(omega);
35      data.Add(omega_0);
36      data.Add(x);
37      data.Add(E_n);
38
39      for (var i = 0; i < m.Count; i++) {
40        var res = 1.0 / 2 * m[i] * (Math.Pow(omega[i], 2) + Math.Pow(omega_0[i], 2)) * 1.0 / 2 * Math.Pow(x[i], 2);
41        E_n.Add(res);
42      }
43
44      return data;
45    }
46  }
47}
Note: See TracBrowser for help on using the repository browser.