Rev | Line | |
---|
[17737] | 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 |
|
---|
[17779] | 10 | public int Complexity => 1 + B1.Complexity + B2.Complexity;
|
---|
[17737] | 11 |
|
---|
[17779] | 12 | public bool IsDenominator { get; set; }
|
---|
[17737] | 13 |
|
---|
[17779] | 14 | public ProductBaseFunction(IBasisFunction b1, IBasisFunction b2, bool isDenominator) {
|
---|
[17737] | 15 | B1 = b1 ?? throw new ArgumentNullException(nameof(b1));
|
---|
| 16 | B2 = b2 ?? throw new ArgumentNullException(nameof(b2));
|
---|
[17779] | 17 | IsDenominator = isDenominator;
|
---|
[17737] | 18 | }
|
---|
| 19 |
|
---|
[17779] | 20 | public double[] Evaluate(IRegressionProblemData data) {
|
---|
| 21 | return B1.Evaluate(data).Zip(B2.Evaluate(data), (a, b) => a * b).ToArray();
|
---|
[17737] | 22 | }
|
---|
| 23 |
|
---|
| 24 | public override string ToString() {
|
---|
| 25 | return $"{B1} * {B2}";
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public IBasisFunction DeepCopy() {
|
---|
[17779] | 29 | return new ProductBaseFunction(B1, B2, IsDenominator);
|
---|
[17737] | 30 | }
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.