Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/ProblemInstances/FluidDynamics.cs @ 16123

Last change on this file since 16123 was 15928, checked in by lkammere, 7 years ago

#2886: Add problem instance providers for grammar enumeration.

File size: 2.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using HeuristicLab.Problems.Instances.DataAnalysis;
5using HeuristicLab.Random;
6
7namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration {
8  class FluidDynamics : ArtificialRegressionDataDescriptor {
9    public override string Name { get { return "Flow psi = x1*x2*x5*(1 - x4²/x5²) + 1/(2*Pi) * x3*log(x5/x4)"; } }
10
11    public override string Description {
12      get {
13        return "Paper: A multilevel block building algorithm for fast modeling generalized separable systems. " + Environment.NewLine +
14               "Author: Chen Chen, Changtong Luo, Zonglin Jiang" + Environment.NewLine +
15               "Function: f(X) = x1*x2*x5*(1 - x4²/x5²) + 1/(2*Pi) * x3*log(x5/x4)" + Environment.NewLine +
16               "with x1 in [60,65], x2 in [30, 40], x3 in [5,10], x4 in [0.5,0.8], x5 in [0.2,0.5]";
17      }
18    }
19
20    protected override string TargetVariable { get { return "f(X)"; } }
21    protected override string[] VariableNames { get { return new string[] { "x1", "x2", "x3", "x4", "x5", "f(X)" }; } }
22    protected override string[] AllowedInputVariables { get { return new string[] { "x1", "x2", "x3", "x4", "x5" }; } }
23    protected override int TrainingPartitionStart { get { return 0; } }
24    protected override int TrainingPartitionEnd { get { return 100; } }
25    protected override int TestPartitionStart { get { return 100; } }
26    protected override int TestPartitionEnd { get { return 200; } }
27
28    public int Seed { get; private set; }
29
30    public FluidDynamics() : this((int)System.DateTime.Now.Ticks) { }
31
32    public FluidDynamics(int seed) {
33      Seed = seed;
34    }
35
36    protected override List<List<double>> GenerateValues() {
37      var rand = new MersenneTwister((uint)Seed);
38
39      List<List<double>> data = new List<List<double>>();
40      var x1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 60.0, 65.0).ToList();
41      var x2 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 30.0, 40.0).ToList();
42      var x3 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 5.0, 10.0).ToList();
43      var x4 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0.5, 0.8).ToList();
44      var x5 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 0.2, 0.5).ToList();
45
46      List<double> fx = new List<double>();
47      data.Add(x1);
48      data.Add(x2);
49      data.Add(x3);
50      data.Add(x4);
51      data.Add(x5);
52      data.Add(fx);
53
54      for (int i = 0; i < x1.Count; i++) {
55        double fxi = x1[i] * x2[i] * x5[i] * (1 - (x4[i] * x4[i]) / (x5[i] * x5[i])) +
56                     (1 / (2 * Math.PI)) * x3[i] * Math.Log(x5[i] / x4[i]);
57        fx.Add(fxi);
58      }
59
60      return data;
61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.