Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/10/22 10:15:25 (2 years ago)
Author:
dpiringe
Message:

#3138

  • merged trunk into branch
Location:
branches/3138_Shape_Constraints_Transformations
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3138_Shape_Constraints_Transformations

  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Algorithms.DataAnalysis

  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Algorithms.DataAnalysis/3.4

  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression/NonlinearRegression.cs

    r17180 r18180  
    123123      : base() {
    124124      Problem = new RegressionProblem();
    125       Parameters.Add(new FixedValueParameter<StringValue>(ModelStructureParameterName, "The function for which the parameters must be fit (only numeric constants are tuned).", new StringValue("1.0 * x*x + 0.0")));
    126       Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "The maximum number of iterations for constants optimization.", new IntValue(200)));
     125      Parameters.Add(new FixedValueParameter<StringValue>(ModelStructureParameterName,
     126        "The expression for which the <num> parameters should be fit.\n " +
     127        "Defined constants will not be modified.\n " +
     128        "Modifiable numbers are specified with <num>. To specify a default value within this number symbol, a default value can be declared by e.g. <num=1.0>.",
     129        new StringValue("<num> * x*x + 0.0")));
     130      Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "The maximum number of iterations for parameter optimization.", new IntValue(200)));
    127131      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of independent random restarts (>0)", new IntValue(10)));
    128132      Parameters.Add(new FixedValueParameter<IntValue>(SeedParameterName, "The PRNG seed value.", new IntValue()));
     
    210214
    211215    /// <summary>
    212     /// Fits a model to the data by optimizing the numeric constants.
     216    /// Fits a model to the data by optimizing parameters.
    213217    /// Model is specified as infix expression containing variable names and numbers.
    214     /// The starting point for the numeric constants is initialized randomly if a random number generator is specified (~N(0,1)). Otherwise the user specified constants are
     218    /// The starting values for the parameters are initialized randomly if a random number generator is specified (~N(0,1)). Otherwise the user specified values are
    215219    /// used as a starting point.
    216220    /// </summary>-
    217221    /// <param name="problemData">Training and test data</param>
    218222    /// <param name="modelStructure">The function as infix expression</param>
    219     /// <param name="maxIterations">Number of constant optimization iterations (using Levenberg-Marquardt algorithm)</param>
    220     /// <param name="random">Optional random number generator for random initialization of numeric constants.</param>
     223    /// <param name="maxIterations">Number of Levenberg-Marquardt iterations</param>
     224    /// <param name="random">Optional random number generator for random initialization of parameters.</param>
    221225    /// <returns></returns>
    222226    public static ISymbolicRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData, string modelStructure, int maxIterations, bool applyLinearScaling, IRandom rand = null) {
     
    263267      }
    264268
    265       if (!SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(tree)) throw new ArgumentException("The optimizer does not support the specified model structure.");
    266 
    267       // initialize constants randomly
     269      if (!SymbolicRegressionParameterOptimizationEvaluator.CanOptimizeParameters(tree)) throw new ArgumentException("The optimizer does not support the specified model structure.");
     270
     271      // initialize parameters randomly
    268272      if (rand != null) {
    269         foreach (var node in tree.IterateNodesPrefix().OfType<ConstantTreeNode>()) {
     273        foreach (var node in tree.IterateNodesPrefix().OfType<NumberTreeNode>()) {
    270274          double f = Math.Exp(NormalDistributedRandom.NextDouble(rand, 0, 1));
    271275          double s = rand.NextDouble() < 0.5 ? -1 : 1;
     
    275279      var interpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
    276280
    277       SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, problemData.TrainingIndices,
     281      SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, problemData.TrainingIndices,
    278282        applyLinearScaling: applyLinearScaling, maxIterations: maxIterations,
    279         updateVariableWeights: false, updateConstantsInTree: true);
     283        updateVariableWeights: false, updateParametersInTree: true);
    280284
    281285      var model = new SymbolicRegressionModel(problemData.TargetVariable, tree, (ISymbolicDataAnalysisExpressionTreeInterpreter)interpreter.Clone());
Note: See TracChangeset for help on using the changeset viewer.