In the JuMP code below, I want to count the number of occurrences of each possible integer in the variable matrix M. s is defined to be a Kx1 variable vector equal to M[:]. Is there any difference in efficiency between
@constraint(model, [i=1:v-1], [n[i]; s] in MOI.CountBelongs(1+K, Set([i])))
versus
@constraint(model, [i=1:v-1], [n[i]; M[:]] in MOI.CountBelongs(1+K, Set([i])))
using JuMP
a = 4
b = 3
K = a*b
v = 16
model = Model()
@variable(model, 1 <= M[1:a,1:b] <= v-1, Int)
@variable(model, 1 <= s[1:K] <= v-1, Int)
@constraint(model, s .== M[:])
@variable(model, 0 <= n[1:v-1] <= K, Int)
n[i] is the count of how many i
are in s for 1 <= i <= v-1.
@constraint(model, [i=1:v-1], [n[i]; s] in MOI.CountBelongs(1+K, Set([i])))
vs
@constraint(model, [i=1:v-1], [n[i]; M[:]] in MOI.CountBelongs(1+K, Set([i])))