module Gecode::Int::IntOperand
A IntOperand is a combination of variables on which the constraints defined in IntConstraintReceiver can be placed.
Integer operands can be created either by using Gecode::Mixin#int_var et al, or by using properties that produce integer operands. The operands, no matter how they were created, all respond to the properties defined by IntOperand.
Examples ¶ ↑
Produces a single integer operand (more specifically an IntVar) with domain 0..9 inside a problem formulation, using Gecode::Mixin#int_var:
int_operand = int_var(0..9)
Uses the IntOperand#+ property to produce a new integer operand
representing int_operand1
plus int_operand2
:
new_int_operand = int_operand1 + int_operand2
Uses the IntEnumOperand#max property to produce a new integer operand
representing the maximum value of the integer operands in the enumeration
int_enum
:
new_int_operand = int_enum.max
Uses the IntEnumOperand#[] property to produce a new integer operand
representing the integer operand at the index decided by
int_operand
(which can change during search) in the
enumeration int_enum
:
new_int_operand = int_enum[int_operand]
Uses the SetOperand#size property to produce a new integer operand
representing the size of set_operand
:
new_int_operand = set_operand.size
Public Instance Methods
Produces a new IntOperand representing this
operand times int_operand
.
Examples ¶ ↑
# The value of +int_op1+ times +int_op2+. int_op1 * int_op2
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/arithmetic.rb, line 46 def *(int_operand) if int_operand.respond_to? :to_int_var Arithmetic::IntMultOperand.new(@model, self, int_operand) else pre_arith_mult(int_operand) end end
Produces a new IntOperand representing this
operand plus int_operand_or_fixnum
.
Examples ¶ ↑
# +int1+ plus +int2+ int1 + int2 # +int+ plus 17 int + 17
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/linear.rb, line 13 def +(int_operand_or_fixnum) int_linear_expression_operation(:+, int_operand_or_fixnum) end
Produces a new IntOperand representing this
operand minus int_operand_or_fixnum
.
Examples ¶ ↑
# +int1+ minus +int2+ int1 - int2 # +int+ minus 17 int - 17
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/linear.rb, line 27 def -(int_operand_or_fixnum) int_linear_expression_operation(:-, int_operand_or_fixnum) end
Produces an IntOperand representing the absolute value of this operand.
Examples ¶ ↑
# The absolute value of +int_op+. int_op.abs
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/arithmetic.rb, line 10 def abs Arithmetic::IntAbsOperand.new(@model, self) end
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int_var_constraints.rb, line 48 def method_missing(method, *args) if Gecode::IntVar.instance_methods.include? method.to_s # Delegate to the int var. to_int_var.method(method).call(*args) else super end end
Produces an IntOperand representing the square root of this operand rounded down.
Examples ¶ ↑
# The square root of +int_op+, rounded down. int_op.square_root
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/arithmetic.rb, line 31 def square_root Arithmetic::IntSquareRootOperand.new(@model, self) end
Produces an IntOperand representing this operand squared.
Examples ¶ ↑
# The value of +int_op*int_op+. int_op.squared
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/arithmetic.rb, line 20 def squared Arithmetic::IntSquaredOperand.new(@model, self) end