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.5 KB
|
Rev | Line | |
---|
[17639] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Threading.Tasks;
|
---|
| 6 | using HeuristicLab.Common;
|
---|
| 7 | using HeuristicLab.Random;
|
---|
| 8 |
|
---|
| 9 | namespace HeuristicLab.Problems.Instances.DataAnalysis {
|
---|
| 10 | public class Feynman16 : FeynmanDescriptor{
|
---|
| 11 | public override string Name { get { return "Feynman I.14.4 U = 1/2*k_spring*x^2"; } }
|
---|
| 12 |
|
---|
| 13 | protected override string TargetVariable { get { return "U"; } }
|
---|
| 14 | protected override string[] VariableNames { get { return new string[] { "k_spring", "x", "U"}; } }
|
---|
| 15 | protected override string[] AllowedInputVariables { get { return new string[] {"k_spring", "x"}; } }
|
---|
| 16 |
|
---|
| 17 | public int Seed { get; private set; }
|
---|
| 18 |
|
---|
| 19 | public Feynman16() : this((int)System.DateTime.Now.Ticks) { }
|
---|
| 20 |
|
---|
| 21 | public Feynman16(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 k_spring = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
|
---|
| 30 | var x = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 5).ToList();
|
---|
| 31 |
|
---|
| 32 | var U = new List<double>();
|
---|
| 33 |
|
---|
| 34 | data.Add(k_spring);
|
---|
| 35 | data.Add(x);
|
---|
| 36 | data.Add(U);
|
---|
| 37 |
|
---|
| 38 | for (var i = 0; i < k_spring.Count; i++) {
|
---|
| 39 | var res = 1.0 / 2 * k_spring[i] * Math.Pow(x[i], 2);
|
---|
| 40 | U.Add(res);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | return data;
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.