Class: Gecode::Bool::ExpressionTree
- Inherits:
-
Object
- Object
- Gecode::Bool::ExpressionTree
- Includes:
- BoolOperand
- Defined in:
- lib/gecoder/interface/constraints/bool/boolean.rb
Overview
Describes a binary tree of expression nodes which together form a boolean expression.
Instance Method Summary collapse
-
#initialize(left_tree, operation, right_tree) ⇒ ExpressionTree
constructor
Constructs a new expression with the specified binary operation applied to the specified trees.
-
#model ⇒ Object
Fetches the space that the expression’s variables is in.
- #to_bool_var ⇒ Object
-
#to_minimodel_bool_expr ⇒ Object
Returns a MiniModel boolean expression representing the tree.
Methods included from BoolOperand
#&, #*, #+, #-, #^, #implies, #method_missing, #|
Methods included from Operand
Methods included from BoolLinearOperations
Constructor Details
#initialize(left_tree, operation, right_tree) ⇒ ExpressionTree
Constructs a new expression with the specified binary operation applied to the specified trees.
196 197 198 199 200 |
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 196 def initialize(left_tree, operation, right_tree) @left = left_tree @operation = operation @right = right_tree end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Gecode::Bool::BoolOperand
Instance Method Details
#model ⇒ Object
Fetches the space that the expression’s variables is in.
210 211 212 |
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 210 def model @left.model || @right.model end |
#to_bool_var ⇒ Object
214 215 216 217 218 219 220 221 222 |
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 214 def to_bool_var bool_var = model.bool_var tree = ExpressionTree.new(self, :==, ExpressionNode.new(bool_var)) model.add_interaction do tree.to_minimodel_bool_expr.post(model.active_space, true, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF) end return bool_var end |
#to_minimodel_bool_expr ⇒ Object
Returns a MiniModel boolean expression representing the tree.
203 204 205 206 207 |
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 203 def to_minimodel_bool_expr Gecode::Raw::MiniModel::BoolExpr.new( @left.to_minimodel_bool_expr, OPERATION_TYPES[@operation], @right.to_minimodel_bool_expr) end |