From b6a1e3e65e6df4629522bc39046f25fef63116bd Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Tue, 3 Dec 2024 00:05:21 -0600 Subject: [PATCH] Update the function for the lagrangian --- src/enzyme.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/enzyme.jl b/src/enzyme.jl index 72e90ec6..5b032c81 100644 --- a/src/enzyme.jl +++ b/src/enzyme.jl @@ -216,8 +216,12 @@ function SparseEnzymeADHessian( cx = similar(x0, ncon) grad = similar(x0) function ℓ(x, y, obj_weight, cx) - c!(cx, x) - obj_weight * f(x) + sum(cx[i] * y[i] for i = 1:ncon) + res = obj_weight * f(x) + if ncon == 0 + c!(cx, x) + res += sum(cx[i] * y[i] for i = 1:ncon) + end + return res end return SparseEnzymeADHessian(