Closed tmigot closed 2 years ago
Can you give me your problem so that I can reproduce the error?
using QuadraticModels, RipQP
qp = QuadraticModel(zeros(2), zeros(2,2), lvar = zeros(2), uvar = zeros(2))
ripqp(qp)
https://github.com/JuliaSmoothOptimizers/NLPModels.jl/blob/94e14baa2cc8584eef2eeb6190b75fdecb7d4458/src/nlp/meta.jl#L120
The presolved problem has a size 0. Maybe we should be able create NLPModelsMeta
with nvar = 0
?
Oh, I see. It would make sense to replace nvar < 1
by nvar < 0
. Can you open a PR for this?
It's a bit weird to create a problem with 0 variables. Could you show the original problem?
The origin problem comes from adapting https://github.com/JuliaSmoothOptimizers/SolverTest.jl/pull/26 to QuadraticModels
After discussion, the solution is to let presolve
detect this case.
How? It is not an error if the presolved model has 0 variables but I don't know what should be the output in this case.
Please just use a different problem that isn't solved by presolve.
I'm not sure I understand. Should we tell the user that he should not try to solve this problem since the presolve solved it with an error message? In any case, I don't see the drawbacks of creating QuadraticModels with 0 variables, since in julia it's possible to create empty Arrays without getting error messages. This will allow codes to be more generic, since if you're solving QuadraticModels in an automated way you don't want to check whether each presolved QuadraticModel has 1 or more variables.
Without modifying NLPModels we can do 2 things:
presolve
https://github.com/JuliaSmoothOptimizers/QuadraticModels.jl/blob/b44a7069fd77bcd171d05655834d591a81bbde7c/src/presolve/presolve.jl#L30 check that all the variables are fixed and return the initial nlp
with a warning.ripqp
, we can detect that all the variables are fixed and return the solution.@geoffroyleconte what do you think?
In the future, if I add more operations to the presolve
function, I could be possible that a problem that has initialy not all of its variables fixed became a problem with all its variables fixed after the presolve. That's why I prefer create a model with 0 variables.
@geoffroyleconte @dpo Is this issue really closed? I believe we also need the RipQP
update as I now have:
MethodError: no method matching allocate_workspace(::GenericExecutionStats{Float64, Vector{Float64}}, ::RipQP.InputConfig{Int64}, ::RipQP.InputTol{Float64, Int64}, ::Float64, ::Type{Float64})
Closest candidates are:
allocate_workspace(::QuadraticModels.AbstractQuadraticModel, ::RipQP.InputConfig, ::RipQP.InputTol, ::Any, ::DataType) at ~/.julia/packages/RipQP/6e6d0/src/data_initialization.jl:120
Yes I have not changed RipQP yet, I'll try to do it today.
I've made the changes, waiting for https://github.com/JuliaSmoothOptimizers/QuadraticModels.jl/pull/74 to open a PR in RipQP.
This should be fixed with https://github.com/JuliaSmoothOptimizers/RipQP.jl/pull/175.
I changed the output stats so that the output status is :first_order
when the problem is solved, so I'm making a new major release (0.3).
I have a NLPModelMeta of this form:
but
ripqp
calls the functionpresolve
from this package and returns