Rev | Line | |
---|
[2379] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
| 6 | using HeuristicLab.Data;
|
---|
| 7 | using HeuristicLab.DataAnalysis;
|
---|
| 8 |
|
---|
| 9 | namespace HeuristicLab.Modeling {
|
---|
| 10 | public class SimpleDirectionalSymmetryEvaluator : SimpleEvaluatorBase {
|
---|
| 11 |
|
---|
| 12 | public override string OutputVariableName {
|
---|
| 13 | get {
|
---|
| 14 | return "DirectionalSymmetry";
|
---|
| 15 | }
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | public override double Evaluate(double[,] values) {
|
---|
| 19 | return Calculate(values);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | public static double Calculate(double[,] values) {
|
---|
| 23 | int n = 0;
|
---|
| 24 | int nCorrect = 0;
|
---|
| 25 | for (int i = 1; i < values.GetLength(0); i++) {
|
---|
| 26 | double prevOriginal = values[i - 1, ORIGINAL_INDEX];
|
---|
| 27 | double original = values[i, ORIGINAL_INDEX];
|
---|
| 28 | double prevEstimated = values[i - 1, ESTIMATION_INDEX];
|
---|
| 29 | double estimated = values[i, ESTIMATION_INDEX];
|
---|
| 30 |
|
---|
| 31 | if (!(double.IsNaN(original) || double.IsInfinity(original) || double.IsNaN(prevOriginal) || double.IsInfinity(prevOriginal))) {
|
---|
| 32 | n++;
|
---|
| 33 | if (!(double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(prevEstimated) || double.IsInfinity(prevEstimated))) {
|
---|
| 34 | if ((original - prevOriginal) * (estimated - prevEstimated) >= 0) nCorrect++;
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | return (double)nCorrect / (double)n * 100.0;
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.