# Class MarketImpact1

java.lang.Object
dev.nm.solver.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.SOCPPortfolioConstraint
dev.nm.solver.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.MarketImpact1
All Implemented Interfaces:
Function<Vector,Double>, RealScalarFunction

public class MarketImpact1 extends SOCPPortfolioConstraint
Constructs the constraint coefficient arrays of a market impact term in the compact form. The constraint is generated during the transformation of the objective function.

This market impact term in the objective function takes this form: $\sum_{j=1}^n\left(m_j |x_j|^{\frac{3}{2}}\right)\leq t_2.$ Let $$\bar{x}=|x|$$, the market impact term is transformed into: $\sum_{j=1}^n\left( m_{j}\bar{x}_{j}^{\frac{3}{2}}\right)\leq t_2$ By introducing variables $$y=x+w^{0}$$, $$\alpha$$ and $$\beta$$, the above inequality is equivalent to: $\sum\beta_{j}\leq t_{2}\\ |y_{j}-w_{j}^{0}|\leq\bar{x}_{j}\;j=1,\cdots,n\\ m_{j}\bar{x}_{j}^{\frac{3}{2}}\leq \beta_{j}\;j=1,\cdots,n\\$ These constraints can be further transformed into: $\sum_{j=1}^{n}\beta_{j}\leq t_{2}\\ y_{j}-w_{j}^{0}\leq\bar{x}_{j},\; j =1,\cdots, n\\ -y_{j}+w_{j}^{0}\leq \bar{x}_{j},\; j=1,\cdots,n\\ \bar{x}_{j}^{\frac{3}{2}}\leq \frac{\beta_{j}}{m_{j}},\; j=1,\cdots,n\\$ Therefore we have: $||0||_{2}\leq t_{2}-\sum_{j=1}^{n}\beta_{j}\\ ||0||_{2}\leq\bar{x}_{j}-(y_{j}-w_{j}^{0}),\; j =1,\cdots, n\\ ||0||_{2}\leq \bar{x}_{j}-(-y_{j}+w_{j}^{0}),\; j=1,\cdots,n\\ \bar{x}_{j}^{\frac{3}{2}}\leq \frac{\beta_{j}}{m_{j}},\;j=1,\cdots,n.$ The last term, $$\bar{x}_{j}^{\frac{3}{2}}\leq \frac{\beta_{j}}{m_{j}}$$, is equivalent to: $\bar{x}_{j}^{\frac{3}{2}}\leq \frac{\beta_{j}}{m_{j}},\;\bar{x}_{j}\geq 0\Longleftrightarrow \bar{x}_{j}^2\leq s_{j} \frac{\beta_{j}}{m_{j}},\; s_{j}\leq \sqrt{\bar{x}_{j}},\;\bar{x}_{j}\geq0,\; s_{j}\geq 0\;, \frac{\beta_{j}}{m_{j}}\geq0 \Longleftrightarrow\\ \bar{x}_{j}^2\leq s_{j} \frac{\beta_{j}}{m_{j}},\; s_{j}^{2} \leq \bar{x}_{j},\;\bar{x}_{j}\geq0,\; s_{j}\geq 0\;, \frac{\beta_{j}}{m_{j}}\geq 0 \Longleftrightarrow\\ \bar{x}_{j}^2+\left(\frac{\beta_{j}}{2m_{j}}-\frac{s_{j}}{2}\right)^2\leq \left(\frac{\beta_{j}}{2m_{j}}+\frac{s_{j}}{2}\right)^2,\;s_{j}^{2}+\left(\frac{1-\bar{x}_{j}}{2}\right)^2\leq \left(\frac{1+\bar{x}_{j}}{2}\right)^2,\;\bar{x}_{j}\geq0,\;s_{j}\geq 0\;, \frac{\beta_{j}}{m_{j}}\geq 0.$ Because $$\bar{x}_{j}\geq0,\;s_{j}\geq 0\;, \frac{\beta_{j}}{m_{j}}\geq 0$$ can be deduced from other constraints, they can be deleted from the system of constraints. The constraints deduced from $$\bar{x}_{j}^{\frac{3}{2}}\leq \frac{\beta_{j}}{m_{j}}$$ can be written as: $||\left(\begin{array}{c}\bar{x}_{j}\\\frac{\beta_{j}}{2m_{j}}-\frac{s_{j}}{2}\end{array}\right)||_{2}\leq\frac{\beta_{j}}{2m_{j}}+\frac{s_{j}}{2},j=1,\cdots,n,\\ ||\left(\begin{array}{c}s_{j}\\\frac{1-\bar{x}_{j}}{2}\end{array}\right)||_{2}\leq\frac{1+\bar{x}_{j}}{2},j=1,\cdots,n.$ Combine all the constraints together, the system of constraints for market impact is: $||0||_{2}\leq t_{2}-\sum_{j=1}^{n}\beta_{j},\\ ||0||_{2}\leq\bar{x}_{j}-(y_{j}-w_{j}^{0}), \;j =1,\cdots, n,\\ ||0||_{2}\leq \bar{x}_{j}-(-y_{j}+w_{j}^{0}),\; j=1,\cdots,n,\\ ||\left(\begin{array}{c}\bar{x}_{j}\\\frac{\beta_{j}}{m_{j}}-\frac{s_{j}}{2}\end{array}\right)||_{2}\leq\frac{\beta_{j}}{m_{j}}+\frac{s_{j}}{2},\;j=1,\cdots,n,\\ ||\left(\begin{array}{c}s_{j}\\\frac{1-\bar{x}_{j}}{2}\end{array}\right)||_{2}\leq\frac{1+\bar{x}_{j}}{2},\;j=1,\cdots,n.$ The standard SOCP form of the constraints are: $||0||_{2}\leq t_{2}-\sum_{j=1}^{n}\beta_{j} \Longleftrightarrow ||A_{1}^{\top}z+C_{1}||_{1}\leq b^{\top}_{1}z+d_{1}\\ A_{1}^{\top}=0_{1\times n},\; C_{1}=0,\; b_{1}=\left(\begin{array}{c}-1_{n\times 1}\\1\end{array}\right),\; d_{1}=0,\; z=\left(\begin{array}{c}\beta\\t_{2}\end{array}\right).$ $||0||_{2}\leq\bar{x}_{j}-(y_{j}-w_{j}^{0}) \Longleftrightarrow ||A_{2,j}^{\top}z+C_{2,j}||_{2}\leq b^{\top}_{2,j}z+d_{2,j},\quad j=1,\cdots,n\\ A_{2,j}^{\top}=0_{1\times 2n},\; C_{2,j}=0,\; b_{2,j}=\left(\begin{array}{c}-e_{j}\\e_{j}\end{array}\right),\; d_{2,j}=w_{j}^{0},\; z=\left(\begin{array}{c}y\\\bar{x}\end{array}\right),$ where $$e_{j}$$ is a $$n$$ dimensional vector whose $$j$$-th entry is $$1$$ and all the other entries are $$0$$. $||0||_{2}\leq\bar{x}_{j}-(-y_{j}+w_{j}^{0}) \Longleftrightarrow ||A_{3,j}^{\top}z+C_{3,j}||_{2}\leq b^{\top}_{3,j}z+d_{3,j},\quad j=1,\cdots,n\\ A_{3,j}^{\top}=0_{1\times 2n},\; C_{3,j}=0,\; b_{3,j}=\left(\begin{array}{c}e_{j}\\e_{j}\end{array}\right),\; d_{3,j}=-w_{j}^{0},\; z=\left(\begin{array}{c}y\\\bar{x}\end{array}\right).$ $||\left(\begin{array}{c}\bar{x}_{j}\\\frac{\beta_{j}}{2m_{j}}-\frac{s_{j}}{2}\end{array}\right)||_{2}\leq\frac{\beta_{j}}{2m_{j}}+\frac{s_{j}}{2}\Longleftrightarrow ||A_{4,j}^{\top}z+C_{4,j}||_{2}\leq b^{\top}_{4,j}z+d_{4,j},\quad j=1,\cdots,n\\ A_{4,j}^{\top}=\left(\begin{array}{ccc}e_{j}^{\top}invalid input: '&'0_{1\times n}invalid input: '&'0_{1\times n}\\0_{1\times n}invalid input: '&'\frac{1}{2m_{j}}e_{j}^{\top}invalid input: '&' -\frac{1}{2}e_{j}^{\top}\end{array}\right),\; C_{4,j}=0_{2 \times 1},\; b_{4,j}=\left(\begin{array}{c}0_{n\times 1} \\\frac{1}{2m_{j}}e_{j}\\\frac{1}{2}e_{j}\end{array}\right),\; d_{4,j}=0,\; z=\left(\begin{array}{c}\bar{x}\\\beta_{j}\\s\end{array}\right).$ $||\left(\begin{array}{c}s_{j}\\\frac{1-\bar{x}_{j}}{2}\end{array}\right)||_{2}\leq\frac{1+\bar{x}_{j}}{2}\Longleftrightarrow ||A_{5,j}^{\top}z+C_{5,j}||_{2}\leq b^{\top}_{5,j}z+d_{5,j},\quad j=1,\cdots,n\\ A_{5,j}^{\top}=\left(\begin{array}{ccc}0_{1\times n}invalid input: '&e_'{j}^{\top}\\-\frac{1}{2}e_{j}^{\top}invalid input: '&'0_{1\times n}\end{array}\right),\; C_{5,j}=\left(\begin{array}{c}0\\\frac{1}{2}\end{array}\right),\; b_{5,j}=\left(\begin{array}{c}\frac{1}{2}e_{j}\\0_{n\times 1}\end{array}\right),\; d_{5,j}=\frac{1}{2},\; z=\left(\begin{array}{c}\bar{x}\\s\end{array}\right).$
• "Section 2.1, Modeling market impact, http://mosek.com/fileadmin/reports/tech/portfolio.pdf"

## Nested classes/interfaces inherited from class dev.nm.solver.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.SOCPPortfolioConstraint

SOCPPortfolioConstraint.ConstraintViolationException, SOCPPortfolioConstraint.Variable

## Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function

Function.EvaluationException
• ## Constructor Summary

Constructors
Constructor
Description
MarketImpact1(Vector w_0, Vector m)
Constructs a market impact term.
• ## Method Summary

Modifier and Type
Method
Description
boolean
areAllConstraintsSatisfied(Vector y)
Checks whether all SOCP constraints represented by this portfolio constraint are satisfied.
int
dimensionOfDomain()
Get the number of variables the function has.
int
dimensionOfRange()
Get the dimension of the range space of the function.
Double
evaluate(Vector y)
Evaluate the function f at x, where x is from the domain.

### Methods inherited from class dev.nm.solver.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.SOCPPortfolioConstraint

generalConstraints, getVariables, linearEqualities, linearInequalities, newSOCPGeneralConstraints, newSOCPLinearEqualities, newSOCPLinearInequalities

### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ## Constructor Details

• ### MarketImpact1

public MarketImpact1(Vector w_0, Vector m)
Constructs a market impact term.
Parameters:
w_0 - the initial position
m - the market impact parameter
• ## Method Details

• ### areAllConstraintsSatisfied

public boolean areAllConstraintsSatisfied(Vector y) throws SOCPPortfolioConstraint.ConstraintViolationException
Checks whether all SOCP constraints represented by this portfolio constraint are satisfied. The constraint generated by objective function to find the optimal solution. It cannot be "violated".
Specified by:
areAllConstraintsSatisfied in class SOCPPortfolioConstraint
Parameters:
y - a portfolio solution or allocation; the asset weights
Returns:
true if and only if all SOCP constraints are satisfied
Throws:
SOCPPortfolioConstraint.ConstraintViolationException
• ### evaluate

public Double evaluate(Vector y)
Description copied from interface: Function
Evaluate the function f at x, where x is from the domain.
Parameters:
y - x
Returns:
f(x)
• ### dimensionOfDomain

public int dimensionOfDomain()
Description copied from interface: Function
Get the number of variables the function has. For example, for a univariate function, the domain dimension is 1; for a bivariate function, the domain dimension is 2.
Returns:
the number of variables
• ### dimensionOfRange

public int dimensionOfRange()
Description copied from interface: Function
Get the dimension of the range space of the function. For example, for a Rn->Rm function, the dimension of the range is m.
Returns:
the dimension of the range