# class Gecode::Int::IntConstraintReceiver

IntConstraintReceiver contains all constraints that can be placed on an IntOperand.

Constraints are placed by calling Gecode::Operand#must (or any other of the variations defined in Operand), which produces a IntConstraintReceiver from which the desired constraint can be used.

Each constraint accepts a number of options. See ConstraintReceiver for more information.

#### Examples ¶ ↑

Constrains `int_operand`

to be strictly greater than 5 using
IntConstraintReceiver#>:

int_operand.must > 5

Constrains `int_operand1`

plus `int_operand2`

to be
strictly greater than 5 using the IntOperand#+ property and
IntConstraintReceiver#>:

(int_operand1 + int_operand2).must > 5

Constrains the maximum value of the integer operands in
`int_enum`

to *not* be in the range 3..7 using the
IntEnumOperand#max property and #in:

int_enum.max.must_not_be.in 3..7

Constrains the integer operand at position `int_operand`

in
`int_enum`

, an enumeration of integer operands, to be greater
than or equal to `int_operand2`

. This uses the IntEnumOperand#[]
property and IntConstraintReceiver#>=:

int_enum[int_operand].must >= int_operand2

The same as above, but specifying that strength :domain should be used and
that the constraint should be reified with `bool_operand`

:

int_enum[int_operand].must_be.greater_or_equal(int_operand2, :strength => :domain, :reify => bool_operand)

### Public Instance Methods

Constrains the integer operand to be strictly less than
`int_operand_or_fixnum`

. lesser and lesser_than are aliases of
this method.

#### Examples ¶ ↑

# +int1+ must be strictly less than +int2+ int1.must < int2 # +int+ must be strictly less than 17 int.must < 17 # +int1+ must be strictly less than +int2+. We reify the # constraint with +bool+ and select +domain+ as strength. int1.must_be.less_than(int2, :reify => bool, :strength => :domain)

# File lib/gecoder/interface/constraints/int/relation.rb, line 74 def <(int_operand_or_fixnum, options = {}) comparison(:<, int_operand_or_fixnum, options) end

Constrains the integer operand to be less than or equal to
`int_operand_or_fixnum`

. less_or_equal and
less_than_or_equal_to are aliases of this method.

#### Examples ¶ ↑

# +int1+ must be less than or equal to +int2+ int1.must <= int2 # +int+ must be less than or equal to 17 int.must <= 17 # +int1+ must be less than or equal to +int2+. We reify the # constraint with +bool+ and select +domain+ as strength. int1.must.less_or_equal(int2, :reify => bool, :strength => :domain)

# File lib/gecoder/interface/constraints/int/relation.rb, line 93 def <=(int_operand_or_fixnum, options = {}) comparison(:<=, int_operand_or_fixnum, options) end

Constrains the integer operand to be equal to the specified boolean operand. I.e. constrains the integer operand to be 1 when the boolean operand is true and 0 if the boolean operand is false.

#### Examples ¶ ↑

# The integer operand +int+ must be one exactly when the boolean # operand +bool+ is true. int.must == bool

# File lib/gecoder/interface/constraints/int/channel.rb, line 14 def ==(bool, options = {}) unless @params[:lhs].respond_to? :to_int_var and bool.respond_to? :to_bool_var return pre_channel_equals(bool, options) end if @params[:negate] raise Gecode::MissingConstraintError, 'A negated channel constraint ' + 'is not implemented.' end unless options[:reify].nil? raise ArgumentError, 'Reification is not supported by the channel ' + 'constraint.' end @params.update(Gecode::Util.decode_options(options)) @params[:rhs] = bool @model.add_constraint Channel::ChannelConstraint.new(@model, @params) end

Constrains the integer operand to be strictly greater than
`int_operand_or_fixnum`

. greater and greater_than are aliases
of this method.

#### Examples ¶ ↑

# +int1+ must be strictly greater than +int2+ int1.must > int2 # +int+ must be strictly greater than 17 int.must > 17 # +int1+ must be strictly greater than +int2+. We reify the # constraint with +bool+ and select +domain+ as strength. int1.must_be.greater_than(int2, :reify => bool, :strength => :domain)

# File lib/gecoder/interface/constraints/int/relation.rb, line 36 def >(int_operand_or_fixnum, options = {}) comparison(:>, int_operand_or_fixnum, options) end

Constrains the integer operand to be greater than or equal to
`int_operand_or_fixnum`

. greater_or_equal and
greater_than_or_equal_to are aliases of this method.

#### Examples ¶ ↑

# +int1+ must be greater than or equal to +int2+ int1.must >= int2 # +int+ must be greater than or equal to 17 int.must >= 17 # +int1+ must be greater than or equal to +int2+. We reify the # constraint with +bool+ and select +domain+ as strength. int1.must.greater_or_equal(int2, :reify => bool, :strength => :domain)

# File lib/gecoder/interface/constraints/int/relation.rb, line 55 def >=(int_operand_or_fixnum, options = {}) comparison(:>=, int_operand_or_fixnum, options) end

Creates a domain constraint using the specified domain, specified as an enumeration of integers. The integer operand is constrained to take a value in the domain. Domains should be specified as ranges if possible.

#### Examples ¶ ↑

# +x+ must be in the range 1..10 x.must_be.in 1..10 # +x+ must not be in the range -5...5 x.must_not_be.in -5...5 # Specifies the above, but reifies the constraint with the boolean # operand +bool+ and specified +value+ as strength. x.must_not_be.in(-5...5, :reify => bool, :strength => :value) # +x+ must be in the enumeration [3,5,7]. x.must_be.in [3,5,7] # +x+ must not be in the enumeration [5,6,7,17]. x.must_not_be.in [5,6,7,17] # Specifies the above, but reifies the constraint with the boolean # operand +bool+ and specified +value+ as strength. x.must_not_be.in([5,6,7,17], :reify => bool, :strength => :value)

# File lib/gecoder/interface/constraints/int/domain.rb, line 30 def in(domain, options = {}) @params.update(Gecode::Util.decode_options(options)) @params[:domain] = domain if domain.kind_of? Range @model.add_constraint Domain::RangeDomainConstraint.new(@model, @params) elsif domain.kind_of?(Enumerable) and domain.all?{ |e| e.kind_of? Fixnum } @model.add_constraint Domain::EnumDomainConstraint.new(@model, @params) else raise TypeError, "Expected integer enumerable, got #{domain.class}." end end