Sha256: a629c633966f3cbf2e9dfce219d9cf758c4a7fea5d5badc0c86ebbbea4ae902a
Contents?: true
Size: 1.39 KB
Versions: 12
Compression:
Stored size: 1.39 KB
Contents
module Gecode::Constraints::IntEnum class Expression # Posts an equality constraint on the variables in the enum. 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 ' + 'implemented.' end unless options[:reify].nil? 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))) 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 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) end end end end
Version data entries
12 entries across 12 versions & 2 rubygems