Class: MIPPeR::Gurobi::Environment
- Inherits:
-
Object
- Object
- MIPPeR::Gurobi::Environment
- Defined in:
- lib/mipper/gurobi/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.
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
#ptr ⇒ Object (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 |