Class: Gecode::FreeVarBase

Inherits:
Object
  • Object
show all
Defined in:
lib/gecoder/interface/variables.rb

Overview

Describes a variable that is bound to a model, but not to a particular space.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, index) ⇒ FreeVarBase

Creates an int variable with the specified index.



8
9
10
11
12
13
# File 'lib/gecoder/interface/variables.rb', line 8

def initialize(model, index)
  @model = model
  @index = index
  @bound_space = @bound_var = nil
  model.track_variable(self)
end

Instance Attribute Details

#modelObject

:nodoc:



5
6
7
# File 'lib/gecoder/interface/variables.rb', line 5

def model
  @model
end

Instance Method Details

#cached?Boolean

Checks whether the variable is cached, i.e. whether it needs to be rebound after changes to a space.

Returns:

  • (Boolean)


17
18
19
# File 'lib/gecoder/interface/variables.rb', line 17

def cached?
  not @bound_space.nil?
end

#inspectObject



26
27
28
29
30
31
32
# File 'lib/gecoder/interface/variables.rb', line 26

def inspect
  if assigned?
    "#<#{self.class} #{domain}>"
  else
    "#<#{self.class} #{domain}>"
  end
end

#refreshObject

Forces the variable to refresh itself.



22
23
24
# File 'lib/gecoder/interface/variables.rb', line 22

def refresh
  @bound_space = nil
end