Skip to content

Commit be9bfd1

Browse files
Merge pull request #134 from baggepinnen/patch-1
optimize lagrangian implementation in oop dispatch for autosparse backends
2 parents d1fdea1 + 2898867 commit be9bfd1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/OptimizationDISparseExt.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ function instantiate_function(
133133
end
134134

135135
function lagrangian(θ, σ, λ, p)
136-
return σ * f.f(θ, p) + dot(λ, cons_oop(θ))
136+
if eltype(θ) <: SparseConnectivityTracer.AbstractTracer || !iszero(θ)
137+
return σ * f.f(θ, p) + dot(λ, cons_oop(θ))
138+
else
139+
return dot(λ, cons_oop(θ))
140+
end
137141
end
138142
end
139143

0 commit comments

Comments
 (0)