-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for obtaining the active domain of an variable #229
Comments
I currently lack of an example when this will be useful as I'm not really experienced in modelling. Do you mind giving an example model? 😁 |
Here's a simple (perhaps too simple) example of a
Another constraint that might be more efficient using
I.e. here we find out that some of the boolean values (e.g. Also, been able to print the domains can be a good help in debugging a model since then one see how the constraints behave. Does this help as inspiration of the use cases? |
I realize that the previous version of function assignment_ctr(model, x, y)
n = length(x)
b1 = @variable(model, [1:n,1:n], Bin)
b2 = @variable(model, [1:n,1:n], Bin)
x_dom = [fd_dom(x[i]) for i in 1:n] # <-
y_dom = [fd_dom(x[i]) for i in 1:n] # <-
for i in 1:n, j in 1:n
@constraint(model, !(i in x_dom) := {b1[i] == 0}) # <- Changed version
@constraint(model, !(i in y_dom) := {b2[i] == 0}) # <-
end
@constraint(model, b1[i,j] := { x[i] == j})
@constraint(model, b2[j,i] := { y[j] == i})
@constraint(model, b1[i,j] + b2[j,i] != 1 )
end
end |
It would be great with a way of obtaining the domain in a variable when writing a Model. It's useful for writing better decompositions than "simply" using the variable's upper/lower domain that
JuMP.lower_bound
andJuMP.upper_bound
support.The syntax could be something like
domain = CS.domain(v)
wheredomain
will be and Array/Vector of the possible values of the variablev
.(When I'm much more comfortable with Julia as well as the source code in ConstraintSolver.jl, I might be able to write constraints / propagators at the source code level, but for a relatively beginner supports for domains and upper/lower bounds - and in general reflection/introspection - at the model is a great help.)
This was originally discussed at Zulip: https://julialang.zulipchat.com/#narrow/stream/268675-ConstraintSolver/topic/Getting.20.22active.22.20domain.20of.20a.20variable.3F
The text was updated successfully, but these errors were encountered: