Line | |
---|
1 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
2 | using System;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Diagnostics;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Text;
|
---|
7 | using System.Threading.Tasks;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Algorithms.DataAnalysis.FastFunctionExtraction
|
---|
10 | {
|
---|
11 |
|
---|
12 | struct BasisFunction
|
---|
13 | {
|
---|
14 | public string Var { get; set; } // e.g. "Abs(Column1 ** 2)"
|
---|
15 | public double[] Val { get; set; } // this holds the already calculated values, i.e. the function written in Var
|
---|
16 | public bool IsOperator { get; set; }// alg needs to check if basis function has an operator
|
---|
17 | public NonlinOp Operator { get; }
|
---|
18 |
|
---|
19 | public BasisFunction(string var, double[] val, bool isOperator, NonlinOp op = NonlinOp.None)
|
---|
20 | {
|
---|
21 | this.Var = var;
|
---|
22 | this.Val= val;
|
---|
23 | this.IsOperator = isOperator;
|
---|
24 | this.Operator = op;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public static BasisFunction operator *(BasisFunction a, BasisFunction b)
|
---|
28 | {
|
---|
29 | Debug.Assert(a.Val.Length == b.Val.Length);
|
---|
30 | double[] newVal = new double[a.Val.Length];
|
---|
31 | for(int i = 0; i < a.Val.Length; i++)
|
---|
32 | {
|
---|
33 | newVal[i] = a.Val[i] * b.Val[i];
|
---|
34 | }
|
---|
35 | return new BasisFunction(a.Var + " * " + b.Var, newVal, false);
|
---|
36 | }
|
---|
37 |
|
---|
38 | public int Complexity() => 1;
|
---|
39 |
|
---|
40 | public ISymbolicExpressionTree Tree()
|
---|
41 | {
|
---|
42 | return null;
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.