[ library(ic) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]

?Vars :: ++Domain

Constrain Vars to have the domain Domain.
Vars
Variable, list of variables or submatrix of variables
Domain
Domain specification

Description

Constrains Vars to take only integer or real values from the domain specified by Domain. Vars may be a variable, a list, or a submatrix (e.g. M[1..4, 3..6]); for a list or a submatrix, the domain is applied recursively so that one can apply a domain to, for instance, a list of lists of variables. Domain can be specified as a simple range Lo .. Hi, or as a list of subranges and/or individual elements (integer variables only). The type of the bounds determines the type of the variable (real or integer). Also allowed are the (untyped) symbolic bound values inf, +inf and -inf. For instance:

     X :: 0..1                  % boolean
     X :: -1..5                 % integer between -1 and 5
     X :: 1..inf                % strictly positive integer
     X :: 0.0..10.0             % real between 0.0 and 10.0
     X :: 1.5..3.7              % real between 1.5 and 3.7
     X :: 1.4__1.6..3.6__3.8    % real where the bounds aren't known exactly
     X :: breal(0)..inf         % nonnegative real
     X :: [0..3, 5, 8..10]      % any integer from 0 to 10 except 4 and 6
     [X, Y, Z] :: 1..8          % (recursively) apply domain to X, Y and Z
     M[2..4, 5] :: 1..8         % apply to rows 2..4, column 5 of matrix M
     X :: 0.0..5                % Type error
     X :: [0.0..5.0, 7.0..9.0]  % Type error
     X :: [a, b, c]             % Type error
Note that floating point bounds, like all floating point numbers given to the IC solver, are assumed to be fuzzy. This means there's a small amount of uncertainty as to exactly what the endpoints of the domain are, and this will be reflected in delayed goals constraining the variable to lie between these fuzzy bounds. Sometimes it is convenient to be able to express exact integer bounds (so no delayed goals are set up) without having the domain interpreted as being integral. This can be conveniently done by casting the integer to a bounded real, e.g. breal(0). In general, specifying a zero-width bounded real will avoid delayed goals in this context, but is not recommended unless you are sure that the machine representation of the floating point value used in constructing the bounded real exactly matches the number you intend.

Examples

[eclipse 2]: X :: 0..1.
X = X{[0, 1]}
Yes (0.00s cpu)

[eclipse 3]: X :: -1..5.
X = X{-1 .. 5}
Yes (0.00s cpu)

[eclipse 4]: X :: 1..inf.
X = X{1 .. 1.0Inf}
Yes (0.00s cpu)

[eclipse 5]: X :: 0.0..10.0.
X = X{-2.2250738585072014e-308 .. 10.000000000000002}
Delayed goals:
        ic : (-(X{-2.2250738585072014e-308 .. 10.000000000000002}) =< -2.2250738585072014e-308__2.2250738585072014e-308)
        ic : (X{-2.2250738585072014e-308 .. 10.000000000000002} =< 9.9999999999999982__10.000000000000002)
Yes (0.00s cpu)

[eclipse 6]: X :: breal(0)..breal(10).
X = X{0.0 .. 10.0}
Yes (0.00s cpu)

[eclipse 7]: X :: 1.5..3.7.
X = X{1.4999999999999998 .. 3.7000000000000006}
Delayed goals:
        ic : (-(X{1.4999999999999998 .. 3.7000000000000006}) =< -1.5000000000000002__-1.4999999999999998)
        ic : (X{1.4999999999999998 .. 3.7000000000000006} =< 3.6999999999999997__3.7000000000000006)
Yes (0.00s cpu)

[eclipse 8]: X :: 1.4__1.6..3.6__3.8.
X = X{1.4 .. 3.8}
Delayed goals:
        ic : (-(X{1.4 .. 3.8}) =< -1.6__-1.4)
        ic : (X{1.4 .. 3.8} =< 3.6__3.8)
Yes (0.00s cpu)

[eclipse 9]: X :: [0..3, 5, 8..10].
X = X{[0 .. 3, 5, 8 .. 10]}
Yes (0.00s cpu)

See Also

integers / 1, reals / 1, fd : :: / 2, suspend : :: / 2, range : :: / 2, eplex : :: / 2, ria : :: / 2, fdplex : :: / 2, fd_sets : :: / 2