# Difference between revisions of "Optimization with absolute values"

Authors: Matthew Chan (mdc297), Yilian Yin (yy896), Brian Amado (ba392), Peter (pmw99), Dewei Xiao (dx58) - SYSEN 5800 Fall 2020

Steward: Fengqi You

## Introduction

Absolute values can make it relatively difficult to determine the optimal solution when handled without first converting to standard form. This conversion of the objective function is a good first step in solving optimization problems with absolute values. As a result, one can go on to solve the problem using linear programing techniques.

## Method

### Defining Absolute Values

An absolute value of a real number can be described as its distance away from zero, or the non-negative magnitude of the number. Thus,

${\displaystyle \displaystyle |x|={\begin{cases}-x,&{\text{if }}x<0\\x,&{\text{if }}x\geq 0\end{cases}}}$

Absolute values can exist in linear optimization problems in two primary instances: in constraints and in the objective function.

### Absolute Values in Constraints

Within constraints, absolute value relations can be transformed into one of the following forms:

${\displaystyle \displaystyle |X|=0}$

${\displaystyle \displaystyle |X|\leq C}$

${\displaystyle \displaystyle |X|\geq C}$

Where ${\displaystyle \textstyle X}$ is a linear combination (${\displaystyle \textstyle ax_{1}+bx_{2}+...}$ where ${\displaystyle \textstyle a,b}$ are constants) and ${\displaystyle \textstyle C}$ is a constant ${\displaystyle \textstyle >0}$.

#### Form when ${\displaystyle \displaystyle |X|=0}$

In this form, the only possible solution is if ${\displaystyle \displaystyle X=0}$ simplifying the constraint. Note that this solution also occurs if the constraint is in the form ${\displaystyle \displaystyle |X|\leq 0}$ due to the same conclusion that the only possible solution is ${\displaystyle \textstyle X=0}$.

#### Form when ${\displaystyle \displaystyle |X|\leq C}$

The second form a linear constraint can exist in is ${\displaystyle \displaystyle |X|\leq C}$. In this case, an equivalent feasible solution can be described by splitting the constraint into two:

${\displaystyle \displaystyle X\leq C}$

${\displaystyle \displaystyle -X\leq C}$

The solution can be understood visually since ${\displaystyle \textstyle X}$ must lie between ${\displaystyle \textstyle -C}$ and ${\displaystyle \textstyle C}$, as shown below:

#### Form when ${\displaystyle \displaystyle |X|\geq C}$

Visually, the solution space for the last form is the complement of the second solution above, resulting in the following representation:

In expression form, the solutions can be written as:

${\displaystyle \displaystyle X\geq C}$

${\displaystyle \displaystyle -X\geq C}$

As seen visually, the feasible region has a gap and thus non-convex. The expressions also make it impossible for both to simultaneously hold true. This means that it is not possible to transform constraints in this form to linear equations.

An approach to reach a solution for this particular case exists in the form of Mixed-Integer Linear Programming, where only one of the equations above is “active”.

The inequality can be reformulated into the following:

${\displaystyle \displaystyle X+N*Y\geq C}$

${\displaystyle \displaystyle -X+N*(1-Y)\geq C}$

${\displaystyle \displaystyle Y=0,1}$

With this new set of constraints, a large constant ${\displaystyle \textstyle N}$ is introduced, along with a binary variable ${\displaystyle \textstyle Y}$. So long as ${\displaystyle \textstyle N}$ is sufficiently larger than the upper bound of ${\displaystyle \textstyle X+C}$, the large constant multiplied with the binary variable ensures that one of the constraints must be satisfied. For instance, if ${\displaystyle \textstyle Y=0}$, the new constraints will resolve to:

${\displaystyle \displaystyle X\geq C}$

${\displaystyle \displaystyle -X+N\geq C}$

Since ${\displaystyle \textstyle N}$ is sufficiently large, the latter constraint will always be satisfied, leaving only one relation active: ${\displaystyle \textstyle X\geq C}$. Functionally, this allows for the XOR logical operation of ${\displaystyle \textstyle X\geq C}$ and ${\displaystyle \textstyle -X\geq C}$.

### Absolute Values in Objective Functions

In objective functions, to leverage transformations of absolute functions, all constraints must be linear.

Similar to the case of absolute values in constraints, there are different approaches to the reformation of the objective function, depending on the satisfaction of sign constraints. The satisfaction of sign constraints is when the coefficient signs of the absolute terms must all be either:

• Positive for a minimization problem
• Negative for a maximization problem

#### Sign Constraints are Satisfied

At a high level, the transformation works similarly to the second case of absolute value in constraints – aiming to bound the solution space for the absolute value term with a new variable, ${\displaystyle \textstyle Z}$.

If ${\displaystyle \textstyle |X|}$ is the absolute value term in our objective function, two additional constraints are added to the linear program:

${\displaystyle \displaystyle X\leq Z}$

${\displaystyle \displaystyle -X\leq Z}$

The ${\displaystyle \textstyle |X|}$ term in the objective function is then replaced by ${\displaystyle \textstyle Z}$, relaxing the original function into a collection of linear constraints.

#### Sign Constraints are Not Satisfied

In order to transform problems where the coefficient signs of the absolute terms do not fulfill the conditions above, a similar conclusion is reached to that of the last case for absolute values in constraints – the use of integer variables is needed to reach an LP format.

The following constraints need to be added to the problem:

${\displaystyle \displaystyle X+N*Y\geq Z}$

${\displaystyle \displaystyle -X+N*(1-Y)\geq Z}$

${\displaystyle \displaystyle X\leq Z}$

${\displaystyle \displaystyle -X\leq Z}$

${\displaystyle \displaystyle Y=0,1}$

Again, ${\displaystyle \textstyle N}$ is a large constant, ${\displaystyle \textstyle Z}$ is a replacement variable for ${\displaystyle \textstyle |X|}$ in the objective function, and ${\displaystyle \textstyle Y}$ is a binary variable. The first two constraints ensure that one and only one constraint is active while the other will be automatically satisfied, following the same logic as above. The third and fourth constraints ensure that ${\displaystyle \textstyle Z}$ must be equal to ${\displaystyle \textstyle |X|}$ and has either a positive or negative value. For instance, for the case of ${\displaystyle \textstyle Y=0}$, the new constraints will resolve to:

${\displaystyle \displaystyle X\geq Z}$

${\displaystyle \displaystyle -X+N\geq Z}$

${\displaystyle \displaystyle X\leq Z}$

${\displaystyle \displaystyle -X\leq Z}$

As ${\displaystyle \textstyle N}$ is sufficiently large (${\displaystyle \textstyle N}$ must be at least ${\displaystyle \textstyle 2|X|}$ for this approach), the second constraint must be satisfied. Since ${\displaystyle \textstyle Z}$ is non-negative, the fourth constraint must also be satisfied. The remaining constraints, ${\displaystyle \textstyle X\geq Z}$ and ${\displaystyle \textstyle X\leq Z}$ can only be satisfied when ${\displaystyle \textstyle Z=X}$ and is of non-negative signage. Together, these constraints will allow for the selection of the largest ${\displaystyle \textstyle |X|}$ for maximization problems (or smallest for minimization problems).

## Numerical Example

• Example when all sign constraints are satisfied

{\displaystyle {\begin{aligned}\min {2|x_{1}|+3|x_{2}|+|x_{3}|}\\s.t.x_{1}+2x_{2}-3x_{3}\leq 8\\2x_{1}-x_{2}+4x_{3}=14\end{aligned}}}

The absolute value quantities will be replaced with single variables:

${\displaystyle |x_{1}|=U_{1}}$

${\displaystyle |x_{2}|=U_{2}}$

${\displaystyle |x_{3}|=U_{3}}$

We must introduce additional constraints to ensure we do not lose any information by doing this substitution:

${\displaystyle -U_{1}\leq x_{1}\leq U_{1}}$

${\displaystyle -U_{2}\leq x_{2}\leq U_{2}}$

${\displaystyle -U_{3}\leq x_{3}\leq U_{3}}$

The problem has now been reformulated as a linear programming problem that can be solved normally:

{\displaystyle {\begin{aligned}\min {2U_{1}+3U_{2}+U_{3}}\\s.t.x_{1}+2x_{2}-3x_{3}\leq 8\\2x_{1}-x_{2}+4x_{3}=14\\-U_{1}\leq x_{1}\leq U_{1}\\-U_{2}\leq x_{2}\leq U_{2}\\-U_{3}\leq x_{3}\leq U_{3}\end{aligned}}}

The optimum value for the objective function is ${\displaystyle 3.5}$, which occurs when ${\displaystyle x_{1}=0}$ and ${\displaystyle x_{2}=0}$ and ${\displaystyle x_{3}=3.5}$.

• Example when some sign constraints are not satisfied

{\displaystyle {\begin{aligned}\min {2|x_{1}|+3|x_{2}|-|x_{3}|}\\s.t.x_{1}+2x_{2}-3x_{3}\leq 8\\2x_{1}-x_{2}+4x_{3}=14\end{aligned}}}

The absolute value quantities will be replaced with single variables:

${\displaystyle |x_{1}|=U_{1}}$

${\displaystyle |x_{2}|=U_{2}}$

${\displaystyle |x_{3}|=U_{3}}$

We must introduce additional constraints to ensure we do not lose any information by doing this substitution:

${\displaystyle -U_{1}\leq x_{1}\leq U_{1}}$

${\displaystyle -U_{2}\leq x_{2}\leq U_{2}}$

${\displaystyle x_{3}+M*Y\geq U_{3}}$

${\displaystyle -x_{3}+M*(1-Y)\geq U_{3}}$

${\displaystyle x_{3}\leq U_{3}}$

${\displaystyle -x_{3}\leq U_{3}}$

${\displaystyle Y=0,1}$

The problem has now been reformulated as a linear programming problem that can be solved normally:

{\displaystyle {\begin{aligned}\min {2U_{1}+3U_{2}-U_{3}}\\s.t.x_{1}+2x_{2}-3x_{3}\leq 8\\2x_{1}-x_{2}+4x_{3}=14\\-U_{1}\leq x_{1}\leq U_{1}\\-U_{2}\leq x_{2}\leq U_{2}\\x_{3}+M*Y\geq U_{3}\\-x_{3}+M*(1-Y)\geq U_{3}\\x_{3}\leq U_{3}\\-x_{3}\leq U_{3}\\Y=0,1\end{aligned}}}

The optimum value for the objective function is ${\displaystyle -3.5}$, which occurs when ${\displaystyle x_{1}=0}$ and ${\displaystyle x_{2}=0}$ and ${\displaystyle x_{3}=3.5}$.

## Applications

There are no specific applications to Optimization with Absolute Values however it is necessary to account for at times when utilizing the simplex method.

Consider the problem Ax=b; max z= x c,jx,i. This problem cannot, in general, be solved with the simplex method. The problem has a simplex method solution (with unrestricted basis entry) only if c, are nonpositive (non-negative for minimizing problems).

The primary application of absolute-value functionals in linear programming has been for absolute-value or L(i)-metric regression analysis. Such application is always a minimization problem with all C(j) equal to 1 so that the required conditions for valid use of the simplex method are met.

By reformulating the original problem into a Mixed-Integer Linear Program (MILP), in most case we should be able to use GAMS/Pyomo/JuliaOPT to solve the problem.

• Application in Financial: Portfolio Selection

Under this topic, the same tricks played in the Numerical Example section to perform Reduction to a Linear Programming Problem will be applied here again, to reform the problem into a MILP in order to solve the problem. An example is given as below.

A portfolio is determined by what fraction of one's assets to put into each investment. It can be denoted as a collection of nonnegative numbers xj, where j = 1, 2,...,n. Because each xj stands for a portion of the assets, it sums to one. In order to get a highest reward through finding a right mix of assets, let ${\displaystyle \mu }$, the positive parameter, denote the importance of risk relative to the return, and Rj denote the return in the next time period on investment j, j = 1, 2,..., n. The total return one would obtain from the investment is ${\displaystyle R=\sum _{j}\!x_{j}\!R_{j}}$. The expected return is ${\displaystyle \mathbb {E} \!R=\sum _{j}\!x_{j}\mathbb {E} \!R_{j}}$. And the Mean Absolute Deviation from the Mean (MAD) is ${\displaystyle \mathbb {E} \left\vert \!R-\mathbb {E} \!R\right\vert =\mathbb {E} \left\vert \sum _{j}\!x_{j}{\tilde {R}}_{j}\right\vert }$.

maximize ${\textstyle \mu \sum _{j}\!x_{j}\mathbb {E} \!R_{j}-\mathbb {E} \left\vert \sum _{j}\!x_{j}{\tilde {R}}_{j}\right\vert }$

subject to ${\displaystyle \sum _{j}\!x_{j}=1}$

${\displaystyle x_{j}\geq 0}$ ${\displaystyle j=1,2,..n.}$

where ${\displaystyle {\tilde {R}}_{j}=\!R_{j}-\mathbb {E} \!R_{j}}$

Very obviously, this problem is not a linear programming problem yet. Similar to the numerical example showed above, the right thing to do is to replace each absolute value with a new variable and impose inequality constraints to ensure that the new variable is the appropriate absolute value once an optimal value is obtained. To simplify the program, an average of the historical returns can be taken in order to get the mean expected return: ${\displaystyle r_{j}=\mathbb {E} \!R_{j}=\left({\frac {1}{T}}\right)\sum _{t=1}^{T}\!R_{j}(t)}$. Thus the objective function is turned into: ${\displaystyle \mu \sum _{j}\!x_{j}\!r_{j}-\left({\frac {1}{T}}\right)\sum _{t=1}^{T}\left\vert \sum _{j}\!x_{j}{\bigl (}R_{j}(t)-\!r_{j}{\bigr )}\right\vert }$

Now, replace ${\displaystyle \left\vert \sum _{j}\!x_{j}{\bigl (}R_{j}(t)-\!r_{j}{\bigr )}\right\vert }$ with a new variable ${\displaystyle y_{t}}$and thus the problem can be rewrote as:

maximize ${\displaystyle \mu \sum _{j}\!x_{j}\!r_{j}-\left({\frac {1}{T}}\right)\sum _{t=1}^{T}\!y_{t}}$

subject to ${\displaystyle -\!y_{t}\leq \sum _{j}\!x_{j}{\bigl (}R_{j}(t)-\!r_{j}{\bigr )}\leq y_{t}}$. t = 1, 2,...,T

where ${\displaystyle \sum _{j}\!x_{j}=1}$

${\displaystyle x_{j}\geq 0}$. j = 1, 2,...,n

${\displaystyle y_{t}\geq 0}$. t = 1, 2,...,T

So finally, after some simplifications methods and some tricks applied, the original problem is converted into a linear programming which is easier to be solved further.

## Conclusion

The presence of an absolute value within the objective function prevents the use of certain optimization methods. Solving these problems requires that the function be manipulated in order to continue with linear programming techniques like the simplex method.

## References

1. "Absolute Values." lp_solve, http://lpsolve.sourceforge.net/5.1/absolute.htm. Accessed 20 Nov. 2020.
2. Optimization Methods in Management Science / Operations Research. Massachusetts Institute of Technology, Spring 2013, https://ocw.mit.edu/courses/sloan-school-of-management/15-053-optimization-methods-in-management-science-spring-2013/tutorials/MIT15_053S13_tut04.pdf. Accessed 20 Nov. 2020.