[gecode-users] Matrix with two or more lines in one, or in matrix elements, assign

Claudio Cesar de Sá claudio at colmeia.udesc.br
Fri May 7 12:27:38 CEST 2010


Hi

I am trying to obtain as result a matrix with two or more lines that are
complementaries in one.
Ex:
0|0 0 1
1|0 1 0
2|0 1 1

In this case, this matrix should accepted, once the lines 0 and 2  make a
bitwise with OR resulting in 1 ....
Since yesterday I have some advances but with difficulties in types and
operation allowed in matrix element ....
the algorithm was simplified to:
.................................................................................................................
 Matrix < BoolVarArray > m( arrqy_m , mat_size, mat_size);
 BoolVarArray aux (*this,  mat_size*mat_size*mat_size*mat_size , 0, 1 );
    Matrix < BoolVarArray > m_aux( aux , mat_size*mat_size,
mat_size*mat_size);
// a large matrix auxiliar to store all the comparisons ... the size's
complexity is the order n^3/2
.................................................................................................................

     for (int i=0; i < mat_size-1; i++)
       for (int j=i+1; j < mat_size;j++)
         {
           for (int k=0; k < mat_size; k++)
           {
              rel(*this,  m(i , k), BOT_OR, m(j , k),   m_aux(index, k) );
                 // here a  conventional OR  bitwise m(i , k)  or  m(j , k)
with result in m_aux(index, k)
               // I tried something with  BoolVar x(*this, 0,1);
                }

      // NEXT LINE in m_aux
         index++;
         }


Finally, post all the lines filled with 1 in its line

   for (int i=0 ; i <  index ;  i++)
     {
       rel( *this , BOT_AND,  m_aux.row(i) , 1 );
     }


Problems/Difficuties:

a) How to make a conventional or m(i , k), and  m(j , k),  ... assigning its
result in  m_aux(index, k) ?
 BoolVar x1(*this, 0,1);
 BoolVar x2(*this, 0,1);
 x1 =  m(i , k);
 x2 =  m(j , k);
Up to here works fine
  m_aux(index, k) =  x1 || x2;   This atribuition presents problem   ?????

b) In last for, the constraint in over a full line of matrix. Is it possible
to post only some cols of this
matrix, once that the real result has a width of mat_size, by index lines
(number of comparisions)


Thanks in advance







-- 
claudio



   (
   ))
  |""|-.
  |__|-'


**********************************************************************
Skype: claudio_cesar_sa
Links:

http://www.colmeia.udesc.br/
http://www2.joinville.udesc.br/~coca/
http://www2.joinville.udesc.br/~esp7maratona/
Blog: http://claudiocesar.wordpress.com/
***********************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20100507/86863be4/attachment.htm>


More information about the users mailing list