Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs @ 2305

Last change on this file since 2305 was 2226, checked in by gkronber, 15 years ago
  • Added extension method IsAlmost to type double
  • changed evaluation semantics of boolean operations in HL3TreeEvaluator

(#713)

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Data;
7using HeuristicLab.DataAnalysis;
8
9namespace HeuristicLab.Modeling {
10  public abstract class SimpleEvaluatorBase : OperatorBase {
11    public virtual string OutputVariableName {
12      get { return "Quality"; }
13    }
14    public SimpleEvaluatorBase()
15      : base() {
16      AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In));
17      AddVariableInfo(new VariableInfo(OutputVariableName, OutputVariableName, typeof(DoubleData), VariableKind.New | VariableKind.Out));
18    }
19
20    public override IOperation Apply(IScope scope) {
21      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true);
22      DoubleData quality = GetVariableValue<DoubleData>(OutputVariableName, scope, false, false);
23      if (quality == null) {
24        quality = new DoubleData();
25        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(OutputVariableName), quality));
26      }
27
28      quality.Data = Evaluate(values.Data);
29      return null;
30    }
31
32    public abstract double Evaluate(double[,] values);
33  }
34}
Note: See TracBrowser for help on using the repository browser.