Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3022-FastFunctionExtraction/FFX/ProductBaseFunction.cs @ 17737

Last change on this file since 17737 was 17737, checked in by lleko, 4 years ago

#3022 implement ffx

File size: 1.1 KB
Line 
1using HeuristicLab.Problems.DataAnalysis;
2using System;
3using System.Linq;
4
5namespace HeuristicLab.Algorithms.DataAnalysis.FastFunctionExtraction {
6    internal struct ProductBaseFunction : IBasisFunction {
7        public IBasisFunction B1 { get; set; }
8        public IBasisFunction B2 { get; set; }
9
10        public int Complexity
11            => 1 + B1.Complexity + B2.Complexity;
12
13        public bool IsNominator { get; set; }
14
15        public ProductBaseFunction(IBasisFunction b1, IBasisFunction b2, bool nominator) {
16            B1 = b1 ?? throw new ArgumentNullException(nameof(b1));
17            B2 = b2 ?? throw new ArgumentNullException(nameof(b2));
18            IsNominator = nominator;
19        }
20
21        public double[] Simulate(IRegressionProblemData data) {
22            return B1.Simulate(data).Zip(B2.Simulate(data), (a, b) => a * b).ToArray();
23        }
24
25        public override string ToString() {
26            return $"{B1} * {B2}";
27        }
28
29        public IBasisFunction DeepCopy() {
30            return new ProductBaseFunction(B1, B2, IsNominator);
31        }
32    }
33}
Note: See TracBrowser for help on using the repository browser.