Re: [eclipse-clp-users] Variable Bound Symbols in Embedded

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Sat, 18 Apr 2009 20:51:34 +1000
Meriem Djefel wrote:
> Hi all,
> I want to know can I declare a real variable with a domain union of 
> intervals.

You can model such a problem using a disjunctive constraint.
You need to load lib(ic) and lib(propia) for the following.

Write a disjunction of the alternative domain intervals,
and annotate it as follows:

?- (X :: 0.0 .. 1.3 ; X :: 2.1 .. 4.0) infers ic.
X = X{0.0 .. 4.0}
There is 1 delayed goal.
Yes (0.00s cpu)

You see that, although X is displayed as having domain 0.0..4.0,
there is a "delayed goal", i.e. an active constraint which will
make sure that X only takes the allowed values.  For example:

?- (X :: 0.0..1.3 ; X :: 2.1..4.0) infers ic, X = 2.0.
No (0.00s cpu)

?- (X :: 0.0..1.3 ; X :: 2.1..4.0) infers ic, X :: 1.5 .. 2.2.
X = X{2.1 .. 2.2}
There is 1 delayed goal.
Yes (0.00s cpu)


-- Joachim
Received on Sat Apr 18 2009 - 10:51:58 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST