Skip to content

Replace Nonlinear.ReverseAD.Coloring by SparseMatrixColorings - #3105

Open
blegat wants to merge 4 commits into
masterfrom
bl/smc
Open

blegat wants to merge 4 commits into
masterfrom
bl/smc

Conversation

@blegat

@blegat blegat commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Backport of blegat/ArrayDiff.jl#102

We can now easily use the star coloring 🎉

using JuMP, Ipopt
import MathOptInterface as MOI
import SparseMatrixColorings as SMC

model = Model(Ipopt.Optimizer)
set_silent(model)

# Direct decompression selects star coloring.
algorithm = SMC.GreedyColoringAlgorithm(; decompression = :direct)
set_attribute(
    model,
    MOI.AutomaticDifferentiationBackend(),
    MOI.Nonlinear.SparseReverseMode(algorithm),
)

@variable(model, x, start = -1.2)
@variable(model, y, start = 1.0)
@objective(model, Min, (1 - x)^2 + 100 * (y - x^2)^2)

optimize!(model)

@show termination_status(model)  # LOCALLY_SOLVED
@show value(x) value(y) objective_value(model) # (x, y) ≈ (1, 1), objective ≈ 1.52e-22.

Include workarounds for

We should wait for them to be merged and revisit before merging

Closes #2527
Closes #3104

@gdalle

gdalle commented Oct 16, 2026

Copy link
Copy Markdown

Any clue how this compares in terms of speed to the existing implementation (acyclic coloring, if memory serves?)?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Precision loss in Hessian computation [Nonlinear] sparsity pattern of Hessian with :(x * y)

2 participants