Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 13:25:30 (5 years ago)
Author:
mkommend
Message:

#2844: Merged r16798 into stable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r15584 r17057  
    4646    protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicExpressionTree tree, IProgress progress) {
    4747      const int constOptIterations = 50;
     48      const int maxRepetitions = 1000;
    4849      var regressionProblemData = Content.ProblemData;
    4950      var model = Content.Model;
    50       SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, tree, regressionProblemData, regressionProblemData.TrainingIndices,
    51         applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit,
    52         iterationCallback: (args, func, obj) => {
    53           double newProgressValue = progress.ProgressValue + 1.0 / (constOptIterations + 2); // (maxIterations + 2) iterations are reported
    54           progress.ProgressValue = Math.Min(newProgressValue, 1.0);
    55         });
     51      progress.CanBeStopped = true;
     52      var prevResult = 0.0;
     53      var result = 0.0;
     54      int reps = 0;
     55
     56      do {
     57        prevResult = result;
     58        result = SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, tree, regressionProblemData, regressionProblemData.TrainingIndices,
     59          applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit,
     60          iterationCallback: (args, func, obj) => {
     61            double newProgressValue = progress.ProgressValue + 1.0 / (constOptIterations + 2); // (maxIterations + 2) iterations are reported
     62            progress.ProgressValue = Math.Min(newProgressValue, 1.0);
     63          });
     64        reps++;
     65      } while (prevResult < result && reps < maxRepetitions &&
     66               progress.ProgressState != ProgressState.StopRequested &&
     67               progress.ProgressState != ProgressState.CancelRequested);
    5668      return tree;
    5769    }
Note: See TracChangeset for help on using the changeset viewer.