Class: Gecode::Constraints::Set::Expression

Inherits:
Expression
  • Object
show all
Defined in:
lib/gecoder/interface/constraints/set_var_constraints.rb,
lib/gecoder/interface/constraints/set/domain.rb,
lib/gecoder/interface/constraints/set/channel.rb,
lib/gecoder/interface/constraints/set/relation.rb

Overview

An expression with a set as left hand side.

Instance Method Summary collapse

Methods inherited from Expression

#initialize

Constructor Details

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

Instance Method Details

#channel(bool_enum, options = {}) ⇒ Object

Adds a channel constraint on the set variable with the specified enum of boolean variables.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gecoder/interface/constraints/set/channel.rb', line 5

def channel(bool_enum, options = {})
  if @params[:negate]
    raise Gecode::MissingConstraintError, 'A negated channel constraint ' + 
      'is not implemented.'
  end
  if options.has_key? :reify
    raise ArgumentError, 'The channel constraint does not support the ' + 
      'reification option.'
  end
  unless bool_enum.respond_to? :to_bool_var_array
    raise TypeError, 'Expected an enum of bool variables, ' + 
      "got #{bool_enum.class}."
  end
  
  @params.update(:rhs => bool_enum)
  @params.update Gecode::Constraints::Set::Util.decode_options(options)
  @model.add_constraint Channel::ChannelConstraint.new(@model, @params)
end