Class: Gecode::Constraints::BoolEnum::Relation::ConjunctionStub

Inherits:
Gecode::Constraints::Bool::CompositeStub show all
Defined in:
lib/gecoder/interface/constraints/bool_enum/relation.rb

Overview

Describes a CompositeStub for the conjunction constraint, which constrain the conjunction of all boolean variables in an enumeration.

Example

# The conjunction of all variables in +bool_enum+ must be true. I.e. all
# boolean variables must take the value true.
bool_enum.conjunction.must_be.true

# The conjunction of all variables in +bool_enum+ must equal b1.
bool_enum.conjunction.must ==  b1

# The conjunction of all variables in +bool_enum+ must not equal b1 and 
# b2. It's reified it with +bool+ and selects the strength +domain+.
bool_enum.conjunction.must_not.equal(b1 & b2, :reify => bool, 
  :strength => :domain)

Instance Method Summary collapse

Methods inherited from Gecode::Constraints::Bool::CompositeStub

#initialize

Methods inherited from CompositeStub

#initialize

Methods included from LeftHandSideMethods

#must, #must_not

Methods inherited from ExpressionStub

#initialize

Constructor Details

This class inherits a constructor from Gecode::Constraints::Bool::CompositeStub

Instance Method Details

#constrain_equal(variable, params, constrain) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gecoder/interface/constraints/bool_enum/relation.rb', line 40

def constrain_equal(variable, params, constrain)
  enum = @params[:lhs]
  
  @model.add_interaction do
    if variable.respond_to? :bind
      bound = variable.bind
    else
      bound = variable ? 1 : 0
    end
    Gecode::Raw::rel(@model.active_space, Gecode::Raw::BOT_AND,
      enum.to_bool_var_array, bound, *propagation_options)
  end
  return variable
end