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
Instance Method Summary collapse
-
#conjunction ⇒ Object
Produces an expression that can be handled as if it was a variable representing the conjunction of all boolean variables in the enumeration.
-
#disjunction ⇒ Object
Produces an expression that can be handled as if it was a variable representing the disjunction of all boolean variables in the enumeration.
-
#to_bool_var_array ⇒ Object
(also: #to_var_array)
Returns a bool variable array with all the bound variables.
Methods included from VariableEnumMethods
Methods included from EnumMethods
Instance Method Details
#conjunction ⇒ Object
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 |
#disjunction ⇒ Object
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_array ⇒ Object 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 |