Skip to content

Commit 5ce09a6

Browse files
Updated the alg trait checks solve.jl
Changed the OptimizationFunction part to AbstractOptimizationFunction and removed the '!' sign in the trait checks.
1 parent bb1a126 commit 5ce09a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/solve.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ function _check_opt_alg(prob::OptimizationProblem, alg; kwargs...)
116116
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires constraints, pass them with the `cons` kwarg in `OptimizationFunction`."))
117117
!allowscallback(alg) && haskey(kwargs, :callback) &&
118118
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) does not support callbacks, remove the `callback` keyword argument from the `solve` call."))
119-
!requiresgradient(alg) && !(prob.f isa OptimizationFunction) &&
119+
requiresgradient(alg) && !(prob.f isa AbstractOptimizationFunction) &&
120120
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires gradients, hence use `OptimizationFunction` to generate them with an automatic differentiation backend e.g. `OptimizationFunction(f, AutoForwardDiff())` or pass it in with `grad` kwarg."))
121-
!requireshessian(alg) && !(prob.f isa OptimizationFunction) &&
121+
requireshessian(alg) && !(prob.f isa AbstractOptimizationFunction) &&
122122
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires hessians, hence use `OptimizationFunction` to generate them with an automatic differentiation backend e.g. `OptimizationFunction(f, AutoFiniteDiff(); kwargs...)` or pass them in with `hess` kwarg."))
123-
!requiresconsjac(alg) && !(prob.f isa OptimizationFunction) &&
123+
requiresconsjac(alg) && !(prob.f isa AbstractOptimizationFunction) &&
124124
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires constraint jacobians, hence use `OptimizationFunction` to generate them with an automatic differentiation backend e.g. `OptimizationFunction(f, AutoFiniteDiff(); kwargs...)` or pass them in with `cons` kwarg."))
125-
!requiresconshess(alg) && !(prob.f isa OptimizationFunction) &&
125+
requiresconshess(alg) && !(prob.f isa AbstractOptimizationFunction) &&
126126
throw(IncompatibleOptimizerError("The algorithm $(typeof(alg)) requires constraint hessians, hence use `OptimizationFunction` to generate them with an automatic differentiation backend e.g. `OptimizationFunction(f, AutoFiniteDiff(), AutoFiniteDiff(hess=true); kwargs...)` or pass them in with `cons` kwarg."))
127127
return
128128
end

0 commit comments

Comments
 (0)