Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3022-FastFunctionExtraction/FFX/BasisFunction.cs @ 17593

Last change on this file since 17593 was 17227, checked in by lleko, 5 years ago

#3022: Add implementation for FFX.

File size: 1.5 KB
Line 
1using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
2using System;
3using System.Collections.Generic;
4using System.Diagnostics;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace 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.