lib/gecoder/interface/constraints/int_enum/equality.rb in gecoder-0.8.3 vs lib/gecoder/interface/constraints/int_enum/equality.rb in gecoder-0.9.0
- old
+ new
@@ -1,8 +1,14 @@
-module Gecode::Constraints::IntEnum
- class Expression
- # Posts an equality constraint on the variables in the enum.
+module Gecode::IntEnum
+ class IntEnumConstraintReceiver
+ # Constrains all operands in the enumeration to be equal.
+ # Neither negation nor reification is supported.
+ #
+ # ==== Examples
+ #
+ # # Constrains all operands in +int_enum+ to be equal.
+ # int_enum.must_be.equal
def equal(options = {})
if @params[:negate]
# The best we could implement it as from here would be a bunch of
# reified pairwise inequality constraints.
raise Gecode::MissingConstraintError, 'A negated equality is not ' +
@@ -12,30 +18,20 @@
raise ArgumentError, 'Reification is not supported by the equality ' +
'constraint.'
end
@model.add_constraint Equality::EqualityConstraint.new(@model,
- @params.update(Gecode::Constraints::Util.decode_options(options)))
+ @params.update(Gecode::Util.decode_options(options)))
end
end
# A module that gathers the classes and modules used in equality constraints.
module Equality #:nodoc:
- # Describes an equality constraint, which constrains all variables in an
- # integer enumeration to be equal. Neither negation nor reification is
- # supported.
- #
- # == Example
- #
- # # Constrains all variables in +int_enum+ to be equal.
- # int_enum.must_be.equal
- class EqualityConstraint < Gecode::Constraints::Constraint
+ class EqualityConstraint < Gecode::Constraint #:nodoc:
def post
- # Bind lhs.
- lhs = @params[:lhs].to_int_var_array
-
- # Fetch the parameters to Gecode.
- Gecode::Raw::eq(@model.active_space, lhs, *propagation_options)
+ Gecode::Raw::rel(@model.active_space,
+ @params[:lhs].to_int_enum.bind_array,
+ Gecode::Raw::IRT_EQ, *propagation_options)
end
end
end
-end
\ No newline at end of file
+end