Method: Gecode::Set::SetConstraintReceiver#include

Defined in:
lib/gecoder/interface/constraints/set/include.rb

#include(int_enum) ⇒ Object

Constrains this set to include the values of int_enum.

The constraint has the side effect of sorting the integer operands in a non-descending order. It does not support reification nor negation.

Examples

# Constrain +set+ to include the values of all operands in 
# +int_enum+.
set.must.include int_enum


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gecoder/interface/constraints/set/include.rb', line 13

def include(int_enum)
  unless int_enum.respond_to? :to_int_enum
    raise TypeError, "Expected int var enum, got #{int_enum.class}."
  end
  if @params[:negate]
    raise Gecode::MissingConstraintError, 'A negated include is not ' + 
      'implemented.'
  end
  
  @params.update(:variables => int_enum)
  @model.add_constraint Connection::IncludeConstraint.new(@model, @params)
end