# class Gecode::SetVar

Describes a set variable.

A set variable’s domain, i.e. possible values that it can take, are represented with a greatest lower bound (GLB) and a least upper bound (LUB). The set variable may then take any set value S such that S is a subset of the least upper bound and the greatest lower bound is a subset of S.

If for instance the set has a greatest lower bound {1} and least upper bound {1,3,5} then the assigned set may be any of the following four sets: {1}, {1,3}, {1,5}, {1,3,5}.

The domain of a set variable may also specify the cardinality of the set, i.e. the number of elements that the set may contains.

Set variables are set operands and hence respond to everything that Gecode::Set::SetOperand responds to. Any constraint found in Gecode::Set::SetConstraintReceiver can thereby be placed on set variables.

### Attributes

### Public Instance Methods

Returns a range containing the allowed values for the set’s cardinality.

# File lib/gecoder/interface/variables.rb, line 241 def cardinality send_bound(:cardMin)..send_bound(:cardMax) end

Gets all the elements located in the greatest lower bound of the set (an Enumerable).

# File lib/gecoder/interface/variables.rb, line 216 def lower_bound min = send_bound(:glbMin) max = send_bound(:glbMax) EnumerableView.new(min, max, send_bound(:glbSize)) do (min..max).to_a.delete_if{ |e| not send_bound(:contains, e) } end end

Returns the receiver.

# File lib/gecoder/interface/variables.rb, line 246 def to_set_var self end

Gets all the elements located in the least upper bound of the set (an Enumerable).

# File lib/gecoder/interface/variables.rb, line 226 def upper_bound min = send_bound(:lubMin) max = send_bound(:lubMax) EnumerableView.new(min, max, send_bound(:lubSize)) do (min..max).to_a.delete_if{ |e| send_bound(:notContains, e) } end end

Gets the values in the assigned set variable (an enumerable).

# File lib/gecoder/interface/variables.rb, line 235 def value raise 'No value is assigned.' unless assigned? lower_bound end