def save_solution(status)
      status = case status
               when LPSolve::OPTIMAL
                 :optimized
               when LPSolve::INFEASIBLE, LPSolve::UNBOUNDED,
                    LPSolve::DEGENERATE
                 :invalid
               else
                 :unknown
               end

      if status == :optimized
        objective_value = LPSolve.get_objective @ptr
        rows = LPSolve.get_Nrows(@ptr)
        variable_values = [nil]
        @variables.each do |var|
          variable_values << LPSolve.get_var_primalresult(@ptr,
                                                          rows + var.index)
        end
      else
        objective_value = nil
        variable_values = []
      end

      @solution = Solution.new status, objective_value, variable_values
    end
def save_solution(status)
      status = case status
               when LPSolve::OPTIMAL
                 :optimized
               when LPSolve::INFEASIBLE, LPSolve::UNBOUNDED,
                    LPSolve::DEGENERATE
                 :invalid
               else
                 :unknown
               end

      if status == :optimized
        objective_value = LPSolve.get_objective @ptr
        rows = LPSolve.get_Nrows(@ptr)
        variable_values = [nil]
        @variables.each do |var|
          variable_values << LPSolve.get_var_primalresult(@ptr,
                                                          rows + var.index)
        end
      else
        objective_value = nil
        variable_values = []
      end

      @solution = Solution.new status, objective_value, variable_values
    end
Save the solution to the model for access later