Class: Gecode::FreeBoolVar

Inherits:
Object
  • Object
show all
Includes:
Constraints::LeftHandSideMethods
Defined in:
lib/gecoder/interface/variables.rb,
lib/gecoder/interface/constraints/bool/linear.rb,
lib/gecoder/interface/constraints/bool/boolean.rb,
lib/gecoder/interface/constraints/bool_var_constraints.rb

Overview

Describes a boolean variable. A boolean variable can be either true or false.

Instance Method Summary collapse

Methods included from Constraints::LeftHandSideMethods

#must, #must_not

Instance Method Details

#&(var) ⇒ Object

Initiates a boolean constraint with this variable and var.



9
10
11
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 9

def &(var)
  Constraints::Bool::ExpressionNode.new(self, @model) & var
end

#*(int) ⇒ Object

Creates a linear expression where the bool variable is multiplied with a constant integer.



13
14
15
16
17
18
19
20
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 13

def *(int)
  if int.kind_of? Fixnum
    Gecode::Constraints::Int::Linear::ExpressionNode.new(self, 
      @model) * int
  else
    pre_linear_mult(int) if respond_to? :pre_linear_mult
  end
end

#+(var) ⇒ Object

Creates a linear expression where the bool variables are summed.



4
5
6
7
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 4

def +(var)
  Gecode::Constraints::Int::Linear::ExpressionNode.new(self, 
    @model) + var
end

#-(var) ⇒ Object

Creates a linear expression where the specified variable is subtracted from this one.



24
25
26
27
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 24

def -(var)
  Gecode::Constraints::Int::Linear::ExpressionNode.new(self, 
    @model) - var
end

#^(var) ⇒ Object

Initiates a boolean constraint with this variable exclusive or var.



14
15
16
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 14

def ^(var)
  Constraints::Bool::ExpressionNode.new(self, @model) ^ var
end

#implies(var) ⇒ Object

Initiates a boolean constraint with this variable implies var.



19
20
21
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 19

def implies(var)
  Constraints::Bool::ExpressionNode.new(self, @model).implies var
end

#pre_linear_multObject



9
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 9

alias_method :pre_linear_mult, :*

#valueObject

Gets the values in the assigned boolean variable (true or false). The variable must be assigned, if it isn’t then a RuntimeError is raised.



122
123
124
125
# File 'lib/gecoder/interface/variables.rb', line 122

def value
  raise 'No value is assigned.' unless assigned?
  send_bound(:val) == 1
end

#|(var) ⇒ Object

Initiates a boolean constraint with this variable or var.



4
5
6
# File 'lib/gecoder/interface/constraints/bool/boolean.rb', line 4

def |(var)
  Constraints::Bool::ExpressionNode.new(self, @model) | var
end