That's the oldest trick from the schoolbook: when you create the tree, maintain in each node a counter that tells you the number of nodes (or leaves, or the nodes corresponding to a linear expression or whatever you need) in the subtree.
As suggested earlier, this trick is used also in post linear expressions in mini model. Christian -- Christian Schulte, www.ict.kth.se/~cschulte/ -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Max Sent: Tuesday, December 02, 2008 12:52 PM To: [EMAIL PROTECTED] Subject: [gecode-users] Dynamic creation of IntVarArgs Hello everybody, i wanted to create an IntVarArgs array for using linear constraints. I need this array in an recursive function where the size is calculated at the end of the recursion(recursion size == array size). Now i found out that a can not dynamically create an IntVarArgs or an IntArgs. This, seems reasonable, because i would have to destroy it somewhere, and i don't know if gecode copies the reference it gets in the linear call(i don't think so and it would be better not to do so). BUT: Why can i not create an IntVarArgs array without size and initializing it with a size at a later time. Without that, i would have to recurse my tree two times, one time for evaluating the size of the array, and one time to fill it. This is bad. Do i have overseen something ? Why is this feature not supported. Any ideas how to solve my problem? Thanks in advance. Max _______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users _______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users
