Assign least upper bound to variable for piecewise linear function in Linear Programming

96 Views Asked by At

Here I am trying to calculate the US capital gains tax $(cgt)$ using a piecewise linear function, $f(x) = max(f1(x), f2(x), f3(x)))$. One sub-function for each of the tax brackets. US tax law defines the low bracket value as starting with the amount of taxable income (ordinary income) and going to taxable income $(ti)$ + capital gains $(cg)$. So I am trying to set capital gains tax as so:

$$cgt = f(ti+cg) - f(ti)$$

However, because the object function is for after tax income $(ti+cg-taxes)$ taxes are reduced in the model when appropriate. And since there is no upper bound on $f(x)$, $f(ti)$ is increased to match $f(ti+cg)$ rendering $cgt$ as zero.

Given this I am trying to place an upper bound on $f(x)$ that matches $max(f1(x), f2(x), f3(x))$. I have only a simplex optimizer (No Integer) so I have tried to copy the effects of having binary variables without them.

Here is how I have gone about it: $f(ti+cg)$ is getting the correct value so leave it as is. Next, define a set of variables to indicate which of the tax brackets ti is in. To do this I use $x_0$, $x_1$ and $x_2$ as the bracket start values defined by the IRS (0, 77200, 479000 for married filing jointly).

$$v_0 \ge x_2 - ti $$ $$v_1 \ge x_2 - x_3 + ti$$ $$v_2 \ge ti - x_3$$

$v_0$ is positive if ti is in the first bracket and zero otherwise. $v_1$ is positive if ti is in the second or third brackets otherwise zero and $v_2$ is positive only when $ti$ is in the third bracket. Originally I wanted for $v_i$ to only indicate information about the $i^{th}$ bracket but I didn't see quite how to do that.

With these defined, I define a set of $\delta_i$ variables to function like binary variables as much as possible. They should be between zero and one inclusively.

$$\delta_i \le v_i*100$$

$$\delta_i \le 1$$

If $v_i$ was $0$, $\delta_i$ will also be zero. If $v_i$ is positive, $\delta_i$ will be positive and each value more than 1 cent $(*100)$ is greater than one pushing $\delta_i$ to be one. Here I am thinking that I can have an area where the binary characteristic fails but is only 1 cent wide. If this reasoning makes sense then $1/10^{th}$ of a cent may be more appropriate.

$$f(ti+cg) \ge m_1*(ti+cg) + yintercpt_1$$ $$f(ti+cg) \ge m_2*(ti+cg) + yintercpt_2$$ $$f(ti+cg) \ge m_3*(ti+cg) + yintercpt_3$$

So the variable represented by $f(ti+cg)$ gets the $max$ of the piecewise linear function.

$$f(ti) \ge m_1*(ti) + yintercpt_1$$

$$f(ti) \ge m_2*(ti) + yintercpt_2$$

$$f(ti) \ge m_3*(ti) + yintercpt_3$$

$$f(ti) \le m_1*(ti) + yintercpt_1 + M(1-\delta_1)$$

$$f(ti) \le m_2*(ti) + yintercpt_2 + M(1-\delta_2 +\delta_3)$$

$$f(ti) \le m_3*(TI) + yintercpt_3 + M(1-\delta_3)$$

Here I intend for the variable represented by $f(ti)$ to get the max of the piecewise linear function and have this also be the least upper bound by using the $\delta_i$ variables to either remove $M$ for the segment with the actual $max$ or leave $M$ so that no upper bound is imposed by the constraint.

$$cgt \ge f(ti+cg) - f(ti)$$

However, at present I am getting $cgt$ equal to zero because $f(ti+cg)$ is equal to $f(ti)$. This is the same as was happening before I added all the complicating constrains to try to force $f(ti)$ to its least upper bound.

I know that I can put $f(ti)$ into the object function but this causes it to be minimized witch actually lowers after tax money (it is really a bit more complicated than this) by lowering taxes a bit more so that the combination of these is higher.

Any ideas on what I might be doing wrong? Does this make sense? Are there other ways to accomplish the goal (correctly calculating $cgt$)