@Demo public class SOCPMarkowitzComparisonDemo extends Object
We assume that the last index of w is in the black list.max r*w-q*w'*Sigma*w s.t. sum(w)=1, w_i=1 for i in the black list.
Using this example. Compares quadratic and second-order-cone formulations using the same inputs and constraints. Numerical solver tolerances can produce different weights; inspect the existing TODO about correlated inputs rather than assuming universal agreement.
Model and publication. Related theory and the scope of this example are distinguished below.
Implementation in this tutorial. Compares QP and SOCP representations under the configured constraints and data. Equality of mathematical formulations does not imply bit-identical numerical solutions; inspect the existing correlated-input TODO and solver tolerances.
| Constructor and Description |
|---|
SOCPMarkowitzComparisonDemo(int n,
dev.nm.algebra.linear.vector.doubles.Vector r_bar,
dev.nm.algebra.linear.matrix.doubles.Matrix Sigma,
double riskAverseCoeff) |
| Modifier and Type | Method and Description |
|---|---|
dev.nm.algebra.linear.vector.doubles.Vector |
getMarkowitzSolution() |
dev.nm.algebra.linear.vector.doubles.Vector |
getSOCPSolution() |
double |
getUtilityValue(dev.nm.algebra.linear.vector.doubles.Vector x)
Computes the utility value given the optimal weights.
|
static void |
main(String[] args) |
static dev.nm.algebra.linear.matrix.doubles.Matrix |
randomNormalReturnMatrix(int N,
int T)
Generates a random return matrix, whose entries follow the standard
Normal distribution.
|
public SOCPMarkowitzComparisonDemo(int n,
dev.nm.algebra.linear.vector.doubles.Vector r_bar,
dev.nm.algebra.linear.matrix.doubles.Matrix Sigma,
double riskAverseCoeff)
public dev.nm.algebra.linear.vector.doubles.Vector getSOCPSolution()
throws Exception
Exceptionpublic dev.nm.algebra.linear.vector.doubles.Vector getMarkowitzSolution()
throws dev.nm.solver.multivariate.constrained.convex.sdp.socp.qp.QPInfeasible
dev.nm.solver.multivariate.constrained.convex.sdp.socp.qp.QPInfeasiblepublic double getUtilityValue(dev.nm.algebra.linear.vector.doubles.Vector x)
x - the optimal weightspublic static dev.nm.algebra.linear.matrix.doubles.Matrix randomNormalReturnMatrix(int N,
int T)
N - the number of stocksT - the number of observationsCopyright © 2026. All rights reserved.