JuliaSmoothOptimizers / RipQP.jl

MIT License
29 stars 5 forks source link

Solve unconstrained problems #167

Closed tmigot closed 2 years ago

tmigot commented 2 years ago

I tried using ripqp for an unconstrained quadratic problem, and it returns an error in the scaling I believe. For instance,

g = ones(3)
Hrows = [1, 2, 3]
Hcols = [1, 2, 3]
Hvals = zeros(3)
using QuadraticModels
nlp = QuadraticModel(g, Hrows, Hcols, Hvals)
using RipQP
ripqp(nlp)

returns

ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
  [1] _empty_reduce_error()
    @ Base ./reduce.jl:301
  [2] reduce_empty(op::Function, #unused#::Type{Float64})
    @ Base ./reduce.jl:311
  [3] mapreduce_empty(#unused#::typeof(identity), op::Function, T::Type)
    @ Base ./reduce.jl:345
  [4] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, #unused#::Type{Float64})
    @ Base ./reduce.jl:331
  [5] reduce_empty_iter
    @ ./reduce.jl:357 [inlined]
  [6] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Float64}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:353
  [7] _mapreduce(f::typeof(identity), op::typeof(max), #unused#::IndexLinear, A::Vector{Float64})
    @ Base ./reduce.jl:402
  [8] _mapreduce_dim
    @ ./reducedim.jl:330 [inlined]
  [9] #mapreduce#725
    @ ./reducedim.jl:322 [inlined]
 [10] mapreduce
    @ ./reducedim.jl:322 [inlined]
 [11] #_maximum#743
    @ ./reducedim.jl:894 [inlined]
 [12] _maximum
    @ ./reducedim.jl:894 [inlined]
 [13] #_maximum#742
    @ ./reducedim.jl:893 [inlined]
 [14] _maximum
    @ ./reducedim.jl:893 [inlined]
 [15] #maximum#740
    @ ./reducedim.jl:889 [inlined]
 [16] maximum
    @ ./reducedim.jl:889 [inlined]
 [17] scaling_Ruiz!(fd_T0::RipQP.QM_FloatData{Float64, Vector{Float64}, LinearAlgebra.Symmetric{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}, SparseArrays.SparseMatrixCSC{Float64, Int64}}, id::RipQP.QM_IntData, sd::RipQP.ScaleData{Float64, Vector{Float64}}, ϵ::Float64; max_iter::Int64)
    @ RipQP ~/.julia/packages/RipQP/M6f8t/src/scaling.jl:117
 [18] scaling_Ruiz!
    @ ~/.julia/packages/RipQP/M6f8t/src/scaling.jl:68 [inlined]
 [19] ripqp(QM0::QuadraticModel{Float64, Vector{Float64}, SparseMatricesCOO.SparseMatrixCOO{Float64, Int64}, SparseMatricesCOO.SparseMatrixCOO{Float64, Int64}}; iconf::InputConfig{Int64}, itol::InputTol{Float64, Int64}, display::Bool)
    @ RipQP ~/.julia/packages/RipQP/M6f8t/src/RipQP.jl:72
 [20] ripqp(QM0::QuadraticModel{Float64, Vector{Float64}, SparseMatricesCOO.SparseMatrixCOO{Float64, Int64}, SparseMatricesCOO.SparseMatrixCOO{Float64, Int64}})
    @ RipQP ~/.julia/packages/RipQP/M6f8t/src/RipQP.jl:56
geoffroyleconte commented 2 years ago

I'll fix the error, but I don't think your problem will have a solution. It is linear without constraints so the optimal solution is -Inf. I will open an issue to detect unbounded problems, this is currently not supported.

tmigot commented 2 years ago

You are right, my example wasn't great, but the same goes if Hvals = ones(3) which has a solution.