Skip to content

Commit

Permalink
increase size en improve pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
tmigot committed Dec 22, 2023
1 parent 49c5c7e commit 510f8e4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions docs/src/sparsepattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ using OptimizationProblems
using Symbolics
using SparseArrays
n = 1000
n = 1000000
@elapsed begin
nlp = OptimizationProblems.ADNLPProblems.controlinvestment(n = n, hessian_backend = ADNLPModels.EmptyADbackend)
end
```

After adding the package `Symbolics.jl`, the `ADNLPModel` will automatically try to prepare AD-backend to compute sparse Jacobian and Hessian.
Expand All @@ -47,16 +48,19 @@ using OptimizationProblems
using Symbolics
using SparseArrays
n = 1000
n = 1000000
N = div(n, 2)
function ADNLPModels.compute_jacobian_sparsity(c!, cx, x0; n = n, N = N)
# S = Symbolics.jacobian_sparsity(c!, cx, x0)
# return S
return hcat(
spdiagm(0 => ones(Bool, N - 1), 1 => ones(Bool, N - 1)),
spdiagm(0 => ones(Bool, N - 1), 1 => ones(Bool, N - 1)),
)[1:(N - 1),:]
# S = Symbolics.jacobian_sparsity(c!, cx, x0)
S = spzeros(Bool, N - 1, n)
for i =1:(N - 1)
S[i, i] = true
S[i, i + 1] = true
S[i, N + i] = true
S[i, N + i + 1] = true
end
return S
end
@elapsed begin
Expand Down

0 comments on commit 510f8e4

Please sign in to comment.