How to optimize this (probably with 'cardinality') ? 
Author Message
 How to optimize this (probably with 'cardinality') ?

Brest, le mardi 20 novembre

Hi, I want to write a clause:
  * argument is a list of 37 FD_vars
  * each one of these vars is in the interval [0..35]
  * I want to post the following constraint:
      they all must appear once, except one variable that appears twice
      (ex: [0,1,1,2,3,4,..35] is correct, but [0,1,1,2,3,3,..33,35] isn't).
      My first (and probably ugly) idea was:

together(A) :-
  fd_atleast(1,A,0),
  fd_atleast(1,A,1),
  fd_atleast(1,A,2),
  fd_atleast(1,A,3),
  fd_atleast(1,A,4),
  fd_atleast(1,A,5),
[...]
  fd_atleast(1,A,33),
  fd_atleast(1,A,34),
  fd_atleast(1,A,35).

(The idea is obviously to tell the solver "each number must appear once
in the list" (because there are 36 possible values and 37 variables)).
I don't know really how to use fd_cardinality, but I'm sure that a
more elegant solution is reachable.

--
QlpoOTFBWSZTWcwiz1oAAC1fgHQTwOeABVAABAT7Zp4lMAC4hET1DQNGhoBoyGaQYyaZAyaG
QZGmBGDTJE01NMTJkZDQaAUhm7W8Wu9WYGQZg2Vd+s8PsaiAZJoF5jaDsEQUaCEQHgnxdw5H
siRDfoqLyg4gHe6/TCLCgm0gY3zjVSswgknIk85qBbV7GNcqz8yWcUOcrT4SlYICcQUgKxM2
gumlEIhPgCSCC4gUHVb3pREx/vdlGkW5r2P5Z+LuSKcKEhmEWetA | mimencode + bzip2



Sun, 09 May 2004 03:53:11 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Probably it's easy, but I don't know how to do :(

2. VO - This is what's in VO version 2 - probably

3. Problem (probably simple) that I can't solve

4. Probably the last pseudo-random number generator you'll ever need

5. Probably I'm just too stupid, but...

6. Merry Xmas !!! - Last post of '97 (probably)

7. "Can't optimize #repeat" warning

8. Synthesis Constraint - Don't optimize

9. Leonardo won't optimize

10. Borland Optimizing Compiler Isn't

11. Question about DEC's optimizing compilers in RISC ULTRIX

12. stream('file','c','seek ='x) problem

 

 
Powered by phpBB® Forum Software