-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract / alternative linear operator storage #863
Comments
Do you know a solver which could take advantage of knowing the matrix structure ? |
When Hypatia is released, I will chime in here. Not quite ready to yet. |
From the Gurobi doc:
With this example in R: Where the matrix is passed to the model, instead of constructing row by row |
Is Gurobi actually using this matrix or is it just transforming it and for the algorithm it won't change anything whether you give this matrix or a VectorAffineFunction ? Is it just to gain model generation time or also solve time ? |
Not sure there is a way to know, I would say model generation time only. |
Tulip can. Actually, knowing the matrix structure is the main reason for having coded Tulip in the first place :)
I'm only 99.99% sure it would affect model generation time only, not solve time. |
Another point where this can affect performance is callbacks, if constraints defined in callbacks require moving around more data, it affects solving time. |
I wanted to get back to this issue and start thinking of possible solutions. Pinging @chriscoey now that Hypatia is released. Many solvers will take a pointer to an array of coefficients and a pointer to variable indices, in this form: or something close. This means that there will systematically be an unpacking of values into two arrays, from the one-array-of-struct current SAF model. If users provide the constraint in a form SAF may be a better design for some operations, but at least having the capacity for solvers to specify that they take affine constraints in the pair-of-array form and not array-of-struct could make MOI closer to them. Bridges from one form to the other should be doable |
An alternative to bridges would be to always use an interface when interacting with abstract linear operators, and both SAF and the pair-of-array type implementing this interface |
Relatedly, Convex.jl uses a lot of extended formulations which are similar to bridges in many ways, and I experimented with a bunch of "vector affine function" representations in jump-dev/Convex.jl#393. Looking at that PR, the one I liked best was struct SparseAffineOperation2{T}
matrix::SparseMatrixCSC{T}
vector::Vector{T}
end
struct SparseVAFTape2{T}
operations::Vector{SparseAffineOperation2{T}}
variables::Vector{MOI.VariableIndex}
end where |
There are some related points in #525 |
I propose closing this in favor of #2180. I don't see us changing this anytime soon, and the complexity of adding a new function type to MOI makes me not want to try this. |
We actually have these implemented in DiffOpt: https://github.com/jump-dev/DiffOpt.jl/blob/master/src/utils.jl |
Sure, but making them a first-class part of MOI and JuMP is a lot more work. And I don't really want more functions that solvers can opt-into with a bridge between them. |
This is an item in #2180, so I think we can close this issue. I don't see us making progress anytime soon. It would be far too disruptive (even though it would be beneficial). I'll give this a few days and then close. If anyone disagrees, please comment and we can discuss further. (Or re-open it if you're reading this from the far future.) |
Sorry, @matbesancon, yet another issue closed without resolution. At least this one doesn't have >100 comments... |
another addition to the List:tm: |
The current way of representing
A x
is with aVectorAffineFunction
, which has the following structure:This has a lot of nested structure and imposes a fixed concrete layout:
VectorAffineTerm
, then fromVAT
to the solver.Could we have an abstract linear operator function,
VectorLinearOperator
, with possibly a bridge toVectorAffineTerm
to avoid excessive burden on solvers.It would let solvers query the information as they want,
rows(vector_linear.A)
orcols(vector_linear.A)
or through scalarvector_linear.A[i, j]
The text was updated successfully, but these errors were encountered: