Skip to content

Commit

Permalink
Convert NLLS to OptpRob
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Nov 4, 2023
1 parent ffe68ae commit c838cf2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/problems/basic_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,14 @@ function OptimizationProblem(f, args...; kwargs...)
OptimizationProblem{true}(OptimizationFunction{true}(f), args...; kwargs...)
end

function OptimizationProblem(prob::NonlinearLeastSquaresProblem; kwargs...)
if isinplace(prob)
throw(ArgumentError("Converting NonlinearLeastSquaresProblem to OptimizationProblem is not supported with in-place functions yet."))

Check warning on line 693 in src/problems/basic_problems.jl

View check run for this annotation

Codecov / codecov/patch

src/problems/basic_problems.jl#L691-L693

Added lines #L691 - L693 were not covered by tests
end
optf = OptimizationFunction(sum prob.f, grad = (Jv, u, p) -> prob.f.jvp(Jv, prob.f(u, p), u, p), kwargs...)
return OptimizationProblem(optf, prob.u0, prob.p; prob.kwargs..., kwargs...)

Check warning on line 696 in src/problems/basic_problems.jl

View check run for this annotation

Codecov / codecov/patch

src/problems/basic_problems.jl#L695-L696

Added lines #L695 - L696 were not covered by tests
end

isinplace(f::OptimizationFunction{iip}) where {iip} = iip
isinplace(f::OptimizationProblem{iip}) where {iip} = iip

Expand Down

0 comments on commit c838cf2

Please sign in to comment.