[eclipse-clp-users] negate constraints

From: Oliver Shycle <oliver.shycle_at_...1...>
Date: Tue, 30 Mar 2010 09:57:42 +0200
Hi all,

I have a problem to express negated constraints in ECLiPSe. In my programm,
I want to express what value certain interval constraints may NOT have.
Consider the following problem description: the program shall find values
for four variables such that the values are NOT greater than 8.

Here's the code:
:- lib(ic).

example :-

    OutputModel = [A, B, C, D],
    A #:: 1..100,
    B #:: 1..100,
    C #:: 1..100,
    D #:: 1..100,


wrong_value(Vars) :-
    member(Var, Vars),

greater_eight(X) :-
    X #> 8.

I know that I rather could limit the variable's domains to a maximum of 8,
but I want to demonstrate my problem with this snippet. When ECLiPSe comes
along the constraint "X #> 8" with the first variable of the list, the term
evaluates to true. Therefore wrong_value evaluates to true without even
setting up constraints for the other variables. The negation
not(wrong_value(OutputModel)) thus becomes false and ECLiPSe sais it can't
find a solution. If I test the code with a set of integers instead of
variables everything works as expected.
How can I tell ECLiPSe not to evaluate X #> 8 instantly, but keeping the
constraint in mind for later instantiation during labeling/1?

Many thanks for your help.

Received on Tue Mar 30 2010 - 07:57:48 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 25 2019 - 03:15:37 CEST