Skip to content

Commit

Permalink
vjp jvp eval function fix returns
Browse files Browse the repository at this point in the history
  • Loading branch information
aml5600 committed Oct 21, 2024
1 parent f6dd24d commit e9cfdeb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/OptimizationMOI/src/nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,13 @@ function MOI.eval_constraint_jacobian_product(
evaluator::MOIOptimizationNLPEvaluator, y, x, w)
if evaluator.f.cons_jvp !== nothing
evaluator.f.cons_jvp(y, x, w)

elseif evaluator.f.cons_j !== nothing
J = evaluator.J
evaluator.f.cons_j(J, x)
mul!(y, J, w)
return
else
error("Thou shalt provide the v'J of the constraint jacobian, not doing so is associated with great misfortune and also no ice cream for you.")
end
error("Thou shalt provide the v'J of the constraint jacobian, not doing so is associated with great misfortune and also no ice cream for you.")
end

function MOI.eval_constraint_jacobian_transpose_product(
Expand All @@ -320,14 +319,13 @@ function MOI.eval_constraint_jacobian_transpose_product(
)
if evaluator.f.cons_vjp !== nothing
evaluator.f.cons_vjp(y, x, w)

elseif evaluator.f.cons_j !== nothing
J = evaluator.J
evaluator.f.cons_j(J, x)
mul!(y, J', w)
return
else
error("Thou shalt provide the v'J of the constraint jacobian, not doing so is associated with great misfortune and also no ice cream for you.")
end
error("Thou shalt provide the v'J of the constraint jacobian, not doing so is associated with great misfortune and also no ice cream for you.")
end

function MOI.hessian_lagrangian_structure(evaluator::MOIOptimizationNLPEvaluator)
Expand Down

0 comments on commit e9cfdeb

Please sign in to comment.