Class: Gecode::Constraints::BoolEnum::Channel::ChannelConstraint

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

Overview

Describes a channel constraint that “channels” an enumeration of boolean variables with an integer variable. This constrains the integer variable to take value i exactly when the variable at index i in the boolean enumeration is true and the others are false.

Neither reification nor negation is supported. The int variable and the enumeration can be interchanged.

Examples

# Constrains the enumeration called option_is_selected to be false in the # first four positions and have exactly one true variable in the other. option_is_selected.must.channel selected_option_index selected_option_index.must_be > 3

# Constrains the enumeration called option_is_selected to be false in the # first five positions and have exactly one true variable in the other. selected_option_index.must.channel(option_is_selected, :offset => 1) selected_option_index.must_be > 3

Instance Method Summary collapse

Methods inherited from Constraint

#initialize

Constructor Details

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

Instance Method Details

#postObject



57
58
59
60
61
# File 'lib/gecoder/interface/constraints/bool_enum/channel.rb', line 57

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