Skip to content

Commit 9291aea

Browse files
committed
remove NonlinearSolve things
1 parent da6e4c3 commit 9291aea

File tree

1 file changed

+2
-164
lines changed

1 file changed

+2
-164
lines changed

src/solve.jl

Lines changed: 2 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function init_call(_prob, args...; merge_callbacks = true, kwargshandle = nothin
3939
end
4040

4141
function init(
42-
prob::Union{AbstractDEProblem, NonlinearProblem}, args...; sensealg = nothing,
42+
prob::AbstractDEProblem, args...; sensealg = nothing,
4343
u0 = nothing, p = nothing, kwargs...)
4444
if sensealg === nothing && has_kwargs(prob) && haskey(prob.kwargs, :sensealg)
4545
sensealg = prob.kwargs[:sensealg]
@@ -215,41 +215,6 @@ function build_null_solution(prob::AbstractDEProblem, args...;
215215
build_solution(prob, nothing, ts, timeseries; dense = true, retcode)
216216
end
217217

218-
function build_null_solution(
219-
prob::Union{SteadyStateProblem, NonlinearProblem},
220-
args...;
221-
saveat = (),
222-
save_everystep = true,
223-
save_on = true,
224-
save_start = save_everystep || isempty(saveat) ||
225-
saveat isa Number || prob.tspan[1] in saveat,
226-
save_end = true,
227-
kwargs...)
228-
prob, success = hack_null_solution_init(prob)
229-
retcode = success ? ReturnCode.Success : ReturnCode.InitialFailure
230-
SciMLBase.build_solution(prob, nothing, Float64[], nothing; retcode)
231-
end
232-
233-
function build_null_solution(
234-
prob::NonlinearLeastSquaresProblem,
235-
args...; abstol = 1e-6, kwargs...)
236-
prob, success = hack_null_solution_init(prob)
237-
retcode = success ? ReturnCode.Success : ReturnCode.InitialFailure
238-
239-
if isinplace(prob)
240-
resid = isnothing(prob.f.resid_prototype) ? Float64[] : copy(prob.f.resid_prototype)
241-
prob.f(resid, prob.u0, prob.p)
242-
else
243-
resid = prob.f(prob.f.resid_prototype, prob.p)
244-
end
245-
246-
if success
247-
retcode = norm(resid) < abstol ? ReturnCode.Success : ReturnCode.Failure
248-
end
249-
250-
SciMLBase.build_solution(prob, nothing, Float64[], resid; retcode)
251-
end
252-
253218
"""
254219
```julia
255220
solve(prob::AbstractDEProblem, alg::Union{AbstractDEAlgorithm,Nothing}; kwargs...)
@@ -562,102 +527,7 @@ function solve(prob::AbstractDEProblem, args...; sensealg = nothing,
562527
end
563528
end
564529

565-
"""
566-
```julia
567-
solve(prob::NonlinearProblem, alg::Union{AbstractNonlinearAlgorithm,Nothing}; kwargs...)
568-
```
569-
570-
## Arguments
571-
572-
The only positional argument is `alg` which is optional. By default, `alg = nothing`.
573-
If `alg = nothing`, then `solve` dispatches to the NonlinearSolve.jl automated
574-
algorithm selection (if `using NonlinearSolve` was done, otherwise it will
575-
error with a `MethodError`).
576-
577-
## Keyword Arguments
578-
579-
The NonlinearSolve.jl universe has a large set of common arguments available
580-
for the `solve` function. These arguments apply to `solve` on any problem type and
581-
are only limited by limitations of the specific implementations.
582-
583-
Many of the defaults depend on the algorithm or the package the algorithm derives
584-
from. Not all of the interface is provided by every algorithm.
585-
For more detailed information on the defaults and the available options
586-
for specific algorithms / packages, see the manual pages for the solvers of specific
587-
problems.
588-
589-
#### Error Control
590-
591-
* `abstol`: Absolute tolerance.
592-
* `reltol`: Relative tolerance.
593-
594-
### Miscellaneous
595-
596-
* `maxiters`: Maximum number of iterations before stopping. Defaults to 1e5.
597-
* `verbose`: Toggles whether warnings are thrown when the solver exits early.
598-
Defaults to true.
599-
600-
### Sensitivity Algorithms (`sensealg`)
601-
602-
`sensealg` is used for choosing the way the automatic differentiation is performed.
603-
For more information, see the documentation for SciMLSensitivity:
604-
https://docs.sciml.ai/SciMLSensitivity/stable/
605-
"""
606-
function solve(prob::NonlinearProblem, args...; sensealg = nothing,
607-
u0 = nothing, p = nothing, wrap = Val(true), kwargs...)
608-
if sensealg === nothing && haskey(prob.kwargs, :sensealg)
609-
sensealg = prob.kwargs[:sensealg]
610-
end
611-
612-
if haskey(prob.kwargs, :alias_u0)
613-
@warn "The `alias_u0` keyword argument is deprecated. Please use a NonlinearAliasSpecifier, e.g. `alias = NonlinearAliasSpecifier(alias_u0 = true)`."
614-
alias_spec = NonlinearAliasSpecifier(alias_u0 = prob.kwargs[:alias_u0])
615-
elseif haskey(kwargs, :alias_u0)
616-
@warn "The `alias_u0` keyword argument is deprecated. Please use a NonlinearAliasSpecifier, e.g. `alias = NonlinearAliasSpecifier(alias_u0 = true)`."
617-
alias_spec = NonlinearAliasSpecifier(alias_u0 = kwargs[:alias_u0])
618-
end
619-
620-
if haskey(prob.kwargs, :alias) && prob.kwargs[:alias] isa Bool
621-
alias_spec = NonlinearAliasSpecifier(alias = prob.kwargs[:alias])
622-
elseif haskey(kwargs, :alias) && kwargs[:alias] isa Bool
623-
alias_spec = NonlinearAliasSpecifier(alias = kwargs[:alias])
624-
end
625-
626-
if haskey(prob.kwargs, :alias) && prob.kwargs[:alias] isa NonlinearAliasSpecifier
627-
alias_spec = prob.kwargs[:alias]
628-
elseif haskey(kwargs, :alias) && kwargs[:alias] isa NonlinearAliasSpecifier
629-
alias_spec = kwargs[:alias]
630-
else
631-
alias_spec = NonlinearAliasSpecifier(alias_u0 = false)
632-
end
633-
634-
alias_u0 = alias_spec.alias_u0
635-
636-
u0 = u0 !== nothing ? u0 : prob.u0
637-
p = p !== nothing ? p : prob.p
638-
639-
if wrap isa Val{true}
640-
wrap_sol(solve_up(prob,
641-
sensealg,
642-
u0,
643-
p,
644-
args...;
645-
alias_u0 = alias_u0,
646-
originator = set_mooncakeoriginator_if_mooncake(SciMLBase.ChainRulesOriginator()),
647-
kwargs...))
648-
else
649-
solve_up(prob,
650-
sensealg,
651-
u0,
652-
p,
653-
args...;
654-
alias_u0 = alias_u0,
655-
originator = set_mooncakeoriginator_if_mooncake(SciMLBase.ChainRulesOriginator()),
656-
kwargs...)
657-
end
658-
end
659-
660-
function solve_up(prob::Union{AbstractDEProblem, NonlinearProblem}, sensealg, u0, p,
530+
function solve_up(prob::AbstractDEProblem, sensealg, u0, p,
661531
args...; originator = SciMLBase.ChainRulesOriginator(),
662532
kwargs...)
663533
alg = extract_alg(args, kwargs, has_kwargs(prob) ? prob.kwargs : kwargs)
@@ -685,14 +555,6 @@ function solve_up(prob::Union{AbstractDEProblem, NonlinearProblem}, sensealg, u0
685555
end
686556
end
687557

688-
function solve_call(prob::SteadyStateProblem,
689-
alg::SciMLBase.AbstractNonlinearAlgorithm, args...;
690-
kwargs...)
691-
solve_call(NonlinearProblem(prob),
692-
alg, args...;
693-
kwargs...)
694-
end
695-
696558
function solve(prob::AbstractNoiseProblem, args...; kwargs...)
697559
__solve(prob, args...; kwargs...)
698560
end
@@ -717,30 +579,6 @@ function get_concrete_problem(prob::SteadyStateProblem, isadapt; kwargs...)
717579
remake(prob; u0 = u0, p = p)
718580
end
719581

720-
function get_concrete_problem(prob::NonlinearProblem, isadapt; kwargs...)
721-
oldprob = prob
722-
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
723-
if prob !== oldprob
724-
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
725-
end
726-
p = get_concrete_p(prob, kwargs)
727-
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
728-
u0 = promote_u0(u0, p, nothing)
729-
remake(prob; u0 = u0, p = p)
730-
end
731-
732-
function get_concrete_problem(prob::NonlinearLeastSquaresProblem, isadapt; kwargs...)
733-
oldprob = prob
734-
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
735-
if prob !== oldprob
736-
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
737-
end
738-
p = get_concrete_p(prob, kwargs)
739-
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
740-
u0 = promote_u0(u0, p, nothing)
741-
remake(prob; u0 = u0, p = p)
742-
end
743-
744582
function get_concrete_problem(prob::AbstractEnsembleProblem, isadapt; kwargs...)
745583
prob
746584
end

0 commit comments

Comments
 (0)