Should
@constraint(m, con, A*x .== b)
return a constraint ref to a VectorAffineFunction-in-Zeros constraint or a vector of constraint references to ScalarAffineFunction-in-EqualTo constraints?
This has various implications for deleting, modification, names (https://github.com/JuliaOpt/JuMP.jl/issues/1166) etc.
It feels more appropriate to return a single constraint ref to a VectorAffineFunction-in-Zeros constraint.
If you write a constraint in this form, you likely wouldn't want to delete individual rows, and if you're modifying b then you're likely modifying all of b at the same time anyway.
@odow @joaquimg @blegat
Return a single constraint ref. The less misdirection between JuMP and MOI the better
It's actually a bit problematic to return a single constraint ref, because it's inconsistent with some uses of the broadcast syntax. A .== B works when A and B are arbitrary (compatible) dimensions. We could flatten out the constraint to one dimension, but that would be surprising for the user. I think it makes more sense to return an array of constraint refs whose dimensions match what you would expect from the broadcast...
We still have @constraint(m, con, A*x - b in Zeros()) which obviously returns a single constraint ref.
I agree that we should minimize misdirection between JuMP and MOI. But in this case it might be better to be consistent with with broadcasting.
I am in favor of returning a vector of constraints. It also allows @constraint(m, con, l .<= x .<= u) since there is no vector set for intervals.
Most helpful comment
It's actually a bit problematic to return a single constraint ref, because it's inconsistent with some uses of the broadcast syntax.
A .== Bworks whenAandBare arbitrary (compatible) dimensions. We could flatten out the constraint to one dimension, but that would be surprising for the user. I think it makes more sense to return an array of constraint refs whose dimensions match what you would expect from the broadcast...We still have
@constraint(m, con, A*x - b in Zeros())which obviously returns a single constraint ref.