Module: Gecode::BoolEnumMethods

Includes:
VariableEnumMethods
Defined in:
lib/gecoder/interface/enum_wrapper.rb,
lib/gecoder/interface/constraints/bool_enum/boolean.rb

Overview

A module containing the methods needed by enumerations containing boolean variables. Requires that it’s included in an enumerable.

Instance Attribute Summary

Attributes included from EnumMethods

#model

Instance Method Summary collapse

Methods included from VariableEnumMethods

#values

Methods included from EnumMethods

#active_space

Instance Method Details

#conjunctionObject

Produces an expression that can be handled as if it was a variable representing the conjunction of all boolean variables in the enumeration.



5
6
7
8
# File 'lib/gecoder/interface/constraints/bool_enum/boolean.rb', line 5

def conjunction
  return Gecode::Constraints::BoolEnum::ConjunctionStub.new(
    @model, :lhs => self)
end

#disjunctionObject

Produces an expression that can be handled as if it was a variable representing the disjunction of all boolean variables in the enumeration.



12
13
14
15
# File 'lib/gecoder/interface/constraints/bool_enum/boolean.rb', line 12

def disjunction
  return Gecode::Constraints::BoolEnum::DisjunctionStub.new(
    @model, :lhs => self)
end

#to_bool_var_arrayObject Also known as: to_var_array

Returns a bool variable array with all the bound variables.



96
97
98
99
100
101
102
103
104
105
# File 'lib/gecoder/interface/enum_wrapper.rb', line 96

def to_bool_var_array
  space = @model.active_space
  unless @bound_space == space
    elements = to_a
    @bound_arr = Gecode::Raw::BoolVarArray.new(active_space, elements.size)
    elements.each_with_index{ |var, index| @bound_arr[index] = var.bind }
    @bound_space = space
  end
  return @bound_arr
end