[gecode-users] std::set to Gecode::IntVar conversion - my quick and dirty solution

Martin Mann mmann at informatik.uni-freiburg.de
Thu May 11 16:31:54 CEST 2006


Grégoire Dooms schrieb:
> Martin Mann wrote:
>> It is not a final solution, because I would like to have a direct 
>> conversion from std::set<int> to Gecode::IntVar, but with a 
>> Gecode::IntSet step between it is usable.
> 
> For a more direct version, do this:
> 
> IntVar i(home, Limits::Int::int_min(), Limits::Int::int_max()); // 
> creates a -inf,+inf single range
> GC_StlSetRangeIterator it(&s);
> IntView iv(i); // modifiable wrapper  around Int var implementation
> GECODE_ME_FAIL(home, iv.inter(it)); //modify upper bound of var by 
> intersecting its ranges with the set iterator
> cout << i << endl;
> 
> This way, you don't need to create the intermediate IntSet (and the 
> intermediate vector as I did because I forgot the std::set was already 
> sorted).

That's it! Thanks a lot Grégoire!

Martin




More information about the gecode-users mailing list