# Maximize Cash Back

Credit cards often offers rewards for purchases. For example, a card that gives 5% cash back for grocery stores. Also, credit cards often can be used to buy gift cards for specific stores.

For example, one can use Chase Ink Cash (CIC) and go to Staples and buy gift card for Amazon for effectively 7.5% off Amazon (I value UR at 1.5 cents each).

However, there is usually a limit. CIC caps the reward spending to $25000. Still, it would translate to $1875 of savings. Anything afterwards only earns 1.5%.

I often do large purchases at some retailers, and I have huge number of credit cards. It make sense for me to optimize spending. I use historical data to estimate amount of spending at retailers, and come up with a nice optimization problem.

There are $k$ stores, we want to purchase an item of value $d_{i}$ in store $i$, and want spend the least amount of money.

Stores can also sell gift cards for specific stores (some gives cash back), and one can use the gift card to buy item from other stores. For simplicity, we assume gift card for a particular store can be used to buy gift cards (so it work just like cash). $g_{i,j}$ is the cash back one obtain for buying $1$ unit of gift card for store $j$ from store $i$.

We also have $n$ credit cards. Each credit card have an upper limit $u_{i}$. For credit card $i$, it gives cash back of $c_{i,j}$ per unit on store $j$ if total spend of the credit card is no larger than $u_{i}$, otherwise it give cash back $c_{i,j}$.

This is a min-cost flow problem. Indeed, let’s build the graph. Edges default to have infinite capacity and 0 cost. Node default to have 0 demand.

For credit card $i$, we create $3$ nodes, $a_{i},b_{i},b_{i}$. There is is edge $(a_{i},b_{i})$ with capacity $u_{i}$, there is an edge $(a_{i},b_{i})$ with infinite capacity. For each store, we create a node $s_{i}$, and there are edges $(s_{i},s_{j})$ with cost $−g_{i,j}$. The demand on $s_{i}$ is $d_{i}$. For each credit card $i$ and store $j$, there is an edge $(b_{i},s_{i})$ with cost $−c_{i,j}$, and an edge $(b_{i},s_{i})$ with cost $−c_{i,j}$. Finally add a source node connect to each $a_{i}$. Source node has demand $−∑_{i}d_{i}$.

Some stores does not allow gift card to be used to purchase more gift cards. Indeed, this was not the case a long time ago, until people abused the price difference to generate infinite money.

This can be fixed by duplicate this store into a cash version, so $s_{c,i}$ and gift card version $s_{g,i}$. We redirect edges to the correct ones. Namely credit card goes to $s_{c,i}$ and edges from stores goes to $s_{g,i}$. Also, create edges $(s_{c,i},s_{i})$ and $(s_{g,i},s_{i})$.

We are only thinking about cash backs, but there could also be discounts. It is fairly rare to see discounts, especially for companies that sell other gift cards. The difference between cash back and discount is when you obtain your money back. Cash back you get your money back after the transaction. For discounts, you pay less.

Adding discounts *fundamentally* changes the problem. In the
min-cost flow formulation, the cost keeps track of cash backs, and
demand is keep track of how much money is spent. This does not work when
there are discounts.

Instead, we have to venture into generalized flow. There is an extra factor of $γ$ on each edge, such that the flow going in is $1$, then the flow going out is $γ$.

Anyway, one thing I learned is using credit cards to buy gift cards from grocery store (Amex Gold) or staples (using Chase Ink Cash) are amazing. Netting you large discounts on many vendors you usually cannot get a huge discount for.

Some more interesting things to add. Buying gift cards from grocery stores can obtain fuel points. Fuel points translate to discounts on gas. However, there is only so much gas one can use (unless you selling it to others). So one can view grocery stores as having a higher discount up to a certain limit. This can also be modeled in the graph.