Skip to content
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

QuadraticModels with unit range #71

Open
tmigot opened this issue Mar 11, 2022 · 2 comments
Open

QuadraticModels with unit range #71

tmigot opened this issue Mar 11, 2022 · 2 comments

Comments

@tmigot
Copy link
Member

tmigot commented Mar 11, 2022

The idea would be to define the rows and cols using UnitRange. I am wondering whether this would be a desirable feature or not, because it looks so natural.

julia> QuadraticModel(zeros(3), 1:3, 1:3, ones(3))
ERROR: MethodError: no method matching SparseMatricesCOO.SparseMatrixCOO(::Int64, ::Int64, ::UnitRange{Int64}, ::UnitRange{Int64}, ::Vector{Float64})
Closest candidates are:
  SparseMatricesCOO.SparseMatrixCOO(::Integer, ::Integer, ::Vector, ::Vector, ::Vector) at .julia\packages\SparseMatricesCOO\z5uST\src\coo_types.jl:51
Stacktrace:
 [1] QuadraticModel(c::Vector{Float64}, Hrows::UnitRange{Int64}, Hcols::UnitRange{Int64}, Hvals::Vector{Float64}; Arows::Vector{Int64}, Acols::Vector{Int64}, Avals::Vector{Float64}, lcon::Vector{Float64}, ucon::Vector{Float64}, lvar::Vector{Float64}, uvar::Vector{Float64}, c0::Float64, sortcols::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ QuadraticModels .julia\packages\QuadraticModels\etxWq\src\qpmodel.jl:123
 [2] QuadraticModel(c::Vector{Float64}, Hrows::UnitRange{Int64}, Hcols::UnitRange{Int64}, Hvals::Vector{Float64})
   @ QuadraticModels .julia\packages\QuadraticModels\etxWq\src\qpmodel.jl:97
 [3] top-level scope
   @ REPL[5]:1
``
@dpo
Copy link
Member

dpo commented Mar 11, 2022

It would be easy to achieve using collect(), but do you mean that the internal storage should also use UnitRange?

@tmigot
Copy link
Member Author

tmigot commented Mar 11, 2022

We would save some memory with UnitRange then.

But, a temporary solution could be to do a collect internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants