Skip to content

Commit

Permalink
lsqfit
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Nov 7, 2023
1 parent 250cd28 commit 3b53612
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/MadsCalibrate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function calibraterandom(madsdata::AbstractDict, numberofsamples::Integer=1; tol
end
parameters, results = Mads.calibrate(madsdata; tolX=tolX, tolG=tolG, tolOF=tolOF, tolOFcount=tolOFcount, minOF=minOF, maxEval=maxEval, maxIter=maxIter, maxJacobians=maxJacobians, lambda=lambda, lambda_mu=lambda_mu, np_lambda=np_lambda, show_trace=show_trace, usenaive=usenaive, save_results=save_results)
phi = results.minimum
converged = results.x_converged | results.g_converged | results.f_converged # f_converged => of_conferged
converged = results.x_converged | results.g_converged # f_converged => of_conferged
!quiet && @info("Random initial guess #$(i): OF = $(phi) (converged=$(converged))")
if phi < bestphi || i == 1
bestparameters = parameters
Expand Down Expand Up @@ -135,7 +135,7 @@ function calibraterandom_parallel(madsdata::AbstractDict, numberofsamples::Integ
end
parameters, results = Mads.calibrate(madsdata; tolX=tolX, tolG=tolG, tolOF=tolOF, tolOFcount=tolOFcount, minOF=minOF, maxEval=maxEval, maxIter=maxIter, maxJacobians=maxJacobians, lambda=lambda, lambda_mu=lambda_mu, np_lambda=np_lambda, show_trace=show_trace, usenaive=usenaive, save_results=save_results, localsa=localsa, parallel_optimization=false)
phi = results.minimum
converged = results.x_converged | results.g_converged | results.f_converged # f_converged => of_conferged
converged = results.x_converged | results.g_converged # f_converged => of_conferged
if !quiet
if i == 1 && first_init
@info("First run using initial values #$(i): OF = $(phi) (converged=$(converged))")
Expand Down
5 changes: 2 additions & 3 deletions src/MadsLevenbergMarquardt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ function naive_levenberg_marquardt(f::Function, g::Function, x0::AbstractVector{
break
end
end
LsqFit.LMResults(LsqFit.LevenbergMarquardt, x0, best_x, best_residual, g_calls, !converged, x_converged, g_converged, float(tolG), tr, f_calls, g_calls)
return LsqFit.LMResults(LsqFit.LevenbergMarquardt(), x0, currentx, currentsse, maxIter, true, true, true, 0.0, LsqFit.LMTrace{LsqFit.LevenbergMarquardt}(), nEval, maxIter)
end

Expand Down Expand Up @@ -386,7 +385,7 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x)
tr = LsqFit.LMTrace{LsqFit.LevenbergMarquardt}()
if show_trace
d = Dict("lambda" => lambda)
os = LsqFit.LMTrace{LsqFit.LevenbergMarquardt}(g_calls, best_residual, NaN, d)
os = LsqFit.LMState{LsqFit.LevenbergMarquardt}(g_calls, best_residual, NaN, d)
push!(tr, os)
println(os)
end
Expand Down Expand Up @@ -618,5 +617,5 @@ function levenberg_marquardt(f::Function, g::Function, x0, o::Function=x->(x'*x)
println("OF: $(best_residual) (final)")
end
callbackfinal(best_x, best_residual, NaN)
LsqFit.LMResults(LsqFit.LevenbergMarquardt, x0, best_x, best_residual, g_calls, !converged, x_converged, g_converged, float(tolG), tr, f_calls, g_calls)
LsqFit.LMResults(LsqFit.LevenbergMarquardt(), x0, best_x, best_residual, g_calls, !converged, x_converged, g_converged, float(tolG), tr, f_calls, g_calls)
end

0 comments on commit 3b53612

Please sign in to comment.