NLPModelsJuMP.jl
NLPModelsJuMP.jl copied to clipboard
Add support for quadratic constraints
It could be useful to treat separately quadratic and other nonlinear constraints. An open question is how to store all hessian of the quadratic constraints?
- List of 2D COO
- 3D COO for third order tensor (rows, cols, tubes, vals)
- ...
Maybe this should go to NLPModels?
Yes, maybe we should also move some functions like https://github.com/JuliaSmoothOptimizers/NLPModelsJuMP.jl/blob/master/src/utils.jl#L56-L73 in NLPModels.jl.
@abelsiqueira
Should we create a simple TripletMatrix?
Maybe a separate package with a COOSparseMatrix type that conforms to the Julia AbstractMatrix API.
Agreed
If we want to add support for quadratic constraints (https://github.com/amontoison/NLPModelsJuMP.jl/commit/378439fae5dcc164caf3fd6655a84b758f3e11d0), we need to:
- store all hessian of the quadratic constraints;
- compute
nnzjof the quadratic constraints; - separate quadratic and nonlinear constraints in NLPModels (
nlin,nquad,nln).
It could be a project for a student.
Simply to revitalize the debate. @amontoison Could we consider having a COO-triplet for the matrices of the quadratic constraints, and a vector that contains the number of non-zeros elements in each matrix? For instance,
# With 2 quadratic constraints with matrices Q1 = [1, 2; 3, 4] and Q2 = [5, 6; 7, 8], we would get :
I = [1, 1, 2, 2, 1, 1, 2, 2]
J = [1, 2, 1, 2, 1, 2, 1, 2]
V = [1, 2, 3, 4, 5, 6, 7, 8]
Qnnz = [4, 8]
Why would they be stored together? Also they're symmetric, so we'd only store one triangle.
Indeed, this is a good point that they are symmetric.
We could definitely have a list of I, J and V. This way we would avoid the Qnnz vector.
I have a structure that handle a quadratic objective : https://github.com/JuliaSmoothOptimizers/NLPModelsJuMP.jl/blob/main/src/utils.jl#L47-L53
I can reuse it like this :
mutable struct QuadraticConstraint
hessian::COO
b::SparseVector{Float64}
nnzh::Int
nnzb::Int
end
and add a Vector{QuadraticConstraint} inside the model.
That sounds good.