# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.finance.trading.portfoliooptimization.socp.constraints

## Class SOCPSectorNeutrality

• All Implemented Interfaces:
Function<Vector,Double>, RealScalarFunction, Iterable<SOCPGeneralConstraints>

public class SOCPSectorNeutrality
extends SOCPPortfolioConstraint
Transforms a sector neutral constraint into the compact SOCP form.

The sector neutral constraint is: $\sum_{j\in S_i}(w_j^0+x_j)=0,\quad i=1,\ldots,k,$ where $$S_i$$ is the $$i$$th section indicator. By letting $$y=x+w^{0}$$, the sector neutral constraint can be written as: $\sum_{j\in S_i}y_{j}=0, i=1,\cdots,k.$ And it is equivalent to: $||(\sum_{j\in S_{i}}e_{j})^{\top}y||_{2}\leq 0.$ As a result the standard SOCP form of the sector neutral constraint can be written as: $||(\sum_{j\in S_{i}}e_{j})^{\top}y||_{2}\leq 0\Longleftrightarrow ||A_{i}^{\top}z+C_{i}||_{2}\leq b^{\top}_{i}z+d_{i},\quad i=1,\cdots,k\\ A_{i}^{\top}=\sum_{j\in S_{i}}e^{\top}_{j},\; C_{i}=0,\; b_{i}=0_{n\times 1},\; d_{i}=0,\; z=y.$
See Also:
"Reformulate the Portfolio Optimization Problem as a Second Order Cone Programming Problem, Version 7."

• ### Nested classes/interfaces inherited from class com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.SOCPPortfolioConstraint

SOCPPortfolioConstraint.ConstraintViolationException, SOCPPortfolioConstraint.Variable
• ### Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.Function

Function.EvaluationException
• ### Constructor Summary

Constructors
Constructor and Description
SOCPSectorNeutrality(Vector w_0, Vector[] S)
Constructs a sector neutral constraint.
SOCPSectorNeutrality(Vector w_0, Vector[] S, double epsilon)
Constructs a sector neutral constraint.
• ### Method Summary

All Methods
Modifier and Type Method and Description
boolean areAllConstraintsSatisfied(Vector x)
Checks whether all SOCP constraints represented by this portfolio constraint are satisfied.
double bias(Vector y)
Computes the amount of deviation from neutrality, hence bias.
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 com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.SOCPPortfolioConstraint

getVariables, iterator, newSOCPGeneralConstraints
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface java.lang.Iterable

forEach, spliterator
• ### Constructor Detail

• #### SOCPSectorNeutrality

public SOCPSectorNeutrality(Vector w_0,
Vector[] S,
double epsilon)
Constructs a sector neutral constraint.
Parameters:
w_0 - the initial position
S - the sector indicators
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
• #### SOCPSectorNeutrality

public SOCPSectorNeutrality(Vector w_0,
Vector[] S)
Constructs a sector neutral constraint.
Parameters:
w_0 - the initial position
S - the sector indicators
• ### Method Detail

• #### bias

public double bias(Vector y)
Computes the amount of deviation from neutrality, hence bias.
Parameters:
y - the positions
Returns:
the sector bias
• #### areAllConstraintsSatisfied

public boolean areAllConstraintsSatisfied(Vector x)
throws SOCPPortfolioConstraint.ConstraintViolationException
Description copied from class: SOCPPortfolioConstraint
Checks whether all SOCP constraints represented by this portfolio constraint are satisfied.
Specified by:
areAllConstraintsSatisfied in class SOCPPortfolioConstraint
Parameters:
x - 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

Copyright © 2010-2018 Numerical Method Incorporation Limited. All Rights Reserved.