Ignore:
Timestamp:
10/04/19 09:34:18 (3 years ago)
Author:
gkronber
Message:

#2994: add names for constraints and derivatives, fix a problem: variableRanges are reset when creating a new solution. fix smaller bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Extensions/ConstrainedNLS.cs

    r17214 r17311  
    174174      int idx = 0;
    175175      var formatter = new InfixExpressionFormatter();
     176      var constraintDescriptions = state.ConstraintDescriptions.ToArray();
    176177      foreach(var constraintTree in state.constraintTrees) {
    177178        // HACK to remove parameter nodes which occurr multiple times
    178179        var reparsedTree = parser.Parse(formatter.Format(constraintTree));
    179         Results.AddOrUpdateResult($"Constraint {idx++}", reparsedTree);
     180        Results.AddOrUpdateResult($"{constraintDescriptions[idx++]}", reparsedTree);
    180181      }
    181182
     
    191192
    192193      Results.AddOrUpdateResult("Best solution", CreateSolution((ISymbolicExpressionTree)state.BestTree.Clone(), problem.ProblemData));
    193       Results.AddOrUpdateResult("Best solution constraint values", new DoubleArray(state.BestConstraintValues));
     194      var bestConstraintValues = new DoubleArray(state.BestConstraintValues);
     195      bestConstraintValues.ElementNames = constraintDescriptions;
     196      Results.AddOrUpdateResult("Best solution constraint values", bestConstraintValues);
    194197
    195198
     
    215218      var model = new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeLinearInterpreter());
    216219      // model.Scale(problemData);
    217       return model.CreateRegressionSolution((IRegressionProblemData)problemData.Clone());
     220      // var sol = model.CreateRegressionSolution((IRegressionProblemData)problemData.Clone());
     221      // model.CreateRegressionSolution produces a new ProblemData and recalculates intervals
     222
     223      var sol = new SymbolicRegressionSolution(model, (IRegressionProblemData)problemData.Clone());
     224
     225      // ==> set variable ranges to same range as in original problemData
     226      // foreach(var interval in problemData.VariableRanges.GetIntervals()) {
     227      //   sol.ProblemData.VariableRanges.SetInterval
     228      // }
     229      return sol;
    218230    }
    219231  }
Note: See TracChangeset for help on using the changeset viewer.