[gecode-users] data structure for effiency

Christian Schulte cschulte at kth.se
Thu Mar 15 15:42:19 CET 2007


Hi,

the problem is inherent in the two dimensional structure! Besides of the
performance problems you describe it will give poor propagation. 

Suppose you have an x coordinate from {1,2,3,4} and a y coordinate from
{1,2,3,4}. Then the two coordinates can denote 16 different cells, so very
little information. In that case using an element constraint for accessing
cells will offer poor propagation whatever you use to organize the data
structure!

So if possible avoid two dimensional structures with variable-variables
access.

If one of the coordinates is a constant as in your example, you should
transpose the matrix to change row and column and not use a mult constraint.

For simple uses with matrices, check the Matrix class in the Minimodel. Some
of the examples use this.

Christian

--
Christian Schulte, http://www.imit.kth.se/~schulte/ 

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Serdar Kadioglu
Sent: Thursday, March 15, 2007 2:43 PM
To: users at gecode.org
Subject: [gecode-users] data structure for effiency 



Hi! 

I would like to keep variables in a matrix data structure. 
Array of arrays like VarArray<VarArray<IntVar>> did not work. 
My aim is to reach a cell with an unknown row_IntVar , and known column_int 

If I flatten everything in one dimensional VarArray
then to reach a cell I call; 

        element(Intvar_row * #of columns + column_int).

This multiplication and addition is just an index arithmetic but forces me
to call two linear() operations and create many redundant IntVar's for every
j.

Is there an efficient way of reaching these cells, 
(may be a 2D structure that I am unaware of probably)
because this bottleneck really slows down the model. 

Regards,
serdar

_______________________________________________
Gecode users mailing list
users at gecode.org https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list