module Gecode::Operand
Describes an operand, something that a constraint can be placed on. Constraints are placed by calling must or must_not (the latter negates the constraint). This produces a ConstraintReceiver, which defines methods that places constraints on the operand.
In general this produces something like the following.
operand.must.constraint_method(params)
See e.g. Gecode::Int::IntOperand for concrete examples.
Classes that mix in Operand must define the methods model and construct_receiver. They should also define a method that converts the operand into a variable of the operand’s type (e.g. int var operands should define a method to_int_var that returns an instance of Gecode::IntVar that represents the operand). The latter method should be used by constraints to fetch variables needed when posting constraints. The presence of the method should also be used for type checking (rather than e.g. checking whether a parameter is of type IntOperand).
Public Instance Methods
Fetches the model that the operand belongs to.
# File lib/gecoder/interface/constraints.rb, line 43 def model raise NotImplementedError, 'Abstract method has not been implemented.' end
Specifies that a constraint must hold for the left hand side.
# File lib/gecoder/interface/constraints.rb, line 30 def must construct_receiver :lhs => self, :negate => false end
Specifies that the negation of a constraint must hold for the left hand side.
# File lib/gecoder/interface/constraints.rb, line 37 def must_not construct_receiver :lhs => self, :negate => true end