diff --git a/src/Numerics/Optimization/IObjectiveModel.cs b/src/Numerics/Optimization/IObjectiveModel.cs index 45f94409..72c15391 100644 --- a/src/Numerics/Optimization/IObjectiveModel.cs +++ b/src/Numerics/Optimization/IObjectiveModel.cs @@ -41,11 +41,11 @@ namespace MathNet.Numerics.Optimization /// /// Get the number of calls to function. /// - int FunctionEvaluations { get; } + int FunctionEvaluations { get; set; } /// /// Get the number of calls to jacobian. /// - int JacobianEvaluations { get; } + int JacobianEvaluations { get; set; } /// /// Get the degree of freedom. diff --git a/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs b/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs index 681eb3dd..2b54d194 100644 --- a/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs +++ b/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 diff --git a/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs b/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs index ce81fb54..6b9fba7c 100644 --- a/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs +++ b/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs @@ -125,11 +125,11 @@ namespace MathNet.Numerics.Optimization.ObjectiveModels /// /// Get the number of calls to function. /// - public int FunctionEvaluations { get; private set; } + public int FunctionEvaluations { get; set; } /// /// Get the number of calls to jacobian. /// - public int JacobianEvaluations { get; private set; } + public int JacobianEvaluations { get; set; } /// /// Set or get the desired accuracy order of the numerical jacobian. diff --git a/src/Numerics/Optimization/TrustRegionDogLegMinimizer.cs b/src/Numerics/Optimization/TrustRegionDogLegMinimizer.cs index a8ab570f..85d4fef0 100644 --- a/src/Numerics/Optimization/TrustRegionDogLegMinimizer.cs +++ b/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