Module: Gecode

Defined in:
lib/gecoder/bindings.rb,
lib/gecoder/interface/model.rb,
lib/gecoder/interface/branch.rb,
lib/gecoder/interface/search.rb,
lib/gecoder/interface/variables.rb,
lib/gecoder/interface/constraints.rb,
lib/gecoder/interface/enum_wrapper.rb,
lib/gecoder/interface/constraints/int/linear.rb,
lib/gecoder/interface/constraints/bool/linear.rb,
lib/gecoder/interface/constraints/bool/boolean.rb,
lib/gecoder/interface/constraints/set/relation.rb,
lib/gecoder/interface/constraints/set/operation.rb,
lib/gecoder/interface/constraints/int_enum/count.rb,
lib/gecoder/interface/constraints/set/cardinality.rb,
lib/gecoder/interface/constraints/int_enum/distinct.rb,
lib/gecoder/interface/constraints/bool_enum/relation.rb,
lib/gecoder/interface/constraints/int_var_constraints.rb,
lib/gecoder/interface/constraints/set_var_constraints.rb,
lib/gecoder/interface/constraints/bool_var_constraints.rb,
lib/gecoder/interface/constraints/int_enum_constraints.rb,
lib/gecoder/interface/constraints/set_enum_constraints.rb,
lib/gecoder/interface/constraints/bool_enum_constraints.rb

Defined Under Namespace

Modules: BoolEnumMethods, Constraints, EnumMethods, FixnumEnumMethods, IntEnumMethods, LoggingLayer, SetEnumMethods, Util, VariableEnumMethods Classes: EnumerableView, FreeBoolVar, FreeIntVar, FreeSetVar, FreeVarBase, MissingConstraintError, Model

Constant Summary collapse

Raw =

We just make Gecode::Raw an alias of the real module.

::GecodeRaw

Class Method Summary collapse

Class Method Details

.FreeVar(bound_class, space_bind_method) ⇒ Object

Creates a class for a free variable that can be bound into the specified class using the specified method in a space.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gecoder/interface/variables.rb', line 39

def Gecode::FreeVar(bound_class, space_bind_method)
  clazz = Class.new(FreeVarBase)
  clazz.class_eval <<-"end_method_definitions"      
    # Binds the int variable to the currently active space of the model, 
    # returning the bound int variable.
    def bind
      active_space.method(:#{space_bind_method}).call(@index)
    end
    
    private
    
    # Delegates the method with the specified name to a method with the 
    # specified name when the variable is bound. If the bound method's name
    # is nil then the same name as the new method's name is assumed.
    def self.delegate(method_name, bound_method_name = nil)
      bound_method_name = method_name if bound_method_name.nil?
      module_eval <<-"end_code"
        def \#{method_name}(*args)
          @model.allow_space_access do
            bind.method(:\#{bound_method_name}).call(*args)
          end
        end
      end_code
    end
  end_method_definitions
  return clazz
end

.load_bindings_libObject

Loads the binding libraries. This is done as a method in order to be easier to test.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gecoder/bindings.rb', line 4

def self.load_bindings_lib #:nodoc:
  # Workaround to get the precompiled DLLs into the DLL search path on 
  # Windows.
  dll_dir = File.dirname(__FILE__) + '/../../vendor/gecode/win32/lib'
  if RUBY_PLATFORM =~ /mswin/ and File.exists? dll_dir
    # Switch directory while loading libraries so that the DLLs are in the 
    # work directory.
    require 'fileutils'
    FileUtils.cd dll_dir do
      require 'gecode'
    end
  else
    require 'gecode'
  end
end