Re: [eclipse-clp-users] negate constraints

From: Alexandre Saidi <Alexandre.Saidi_at_...37...>
Date: Thu, 1 Apr 2010 14:29:45 +0200
Dear Oliver,
(back to my office) ..
Your sentence may have 2 meanings :
1- any var (One or more) greater than 8 then at least one less than 8
2- one per one (if one var greater than 8 then one smaller than 8)


In the  case-1, take just what I sent but change the ‘OR’ to an ‘AND’   as follows :
:- lib(fd).
example  :-
    OutputModel = [A, B, C, D],
    A #:: 1..10,
    B #:: 1..10,
    C #:: 1..10,
    D #:: 1..10,

% NOT ALL  can have value greater or equal to 8 (i.e. A <8 or B<8 or C<8 or D<8)
   #\+ (A #>= 8 #/\ B#>= 8  #/\  C #>= 2 #/\ D#>= 2),	 % NOT ALL can have value>8
 	labeling(OutputModel),
	writeln(OutputModel).

N.B. : this means that you must always have one of the vars [A,B,C,D] less that 8. So we can also have the following solution (just change the constraint line) : 	
…
A #< 8 #\/ B#< 8 #\/  C #< 8 #\/ D#< 8,
...

OR :

lib(fd). lib(ic_global).
% the constraint part (the rest dose not change) :
V #:: 1..10, N#:: 0..4, occurrences(V,[A,B,C,D],N), V #< 8, N #>=1,
….


For the case-2 : "if one has a value greater, then one must have a value less than 8,   if 2 have values  > 8 then 2 must have value less than 8 (no more case) : you can change the last solution to that case.


Alex.

Le 31 mars 2010 à 14:27, Oliver Shycle a écrit :

> if any variable has a value greater than eight, there must be at least one variable with a value smaller than eight."

 -------------------------------
Alexandre Saidi
Maitre de Conférences
Ecole Centrale de Lyon-Dép. MI
LIRIS-CNRS UMR 5205
Tél : 0472186530, Fax : 0472186443
Received on Thu Apr 01 2010 - 12:29:58 CEST

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