protected boolean checkKKTSolutionAccuracy ( DoubleMatrix1D v , DoubleMatrix1D w ) { DoubleMatrix2D KKT = null ; DoubleMatrix1D x = null ; DoubleMatrix1D b = null ; if ( this . A != null ) { if ( this . AT == null ) { this . AT = ALG . transpose ( A ) ; } if ( h != null ) { //H.v + [A]T.w = -g //A.v = -h DoubleMatrix2D [ ] [ ] parts = { { this . H , this . AT } , { this . A , null } } ; if ( H instanceof SparseDoubleMatrix2D && A instanceof SparseDoubleMatrix2D ) { KKT = DoubleFactory2D . sparse . compose ( parts ) ; } else { KKT = DoubleFactory2D . dense . compose ( parts ) ; } x = F1 . append ( v , w ) ; b = F1 . append ( g , h ) . assign ( Mult . mult ( - 1 ) ) ; } else { //H.v + [A]T.w = -g DoubleMatrix2D [ ] [ ] parts = { { this . H , this . AT } } ; if ( H instanceof SparseDoubleMatrix2D && A instanceof SparseDoubleMatrix2D ) { KKT = DoubleFactory2D . sparse . compose ( parts ) ; } else { KKT = DoubleFactory2D . dense . compose ( parts ) ; } x = F1 . append ( v , w ) ; //b = g.copy().assign(Mult.mult(-1)); b = ColtUtils . scalarMult ( g , - 1 ) ; } } else { //H.v = -g KKT = this . H ; x = v ; //b = g.copy().assign(Mult.mult(-1)); b = ColtUtils . scalarMult ( g , - 1 ) ; } //checking residual double scaledResidual = Utils . calculateScaledResidual ( KKT , x , b ) ; return scaledResidual < toleranceKKT ; }
Check the solution of the system