Skip to content

Expensive jac_structure! #511

@amontoison

Description

@amontoison

Because of the linear API, the cost of the function jac_structure! is now prohibitive for large scale problems.
If we have as much linear constraints as nonlinear constraints, we need 2 * (ncon / 2)^2 comparisons (hidden in the calls to count).

NLPModels.jl/src/nlp/api.jl

Lines 192 to 221 in ac1213a

function jac_structure!(
nlp::AbstractNLPModel,
rows::AbstractVector{T},
cols::AbstractVector{T},
) where {T}
@lencheck nlp.meta.nnzj rows cols
lin_ind = 1:(nlp.meta.lin_nnzj)
if nlp.meta.nlin > 0
if nlp.meta.nnln == 0
jac_lin_structure!(nlp, rows, cols)
else
jac_lin_structure!(nlp, view(rows, lin_ind), view(cols, lin_ind))
for i in lin_ind
rows[i] += count(x < nlp.meta.lin[rows[i]] for x in nlp.meta.nln)
end
end
end
if nlp.meta.nnln > 0
if nlp.meta.nlin == 0
jac_nln_structure!(nlp, rows, cols)
else
nln_ind = (nlp.meta.lin_nnzj + 1):(nlp.meta.lin_nnzj + nlp.meta.nln_nnzj)
jac_nln_structure!(nlp, view(rows, nln_ind), view(cols, nln_ind))
for i in nln_ind
rows[i] += count(x < nlp.meta.nln[rows[i]] for x in nlp.meta.lin)
end
end
end
return rows, cols
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions