Class: Gecode::Constraints::Set::Channel::ChannelConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/gecoder/interface/constraints/set/channel.rb

Overview

Describes a channel constraint that “channels” a set variable and an enumerations of boolean variables. This constrains the set variable to include value i exactly when the variable at index i in the boolean enumeration is true.

Neither reification nor negation is supported. The boolean enum and set can be interchanged.

Examples

# Constrains the enumeration of boolean variables called bools to at # least have the first and third variables set to true set.must_be.superset_of [0, 2] set.must.channel bools

# An alternative way of writing the above. set.must_be.superset_of [0, 2] bools.must.channel set

Instance Method Summary collapse

Methods inherited from Constraint

#initialize

Constructor Details

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

Instance Method Details

#postObject



47
48
49
50
51
# File 'lib/gecoder/interface/constraints/set/channel.rb', line 47

def post
  lhs, rhs = @params.values_at(:lhs, :rhs)
  Gecode::Raw::channel(@model.active_space, rhs.to_bool_var_array, 
    lhs.bind)
end