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 Feynman3 : FeynmanDescriptor{
|
---|
11 | public override string Name { get { return "Feynman I.6.2b f = exp(-((theta-theta1)/sigma)^2/2)/(sqrt(2*pi)*sigma)"; } }
|
---|
12 |
|
---|
13 | protected override string TargetVariable { get { return "f"; } }
|
---|
14 | protected override string[] VariableNames { get { return new string[] { "sigma", "theta", "theta1", "f"}; } }
|
---|
15 | protected override string[] AllowedInputVariables { get { return new string[] { "sigma", "theta", "theta1" }; } }
|
---|
16 | protected override int TrainingPartitionStart { get { return 0; } }
|
---|
17 | protected override int TrainingPartitionEnd { get { return 800; } }
|
---|
18 | protected override int TestPartitionStart { get { return 800; } }
|
---|
19 | protected override int TestPartitionEnd { get { return 1000; } }
|
---|
20 |
|
---|
21 | public int Seed { get; private set; }
|
---|
22 |
|
---|
23 | public Feynman3() : this((int)System.DateTime.Now.Ticks) { }
|
---|
24 |
|
---|
25 | public Feynman3(int seed) {
|
---|
26 | Seed = seed;
|
---|
27 | }
|
---|
28 |
|
---|
29 | protected override List<List<double>> GenerateValues() {
|
---|
30 | var rand = new MersenneTwister((uint)Seed);
|
---|
31 |
|
---|
32 | var data = new List<List<double>>();
|
---|
33 | var sigma = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
|
---|
34 | var theta = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
|
---|
35 | var theta1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
|
---|
36 |
|
---|
37 | var f = new List<double>();
|
---|
38 |
|
---|
39 | data.Add(sigma);
|
---|
40 | data.Add(theta);
|
---|
41 | data.Add(theta1);
|
---|
42 | data.Add(f);
|
---|
43 |
|
---|
44 |
|
---|
45 | for (var i = 0; i < theta.Count; i++) {
|
---|
46 | var res = Math.Exp(-(Math.Pow(theta[i] - theta1[i], 2) / sigma[i]) / 2) / (Math.Sqrt(2 * Math.PI) * sigma[i]);
|
---|
47 | f.Add(res);
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | return data;
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|