Class: Gecode::Constraints::Set::Domain::EqualityDomainConstraint

Inherits:
ReifiableConstraint show all
Defined in:
lib/gecoder/interface/constraints/set/domain.rb

Overview

Describes a domain constraint which constrains a set to be equal to a constant set.

Examples

# +set+ must equal [1,2,5]
set.must == [1,2,5]

# +set+ must not equal 1..67
set.must_not == 1..67

# +set+ must equal the singleton set 0. The constraint is reified with
# the boolean varaible +is_singleton_zero+.
set.must.equal(0, :reify => is_singleton_zero)

Instance Method Summary collapse

Methods inherited from ReifiableConstraint

#&, #reification_var, #reification_var=, #|

Methods inherited from Constraint

#initialize

Constructor Details

This class inherits a constructor from Gecode::Constraints::Constraint

Instance Method Details

#postObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gecoder/interface/constraints/set/domain.rb', line 50

def post
  var, domain, reif_var, negate = @params.values_at(:lhs, :rhs, :reif, 
    :negate)
  if negate
    rel_type = Gecode::Constraints::Util::NEGATED_SET_RELATION_TYPES[:==]
  else
    rel_type = Gecode::Constraints::Util::SET_RELATION_TYPES[:==]
  end
  
  (params = []) << var.bind
  params << rel_type
  params << Gecode::Constraints::Util.constant_set_to_params(domain)
  params << reif_var.bind if reif_var.respond_to? :bind
  Gecode::Raw::dom(@model.active_space, *params.flatten)
end