[gecode-users] Help: Howto combine sets and value constraints?

Guido Tack tack at ps.uni-sb.de
Tue Dec 15 10:25:08 CET 2009


Hi,

Holger Winnemoeller wrote:

> I am trying to create a solver that (as a toy explanation) can create sets with
> certain properties, such as:
> 
> 1) The resulting set size is specified
> 2) The resulting set contains a certain number of items that belong to a
>   "special" group
> 3) The total "weight" of items is below a certain threshold
> 
> I can easily enough create constraints for 1) and 2), but I would love to get
> some help in how I integrate constraint 3) into the mix. Supposedly I would
> create a set of variables for the weights and specify a constraint on the sum of
> these weights. But I have no idea about how to express in Gecode that I want to
> sum up the weights of exactly the ids that are in the currently selected set. 


have a look at the weights constraint:
http://www.gecode.org/doc-latest/reference/group__TaskModelSetConnect.html#g7c739a2d3c830174ad5e58b77292f6d1

It should do exactly what you describe.

Cheers,
	Guido




More information about the users mailing list