Line | |
---|
1 | using HeuristicLab.Problems.DataAnalysis;
|
---|
2 | using System;
|
---|
3 | using System.Linq;
|
---|
4 |
|
---|
5 | namespace 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.