Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3149 was 2977, checked in by gkronber, 15 years ago

Moved linear scaling functionality out of tree evaluator into a separate operator. #823 (Implement tree evaluator with linear scaling to improve convergence in symbolic regression.)

File size: 1.3 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 const int ORIGINAL_INDEX = 0;
12    public const int ESTIMATION_INDEX = 1;
13
14    public virtual string OutputVariableName {
15      get { return "Quality"; }
16    }
17    public SimpleEvaluatorBase()
18      : base() {
19      AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In));
20      AddVariableInfo(new VariableInfo(OutputVariableName, OutputVariableName, typeof(DoubleData), VariableKind.New | VariableKind.Out));
21    }
22
23    public override IOperation Apply(IScope scope) {
24      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true);
25      DoubleData quality = GetVariableValue<DoubleData>(OutputVariableName, scope, false, false);
26      if (quality == null) {
27        quality = new DoubleData();
28        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(OutputVariableName), quality));
29      }
30
31      quality.Data = Evaluate(values.Data);
32      return null;
33    }
34
35    public abstract double Evaluate(double[,] values);
36  }
37}
Note: See TracBrowser for help on using the repository browser.