Class: Guruby::Environment
- Inherits:
-
Object
- Object
- Guruby::Environment
- Defined in:
- lib/guruby/env.rb
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
-
.finalize(ptr) ⇒ Object
Free the environment.
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/guruby/env.rb', line 7 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, GRB_INT_PAR_OUTPUTFLAG, 0 # Ensure the environment is freed ObjectSpace.define_finalizer self, self.class.finalize(@ptr) end |
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
5 6 7 |
# File 'lib/guruby/env.rb', line 5 def ptr @ptr end |
Class Method Details
.finalize(ptr) ⇒ Object
Free the environment
21 22 23 |
# File 'lib/guruby/env.rb', line 21 def self.finalize(ptr) proc { Gurobi.GRBfreeenv ptr } end |