Just use linear and rel constraints to do that, a little math tells you:

                q[i] + i != q[j] + j ó q[i] – q[j] != j-i   

 

Christian

 

--

Christian Schulte, www.ict.kth.se/~cschulte/

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Mauricio Toro
Sent: Thursday, February 21, 2008 2:17 AM
To: [EMAIL PROTECTED]
Subject: [gecode-users] Queens without using post

 

Hello,

 

Can somebody help to rewrite this code without using post

 

  Queens(const SizeOptions& opt)

    : q(this,opt.size(),0,opt.size()-1) {

    const int n = q.size();

    switch (opt.propagation()) {

    case PROP_BINARY:

      for (int i = 0; i<n; i++)

        for (int j = i+1; j<n; j++) {

          post(this, q[i] != q[j]);

          post(this, q[i]+i != q[j]+j);

          post(this, q[i]-i != q[j]-j);

        }

 

It is taken from the queens example.

It will be used for the Common Lisp port examples.

We have not ported "post" for Common Lisp yet.

 

Thanks


-- 
Mauricio Toro Bermudez
Estudiante de Ingeniería de Sistemas
Pontificia Universidad Javeriana, Colombia

Stagiare à l'Ircam
1, place Igor-Stravinsky 75004 Paris, 
France de 2008 à 2009 

_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to