def add_variables(vars)
      objective_buffer = build_pointer_array vars.map(&:coefficient), :double
      lb_buffer = build_pointer_array vars.map(&:lower_bound), :double
      ub_buffer = build_pointer_array vars.map(&:upper_bound), :double
      type_buffer = build_pointer_array(vars.map do |var|
        gurobi_type(var.type)
      end, :char)
      names_buffer = build_pointer_array array_to_pointers_to_names(vars),
                                         :pointer

      ret = Gurobi.GRBaddvars @ptr, vars.length, 0, nil, nil, nil,
                              objective_buffer, lb_buffer, ub_buffer,
                              type_buffer, names_buffer

      fail if ret != 0

      # Store all the variables in the model
      vars.each { |var| store_variable var }

      # Update the model with variables so constraint adds succeed
      ret = Gurobi.GRBupdatemodel @ptr
      fail if ret != 0
    end
def add_variables(vars)
      objective_buffer = build_pointer_array vars.map(&:coefficient), :double
      lb_buffer = build_pointer_array vars.map(&:lower_bound), :double
      ub_buffer = build_pointer_array vars.map(&:upper_bound), :double
      type_buffer = build_pointer_array(vars.map do |var|
        gurobi_type(var.type)
      end, :char)
      names_buffer = build_pointer_array array_to_pointers_to_names(vars),
                                         :pointer

      ret = Gurobi.GRBaddvars @ptr, vars.length, 0, nil, nil, nil,
                              objective_buffer, lb_buffer, ub_buffer,
                              type_buffer, names_buffer

      fail if ret != 0

      # Store all the variables in the model
      vars.each { |var| store_variable var }

      # Update the model with variables so constraint adds succeed
      ret = Gurobi.GRBupdatemodel @ptr
      fail if ret != 0
    end
Add multiple variables to the model simultaneously