class MIPPeR::Gurobi::Environment

Attributes

ptr[R]

Public Class Methods

finalize(ptr) click to toggle source

Free the environment

# File lib/mipper/gurobi/env.rb, line 20
def self.finalize(ptr)
  proc { Gurobi.GRBfreeenv ptr }
end
new() click to toggle source
# 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