org.akutan.optimization
Class ActiveSetSolver

java.lang.Object
  extended by org.akutan.optimization.ActiveSetSolver
Direct Known Subclasses:
ReturnSolver, StateReturnSolver, UtilitySolver

public class ActiveSetSolver
extends java.lang.Object


Field Summary
protected  java.text.DecimalFormat df
           
 
Constructor Summary
ActiveSetSolver()
           
 
Method Summary
protected  boolean algorithm(java.util.List<Constraint> constraints, java.util.Set<java.lang.Integer> equality, java.util.Set<java.lang.Integer> active, java.util.Set<java.lang.Integer> inactive, cern.colt.matrix.DoubleMatrix1D g, cern.colt.matrix.DoubleMatrix2D Vx, cern.colt.matrix.DoubleMatrix1D x, int n)
           
protected  void dumpConstraints(java.util.List<Constraint> constraints, java.util.Set<java.lang.Integer> equality, java.util.Set<java.lang.Integer> active, java.util.Set<java.lang.Integer> inactive)
          Dump out the constraints to System.out in the format Constraint : {E | I} {A | I | X | M} constraint details Each constraint is either equality or inequality Each constraint is either active, inactive, both = error, or missing
protected  java.lang.String formatOutput(int ct, double ra, cern.colt.matrix.DoubleMatrix1D x, cern.colt.matrix.DoubleMatrix1D e_r, cern.colt.matrix.DoubleMatrix2D V)
           
protected  cern.colt.matrix.DoubleMatrix2D generateConstraints(java.util.List<Constraint> c, java.util.Set<java.lang.Integer> e, java.util.Set<java.lang.Integer> a)
          Called to generate the A matrix for the constraints from the list of constraints in the problem and the sets of equality and active constraints.
protected  cern.colt.matrix.DoubleMatrix1D generateValues(java.util.List<Constraint> c, java.util.Set<java.lang.Integer> e, java.util.Set<java.lang.Integer> a)
          Called to populate the b vector for the constraints (Ax = b) given the total list of constraints and sets of equality and active constaints.
protected  cern.colt.matrix.DoubleMatrix1D initialGuess(cern.colt.matrix.DoubleMatrix1D e_r, java.util.List<Constraint> constraints)
          Executes a Simplex optimization on the equality constraints to find a valid initial point for the ActiveSet method.
 cern.colt.matrix.DoubleMatrix2D make2D(cern.colt.matrix.DoubleMatrix1D m)
          Helper function called to convert a 1D matrix into a 2D matrix with a single column.
protected  SolvedPoint makePoint(double ra, cern.colt.matrix.DoubleMatrix1D x, cern.colt.matrix.DoubleMatrix1D e_r, cern.colt.matrix.DoubleMatrix2D Vt)
           
protected  void setMatrix(cern.colt.matrix.DoubleMatrix2D Q, int qx, int qy, cern.colt.matrix.DoubleMatrix1D V, int vx)
           
protected  void setMatrix(cern.colt.matrix.DoubleMatrix2D Q, int qx, int qy, cern.colt.matrix.DoubleMatrix2D V, int vx, int vy)
           
protected  org.akutan.optimization.ActiveSetSolver.Holder solve(cern.colt.matrix.DoubleMatrix1D x, cern.colt.matrix.DoubleMatrix2D G, cern.colt.matrix.DoubleMatrix2D A, cern.colt.matrix.DoubleMatrix1D g, cern.colt.matrix.DoubleMatrix1D b)
          This implements | G -A | | x | = | -(Gx + g) | | At 0 | | lambda | | b |
 cern.colt.matrix.DoubleMatrix1D solveSingle(cern.colt.matrix.DoubleMatrix1D e_rx, cern.colt.matrix.DoubleMatrix2D Vx, java.util.List<Constraint> constraints, java.util.Set<java.lang.Integer> equality, java.util.Set<java.lang.Integer> active, java.util.Set<java.lang.Integer> inactive)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

df

protected java.text.DecimalFormat df
Constructor Detail

ActiveSetSolver

public ActiveSetSolver()
Method Detail

dumpConstraints

protected void dumpConstraints(java.util.List<Constraint> constraints,
                               java.util.Set<java.lang.Integer> equality,
                               java.util.Set<java.lang.Integer> active,
                               java.util.Set<java.lang.Integer> inactive)
Dump out the constraints to System.out in the format Constraint : {E | I} {A | I | X | M} constraint details Each constraint is either equality or inequality Each constraint is either active, inactive, both = error, or missing

Parameters:
constraints -
equality -
active -
inactive -

make2D

public cern.colt.matrix.DoubleMatrix2D make2D(cern.colt.matrix.DoubleMatrix1D m)
Helper function called to convert a 1D matrix into a 2D matrix with a single column.

Parameters:
m - Input vector (1D matrix) to be copied into the matrix.
Returns:
m as a 2D matrix of m.size() rows and 1 column

setMatrix

protected void setMatrix(cern.colt.matrix.DoubleMatrix2D Q,
                         int qx,
                         int qy,
                         cern.colt.matrix.DoubleMatrix2D V,
                         int vx,
                         int vy)

setMatrix

protected void setMatrix(cern.colt.matrix.DoubleMatrix2D Q,
                         int qx,
                         int qy,
                         cern.colt.matrix.DoubleMatrix1D V,
                         int vx)

solve

protected org.akutan.optimization.ActiveSetSolver.Holder solve(cern.colt.matrix.DoubleMatrix1D x,
                                                               cern.colt.matrix.DoubleMatrix2D G,
                                                               cern.colt.matrix.DoubleMatrix2D A,
                                                               cern.colt.matrix.DoubleMatrix1D g,
                                                               cern.colt.matrix.DoubleMatrix1D b)
This implements | G -A | | x | = | -(Gx + g) | | At 0 | | lambda | | b |

Parameters:
x -
G -
A -
g -
b -
Returns:
Holder structure containing the step (delta) and lagrange multiplier values (lambda) for this step.

generateConstraints

protected cern.colt.matrix.DoubleMatrix2D generateConstraints(java.util.List<Constraint> c,
                                                              java.util.Set<java.lang.Integer> e,
                                                              java.util.Set<java.lang.Integer> a)
Called to generate the A matrix for the constraints from the list of constraints in the problem and the sets of equality and active constraints.

Parameters:
c - Total list of constraints
e - Set of equality constraints
a - Set of active constraints
Returns:
A matrix of constraints to be used in solving for the next step

generateValues

protected cern.colt.matrix.DoubleMatrix1D generateValues(java.util.List<Constraint> c,
                                                         java.util.Set<java.lang.Integer> e,
                                                         java.util.Set<java.lang.Integer> a)
Called to populate the b vector for the constraints (Ax = b) given the total list of constraints and sets of equality and active constaints.

Parameters:
c - List of all constraints on the problem.
e - Set of equality constraints.
a - Set of active constraints.
Returns:
b Vector to be used in solving this step.

initialGuess

protected cern.colt.matrix.DoubleMatrix1D initialGuess(cern.colt.matrix.DoubleMatrix1D e_r,
                                                       java.util.List<Constraint> constraints)
Executes a Simplex optimization on the equality constraints to find a valid initial point for the ActiveSet method.

Parameters:
e_r - Vector of asset returns
constraints - List of constraints
Returns:
Vector of initial guess at asset weights. It will be feasible for the constraints on the problem.

solveSingle

public cern.colt.matrix.DoubleMatrix1D solveSingle(cern.colt.matrix.DoubleMatrix1D e_rx,
                                                   cern.colt.matrix.DoubleMatrix2D Vx,
                                                   java.util.List<Constraint> constraints,
                                                   java.util.Set<java.lang.Integer> equality,
                                                   java.util.Set<java.lang.Integer> active,
                                                   java.util.Set<java.lang.Integer> inactive)

algorithm

protected boolean algorithm(java.util.List<Constraint> constraints,
                            java.util.Set<java.lang.Integer> equality,
                            java.util.Set<java.lang.Integer> active,
                            java.util.Set<java.lang.Integer> inactive,
                            cern.colt.matrix.DoubleMatrix1D g,
                            cern.colt.matrix.DoubleMatrix2D Vx,
                            cern.colt.matrix.DoubleMatrix1D x,
                            int n)

makePoint

protected SolvedPoint makePoint(double ra,
                                cern.colt.matrix.DoubleMatrix1D x,
                                cern.colt.matrix.DoubleMatrix1D e_r,
                                cern.colt.matrix.DoubleMatrix2D Vt)

formatOutput

protected java.lang.String formatOutput(int ct,
                                        double ra,
                                        cern.colt.matrix.DoubleMatrix1D x,
                                        cern.colt.matrix.DoubleMatrix1D e_r,
                                        cern.colt.matrix.DoubleMatrix2D V)