Index: /branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
===================================================================
--- /branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 17652)
+++ /branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 17653)
@@ -178,4 +178,5 @@
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveConstraintConstOptEvaluator.cs" />
+    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator.cs" />
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveConstraintPearsonRSquaredEvaluator.cs" />
     <Compile Include="SingleObjective\SymbolicRegressionSolutionsAnalyzer.cs" />
Index: /branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator.cs
===================================================================
--- /branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator.cs	(revision 17653)
+++ /branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator.cs	(revision 17653)
@@ -0,0 +1,129 @@
+﻿using System;
+using System.Collections.Generic;
+using HEAL.Attic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Parameters;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.SingleObjective.Evaluators {
+  [Item("Constraint ConstOpt NMSE Evaluator", "")]
+  [StorableType("DED36D85-A4BA-4019-B12D-C523F7327899")]
+  public class SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator
+    : SymbolicRegressionSingleObjectiveEvaluator {
+    private const string UseConstOptParameterName = "Use ConstOpt";
+    private const string ConstOptIterationsParameterName = "ConstOpt Iterations";
+
+    public IFixedValueParameter<BoolValue> UseConstOptParamerter =>
+      (IFixedValueParameter<BoolValue>) Parameters[UseConstOptParameterName];
+
+    public IFixedValueParameter<IntValue> ConstOpterIterationsParameter =>
+      (IFixedValueParameter<IntValue>) Parameters[ConstOptIterationsParameterName];
+
+    public bool UseConstOpt {
+      get => UseConstOptParamerter.Value.Value;
+      set => UseConstOptParamerter.Value.Value = value;
+    }
+
+    public int ConstOptIterations {
+      get => ConstOpterIterationsParameter.Value.Value;
+      set => ConstOpterIterationsParameter.Value.Value = value;
+    }
+
+    [StorableConstructor]
+    protected SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator(StorableConstructorFlag _) : base(_) {}
+
+    protected SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator(
+      SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator original, Cloner cloner) :
+      base(original, cloner) { }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator(this, cloner);
+    }
+
+    public SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator() {
+      Parameters.Add(new FixedValueParameter<BoolValue>(UseConstOptParameterName,
+        "Define whether constOpt is active or not.", new BoolValue(true)));
+      Parameters.Add(new FixedValueParameter<IntValue>(ConstOptIterationsParameterName,
+        "Define how many constOpt iterations should be performed.", new IntValue(10)));
+    }
+
+    public override bool Maximization => false;
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (!Parameters.ContainsKey(UseConstOptParameterName)) {
+        Parameters.Add(new FixedValueParameter<BoolValue>(UseConstOptParameterName,
+          "Define whether constOpt is active or not.", new BoolValue(true)));
+      }
+
+      if (!Parameters.ContainsKey(ConstOptIterationsParameterName)) {
+        Parameters.Add(new FixedValueParameter<IntValue>(ConstOptIterationsParameterName,
+          "Define how many constOpt iterations should be performed.", new IntValue(10)));
+      }
+    }
+
+    public override IOperation InstrumentedApply() {
+      var rows                                      = GenerateRowsToEvaluate();
+      var solution                                  = SymbolicExpressionTreeParameter.ActualValue;
+      var problemData                               = ProblemDataParameter.ActualValue;
+      var interpreter                               = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
+      var estimationLimits                          = EstimationLimitsParameter.ActualValue;
+      var applyLinearScaling                        = false;
+      var constantOptimizationIterations            = ConstOptIterations;
+      var constantOptimizationUpdateVariableWeights = true;
+
+      //Use Const Opt
+      if(UseConstOpt)
+        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows,
+          applyLinearScaling, constantOptimizationIterations, constantOptimizationUpdateVariableWeights,
+          estimationLimits.Lower, estimationLimits.Upper);
+
+      var quality = Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData, rows,
+        applyLinearScaling);
+      QualityParameter.ActualValue = new DoubleValue(quality);
+      return base.InstrumentedApply();
+    }
+
+    public static double Calculate(
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      ISymbolicExpressionTree solution, double lowerEstimationLimit,
+      double upperEstimationLimit,
+      IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
+      var estimatedValues =
+        interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
+      var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
+      var constraints = problemData.IntervalConstraints.EnabledConstraints;
+      var variableRanges = problemData.VariableRanges.GetReadonlyDictionary();
+
+      if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution))
+        return double.MaxValue;
+
+      var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
+      var nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out var errorState);
+      if (errorState != OnlineCalculatorError.None) nmse = double.NaN;
+
+      return nmse;
+    }
+    
+    public override double Evaluate(
+      IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData,
+      IEnumerable<int> rows) {
+      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
+      EstimationLimitsParameter.ExecutionContext                    = context;
+      ApplyLinearScalingParameter.ExecutionContext                  = context;
+
+      var nmse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree,
+        EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper,
+        problemData, rows,
+        ApplyLinearScalingParameter.ActualValue.Value);
+
+      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
+      EstimationLimitsParameter.ExecutionContext                    = null;
+      ApplyLinearScalingParameter.ExecutionContext                  = null;
+
+      return nmse;
+    }
+  }
+}
