docs: def knapsack_iterative_numpy(items, maxweight):
      """
      Iterative knapsack method
  
      maximize \sum_{i \in T} v_i
      subject to \sum_{i \in T} w_i \leq W
  
      Notes:
          dpmat is the dynamic programming memoization matrix.
          dpmat[i, w] is the total value of the items with weight at most W
          T is the set of indicies in the optimal solution
      """
      #import numpy as np
      items = np.array(items)
      weights = items.T[1]
      # Find maximum decimal place (this problem is in NP)
      max_exp = max([number_of_decimals(w_) for w_ in weights])
      coeff = 10 ** max_exp
      # Adjust weights to be integral
      weights = (weights * coeff).astype(np.int)
      values  = items.T[0]
      MAXWEIGHT = int(maxweight * coeff)
      W_SIZE = MAXWEIGHT + 1
  
      dpmat = np.full((len(items), W_SIZE), np.inf)
      kmat = np.full((len(items), W_SIZE), 0, dtype=np.bool)
      idx_subset = []
  
      for w in range(W_SIZE):
          dpmat[0][w] = 0
      for idx in range(1, len(items)):
          item_val = values[idx]
          item_weight = weights[idx]
          for w in range(W_SIZE):
              valid_item = item_weight <= w
              prev_val = dpmat[idx - 1][w]
              if valid_item:
                  prev_noitem_val = dpmat[idx - 1][w - item_weight]
                  withitem_val = item_val + prev_noitem_val
                  more_valuable = withitem_val > prev_val
              else:
                  more_valuable = False
              dpmat[idx][w] = withitem_val if more_valuable else prev_val
              kmat[idx][w] = more_valuable
      K = MAXWEIGHT
      for idx in reversed(range(1, len(items))):
          if kmat[idx, K]:
              idx_subset.append(idx)
              K = K - weights[idx]
      idx_subset = sorted(idx_subset)
      items_subset = [items[i] for i in idx_subset]
      total_value = dpmat[len(items) - 1][MAXWEIGHT]
      return total_value, items_subset