I have a quadratic program, and was trying to list all the constraints. However, all_constraints, wouldn’t list any of the constraints of type GenericQuadExpr. Below is a small example exhibiting the problem.
The output is Any[x[2] >= 3.0, x[1] >= 0.0, x[2] >= 0.0]
However, if I run:
println(list_of_constraint_types(m))
The output is [(GenericAffExpr{Float64,VariableRef}, MathOptInterface.GreaterThan{Float64}), (GenericQuadExpr{Float64,VariableRef}, MathOptInterface.GreaterThan{Float64}), (VariableRef, MathOptInterface.GreaterThan{Float64})]
What version of JuMP are you on? The signature all_constraints(m) does not exist in the reference (I can’t find it anyway…).
To your point, though, yes I think that is the intended use of the all_constraints + list_of_constraint_types functions. If you want to print all of the constraints, you can do something like:
for T in list_of_constraint_types(m)
cs = all_constraints(m, T...)
println(T)
println.("\t", cs)
end
I had found that documentation, which is how I am now am using all_constraints. However, I must have inferred the single argument usage from the way all_variables(m) works.
I guess my concern is that all_constraints(m) works without any warning or error (I’ve looked at the code, and I’m not sure how that is the case, since the other two arguments aren’t optional).
I think that either all_variables(m) shouldn’t work at all (throwing an error), or it should enumerate all constraint types.
julia> all_constraints(model)
ERROR: MethodError: no method matching all_constraints(::Model)
Closest candidates are:
all_constraints(::Model, ::Type{#s94} where #s94<:Union{AbstractJuMPScalar, Array{#s93,1} where #s93<:AbstractJuMPScalar}, ::Type{#s92} where #s92<:MathOptInterface.AbstractSet) at /Users/oscar/.julia/packages/JuMP/YXK4e/src/constraints.jl:852
Stacktrace:
[1] top-level scope at REPL[230]:100
What does it return if it doesn’t throw an error? Do you have a reproducible example? What is the output of ] status?