NLPModelsJuMP.jl icon indicating copy to clipboard operation
NLPModelsJuMP.jl copied to clipboard

Add support for quadratic constraints

Open amontoison opened this issue 5 years ago • 12 comments
trafficstars

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)
  • ...

amontoison avatar Apr 13 '20 18:04 amontoison

Maybe this should go to NLPModels?

dpo avatar Apr 13 '20 20:04 dpo

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.

amontoison avatar Apr 13 '20 21:04 amontoison

@abelsiqueira

amontoison avatar May 01 '20 15:05 amontoison

Should we create a simple TripletMatrix?

abelsiqueira avatar May 01 '20 15:05 abelsiqueira

Maybe a separate package with a COOSparseMatrix type that conforms to the Julia AbstractMatrix API.

dpo avatar May 01 '20 16:05 dpo

Agreed

abelsiqueira avatar May 01 '20 16:05 abelsiqueira

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 nnzj of the quadratic constraints;
  • separate quadratic and nonlinear constraints in NLPModels (nlin, nquad, nln).

It could be a project for a student.

amontoison avatar Dec 20 '20 18:12 amontoison

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]

tmigot avatar Sep 29 '21 15:09 tmigot

Why would they be stored together? Also they're symmetric, so we'd only store one triangle.

dpo avatar Sep 29 '21 15:09 dpo

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.

tmigot avatar Sep 29 '21 15:09 tmigot

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.

amontoison avatar Sep 29 '21 15:09 amontoison

That sounds good.

dpo avatar Sep 29 '21 16:09 dpo