[gecode-users] Getting the domain size

Guido Tack tack at ps.uni-sb.de
Fri Nov 23 10:25:45 CET 2007


Malcolm Ryan wrote:

> Is there any efficient way of getting the domain size of an  
> IntVarView?
>
> Currently, I'm doing:
>
> int min = view.min();
> int max = view.max();
> int size = 0;
> for (int i = min; i <= max; i++) {
> 	if (view.in(i)) size++;
> }

You could use an IntViewRanges iterator, that would be more  
efficient.  Version 2.0.0 will include a method size() for IntViews.

> Also, could you please add a toString() method to IntVarView? It
> would make debugging easier.

Yes, that will also be available in the next version.

Guido





More information about the gecode-users mailing list