Skip to content

Commit

Permalink
Update solve.jl
Browse files Browse the repository at this point in the history
Added checks for requiresgradient, requireshessian, requiresconsjac, and requiresconshess in __check_opt_alg function.
  • Loading branch information
ParasPuneetSingh authored Mar 19, 2024
1 parent 9fbff32 commit 718def1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ function _check_opt_alg(prob::OptimizationProblem, alg; kwargs...)
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires constraints, pass them with the `cons` kwarg in `OptimizationFunction`."))
!allowscallback(alg) && haskey(kwargs, :callback) &&
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) does not support callbacks, remove the `callback` keyword argument from the `solve` call."))
!requiresgradient(alg) && !(alg::Type{OptimizationFunction}) &&

Check warning on line 119 in src/solve.jl

View check run for this annotation

Codecov / codecov/patch

src/solve.jl#L119

Added line #L119 was not covered by tests
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires gradients, pass them in `OptimizationFunction`."))
!requireshessian(alg) && !(alg::Type{OptimizationFunction}) &&

Check warning on line 121 in src/solve.jl

View check run for this annotation

Codecov / codecov/patch

src/solve.jl#L121

Added line #L121 was not covered by tests
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires hessians, pass them in `OptimizationFunction`."))
!requiresconsjac(alg) && !(alg::Type{OptimizationFunction}) &&

Check warning on line 123 in src/solve.jl

View check run for this annotation

Codecov / codecov/patch

src/solve.jl#L123

Added line #L123 was not covered by tests
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires constraint jacobian, pass them with the `cons` kwarg in `OptimizationFunction`."))
!requiresconshess(alg) && !(alg::Type{OptimizationFunction}) &&

Check warning on line 125 in src/solve.jl

View check run for this annotation

Codecov / codecov/patch

src/solve.jl#L125

Added line #L125 was not covered by tests
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires constraint hessian, pass them with the `cons` kwarg in `OptimizationFunction`."))
return
end

Expand Down

0 comments on commit 718def1

Please sign in to comment.