Class SOCPNoTradingList1
- java.lang.Object
-
- dev.nm.solver.multivariate.constrained.convex.sdp.socp.problem.portfoliooptimization.SOCPPortfolioConstraint
-
- tech.nmfin.portfoliooptimization.socp.constraints.SOCPNoTradingList1
-
- All Implemented Interfaces:
Function<Vector,Double>
,RealScalarFunction
public class SOCPNoTradingList1 extends SOCPPortfolioConstraint
Transforms a black list (not to trade a new position) constraint into the compact SOCP form. The black list constraint is: \[ x_{j}=0, \] for j in the black list. By letting \(y=x+w^{0}\), the black list constraint are changed to: \[ y_{j}=w^{0}_{j}, \] for j in the black list. Denote the black list index set as \(BL\), i.e. \(BL=\{j|x_{j}=0\}\). As \(y_{j}=x_{j}+w_{j}^{0}\), the set \(BL\) can be written as \(BL=\{j|y_{j}=w_{j}^{0}\}\). The black list constraints can be written in the following form: \[ ||D_{BL}(y-w^{0})||_{2}\leq0, \] where \(D_{BL}\) is a diagonal matrix. The \(k\)th diagonal entry of \(D_{BL}\), \(D_{BL}(k,k)\), is \(1\) if \(k\in BL\), otherwise it is \(0\). The constraint can be transformed into the standard SOCP form: \[ ||D_{BL}(y-w^{0})||_{2}\leq0\Longleftrightarrow ||A_{1}^{\top}z+C_{1}||_{2}\leq b^{\top}_{1}z+d_{1}\\ A_{1}^{\top}=D_{BL},\; C_{1}=-D_{BL}\times w^{0},\; b_{1}=0_{n\times 1},\; d_{1}=0,\; z=y. \]- See Also:
- "Reformulate the Portfolio Optimization Problem as a Second Order Cone Programming Problem, Version 7."
-
-
Nested Class Summary
-
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 SOCPNoTradingList1(Vector w_0, Matrix D_BL0)
Constructs a black list constraint.SOCPNoTradingList1(Vector w_0, Matrix D_BL0, double epsilon)
Constructs a black list constraint.SOCPNoTradingList1(Vector w_0, Vector bl)
Constructs a black list constraint.
-
Method Summary
All Methods Instance Methods Concrete Methods 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 x)
Note:x
here is the trading size, not the position. 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
-
-
-
-
Constructor Detail
-
SOCPNoTradingList1
public SOCPNoTradingList1(Vector w_0, Matrix D_BL0, double epsilon)
Constructs a black list constraint.- Parameters:
w_0
- the initial positionD_BL0
- the black list matrixepsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0
-
SOCPNoTradingList1
public SOCPNoTradingList1(Vector w_0, Vector bl)
Constructs a black list constraint.- Parameters:
w_0
- the initial positionbl
- the black list vector; (1 means blacklisted; 0 otherwise)
-
-
Method Detail
-
areAllConstraintsSatisfied
public boolean areAllConstraintsSatisfied(Vector y) throws SOCPPortfolioConstraint.ConstraintViolationException
Description copied from class:SOCPPortfolioConstraint
Checks whether all SOCP constraints represented by this portfolio constraint are satisfied.- Specified by:
areAllConstraintsSatisfied
in classSOCPPortfolioConstraint
- 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 x)
Note:x
here is the trading size, not the position. Evaluate the function f at x, where x is from the domain.- Parameters:
x
- trading size- Returns:
- constraint value
-
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
-
-