Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/25/19 10:30:24 (5 years ago)
Author:
chaider
Message:

#2971 Added derivates of intervals as result collection to solution view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs

    r15583 r16556  
    1 #region License Information
     1#region License Information
    22/* HeuristicLab
    33 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using HeuristicLab.Common;
     
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.DataAnalysis.Implementation;
    2931
    3032namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    4749    private const string TestNaNEvaluationsResultName = "Test NaN Evaluations";
    4850
     51    private const string EstimatedDerivatesResultName = "Derivates of the Model";
     52    private const string EstimatedDerivationInterval = "Interval";
     53
    4954    public new ISymbolicRegressionModel Model {
    5055      get { return (ISymbolicRegressionModel)base.Model; }
     
    95100      private set { ((IntValue)EstimationLimitsResultCollection[TestNaNEvaluationsResultName].Value).Value = value; }
    96101    }
     102
     103    private ResultCollection EstimatedDerivateResultCollection =>
     104      (ResultCollection) this[EstimatedDerivatesResultName].Value;
     105
     106    public NamedIntervals EstimationInterval =>
     107      (NamedIntervals) EstimatedDerivateResultCollection[EstimatedDerivationInterval].Value;
     108
    97109
    98110    [StorableConstructor]
     
    119131      Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults));
    120132      RecalculateResults();
     133
     134      var estimationDerivatesResult = new ResultCollection();
     135      Add(new Result(EstimatedDerivatesResultName, "Results concerning the derivation of symbolic regression solution", estimationDerivatesResult));
     136      CalculateDerivates(estimationDerivatesResult);
    121137    }
    122138
     
    138154        Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults));
    139155        CalculateResults();
     156
     157        var estimationDerivatesResult = new ResultCollection();
     158        Add(new Result(EstimatedDerivatesResultName, "Results concerning the derivation of symbolic regression solution", estimationDerivatesResult));
     159        CalculateDerivates(estimationDerivatesResult);
    140160      }
    141161    }
     
    146166    }
    147167
     168    private void CalculateDerivates(ResultCollection estimationDerivatesResults) {
     169      var interpreter = new IntervalInterpreter();
     170      var variableRanges = (ProblemData as RegressionProblemData).VariableRangesParameter.Value.VariableIntervals;
     171      var customIntervals = new Dictionary<string, Interval>();
     172      var intervals = new NamedIntervals();
     173
     174      foreach (var variable in variableRanges) {
     175        customIntervals.Add(variable.Key, new Interval(variable.Value.LowerBound, variable.Value.UpperBound));
     176      }
     177
     178      foreach (var derivate in customIntervals) {
     179        if (derivate.Key != ProblemData.TargetVariable) {
     180          var derived = DerivativeCalculator.Derive(Model.SymbolicExpressionTree, derivate.Key);
     181          var derivedResultInterval = interpreter.GetSymbolicExressionTreeInterval(derived, customIntervals);
     182          intervals.Add(" ∂f/∂" + derivate.Key,
     183            new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound));
     184        }
     185      }
     186      estimationDerivatesResults.AddOrUpdateResult("Derived Intervals", intervals);
     187
     188    }
     189   
    148190    private void CalculateResults() {
    149191      ModelLength = Model.SymbolicExpressionTree.Length;
Note: See TracChangeset for help on using the changeset viewer.