Computing Hessian of the Langrangian efficiently with DI.jl

Yes it does work here, but if you had a slightly more sneaky function, like

f(x, mu) = sum(iszero(mui) ? 0 : xi for (xi, mui) in zip(x, mu))

then the zeros in your preparation vector typical_mu would deceive sparsity detection.

Ideally SCT would trace through every Constant context provided, but for arbitrarily complex objects that is not possible. So instead we keep these constants fixed during sparsity detection. This means that, as a rule, you should probably choose a typical_mu that is rather generic, like rand(n), instead of very specific like zeros(n).

That’s probably something I should stress in the DI docs

1 Like