Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Mar 27, 2024
1 parent 28a4d8e commit 534d43a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/lbfgsb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Optimization.SciMLBase, LBFGSB
"""
$(TYPEDEF)
L-BFGS-B Nonlinear Optimization Code from [LBFGSB](https://github.com/Gnimuc/LBFGSB.jl/tree/master).
[L-BFGS-B](https://en.wikipedia.org/wiki/Limited-memory_BFGS#L-BFGS-B) Nonlinear Optimization Code from [LBFGSB](https://github.com/Gnimuc/LBFGSB.jl/tree/master).
It is a quasi-Newton optimization algorithm that supports bounds.
References
Expand All @@ -13,7 +13,7 @@ References
- J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound constrained optimization (2011), to appear in ACM Transactions on Mathematical Software.
"""
@kwdef struct LBFGS
m::Int=10
m::Int = 10
end

SciMLBase.supports_opt_cache_interface(::LBFGS) = true
Expand Down Expand Up @@ -85,7 +85,6 @@ function SciMLBase.__solve(cache::OptimizationCache{
t1 = time()
stats = Optimization.OptimizationStats(; iterations = maxiters,
time = t1 - t0, fevals = maxiters, gevals = maxiters)

return SciMLBase.build_solution(cache, cache.opt, res[2], res[1], stats = stats)
end

4 changes: 2 additions & 2 deletions test/lbfgsb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ optf = OptimizationFunction(rosenbrock, AutoForwardDiff())
prob = OptimizationProblem(optf, x0)
res = solve(prob, Optimization.LBFGS(), maxiters = 100)

@test res.u [1.0, 1.0] atol=1e-3
@test res.u[1.0, 1.0] atol=1e-3

optf = OptimizationFunction(rosenbrock, AutoZygote())
prob = OptimizationProblem(optf, x0, lb = [0.0, 0.0], ub = [0.3, 0.3])
res = solve(prob, Optimization.LBFGS(), maxiters = 100)

@test res.u [0.3, 0.09] atol=1e-3
@test res.u[0.3, 0.09] atol=1e-3

0 comments on commit 534d43a

Please sign in to comment.