Jump.jl: Decision: how to map vectorized constraints to MOI

Created on 28 Jan 2018  路  4Comments  路  Source: jump-dev/JuMP.jl

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

decision

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 .== 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.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccoffrin picture ccoffrin  路  7Comments

Thuener picture Thuener  路  7Comments

IainNZ picture IainNZ  路  10Comments

dourouc05 picture dourouc05  路  7Comments

jd-lara picture jd-lara  路  5Comments