Class: MIPPeR::Gurobi::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/mipper/gurobi/env.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mipper/gurobi/env.rb', line 6

def initialize
  # Create a new environment object
  @ptr = FFI::MemoryPointer.new :pointer
  Gurobi.GRBloadenv @ptr, nil
  @ptr = @ptr.read_pointer

  # Disable output
  Gurobi.GRBsetintparam @ptr, Gurobi::GRB_INT_PAR_OUTPUTFLAG, 0

  # Ensure the environment is freed
  ObjectSpace.define_finalizer self, self.class.finalize(@ptr)
end

Instance Attribute Details

#ptrObject (readonly)

Returns the value of attribute ptr.



4
5
6
# File 'lib/mipper/gurobi/env.rb', line 4

def ptr
  @ptr
end

Class Method Details

.finalize(ptr) ⇒ Object

Free the environment



20
21
22
# File 'lib/mipper/gurobi/env.rb', line 20

def self.finalize(ptr)
  proc { Gurobi.GRBfreeenv ptr }
end