Browse Source

Added initialization step to ensure that the initialGuess is not internal parameters.

pull/614/head
diluculo 8 years ago
parent
commit
4bac95e481
  1. 4
      src/Numerics/Optimization/IObjectiveModel.cs
  2. 4
      src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs
  3. 4
      src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs
  4. 4
      src/Numerics/Optimization/TrustRegionDogLegMinimizer.cs

4
src/Numerics/Optimization/IObjectiveModel.cs

@ -41,11 +41,11 @@ namespace MathNet.Numerics.Optimization
/// <summary>
/// Get the number of calls to function.
/// </summary>
int FunctionEvaluations { get; }
int FunctionEvaluations { get; set; }
/// <summary>
/// Get the number of calls to jacobian.
/// </summary>
int JacobianEvaluations { get; }
int JacobianEvaluations { get; set; }
/// <summary>
/// Get the degree of freedom.

4
src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs

@ -120,6 +120,10 @@ namespace MathNet.Numerics.Optimization
ExitCondition exitCondition = ExitCondition.None;
// Initialize objective
objective.FunctionEvaluations = 0;
objective.JacobianEvaluations = 0;
// First, calculate function values and setup variables
objective.EvaluateFunction(initialGuess);
var P = objective.Parameters; // current parameters

4
src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs

@ -125,11 +125,11 @@ namespace MathNet.Numerics.Optimization.ObjectiveModels
/// <summary>
/// Get the number of calls to function.
/// </summary>
public int FunctionEvaluations { get; private set; }
public int FunctionEvaluations { get; set; }
/// <summary>
/// Get the number of calls to jacobian.
/// </summary>
public int JacobianEvaluations { get; private set; }
public int JacobianEvaluations { get; set; }
/// <summary>
/// Set or get the desired accuracy order of the numerical jacobian.

4
src/Numerics/Optimization/TrustRegionDogLegMinimizer.cs

@ -121,6 +121,10 @@ namespace MathNet.Numerics.Optimization
ExitCondition exitCondition = ExitCondition.None;
// Initialize objective
objective.FunctionEvaluations = 0;
objective.JacobianEvaluations = 0;
// First, calculate function values and setup variables
objective.EvaluateFunction(initialGuess);
var P = objective.Parameters; // current parameters

Loading…
Cancel
Save