I am looking to be able to declare a vector of integer variables and restrain them to 1, 2, 3 … some finite number of non sequential integers. Should I create some roundabout lookup table to interpret sequential integers? (this is very similar to Bin, except with a configurable set)
x to take one of the values in
y, a naive approach is as follows:
using JuMP model = Model() @variable(model, x) y = [2, 3, 5, 7, 11] N = length(y) @variable(model, z[1:N], Bin) @constraint(model, x == sum(y[i] * z[i] for i in 1:N)) @constraint(model, sum(z) == 1)
Yeah, this is sorta what I was referring to with the “roundabout lookup table” type idea, with the additional benefit that the values of x are easily interpretable.
I tried it out and I think this makes sense, thanks!