public void toStandardForm(DoubleMatrix1D originalC,
			DoubleMatrix2D originalG, DoubleMatrix1D originalH, 
			DoubleMatrix2D originalA, DoubleMatrix1D originalB,
			DoubleMatrix1D originalLB, DoubleMatrix1D originalUB){
		
		this.F1 = (useSparsity)? DoubleFactory1D.sparse : DoubleFactory1D.dense;
		this.F2 = (useSparsity)? DoubleFactory2D.sparse : DoubleFactory2D.dense;
		
		this.originalN = originalC.size();
		if(originalLB != null && originalUB !=null){
			if(originalLB.size() != originalUB.size()){
				throw new IllegalArgumentException("lower and upper bounds have different size");
			}
		}
		if(originalLB==null){
			//there are no lb, that is they are all unbounded
			originalLB = F1.make(originalN, unboundedLBValue);
		}
		if(originalUB==null){
			//there are no ub, that is they are all unbounded
			originalUB = F1.make(originalN, unboundedUBValue);
		}
		
		if(originalG==null && !strictlyStandardForm){
			//nothing to convert
			this.standardN = originalN;
			this.standardA = originalA;
			this.standardB = originalB;
			this.standardC = originalC;
			this.standardLB = originalLB;
			this.standardUB = originalUB;
			return;
		}
		
		//definition of the elements
		int nOfSlackG = (originalG!=null)? originalG.rows() : 0;//number of slack variables given by G
		int nOfSlackUB = 0;//number of slack variables given by the upper bounds
		int nOfSplittedVariables = 0;//number of variables to split, x = xPlus-xMinus with xPlus and xMinus positive
		int nOfSlackLB = 0;//number of slack variables given by the lower bounds
		lbSlack = new boolean[originalN];
		ubSlack = new boolean[originalN];
		
		if(strictlyStandardForm){
			//record the variables that need the split x = xPlus-xMinus
			for(int i=0; i<originalN; i++){
				double lbi = originalLB.getQuick(i);
				double ubi = originalUB.getQuick(i);
				if(isLbUnbounded(lbi)){
					//no slack (no row in the final A) but split the variable
					//we have lb[i] = -oo, so must split this variable (because it is not forced to be non negative)
					splittedVariablesList.add(splittedVariablesList.size(), i);
				}else{
					int lbCompare = Double.compare(lbi, 0.);
					if(lbCompare < 0){
						//this inequality must become an equality
						nOfSlackLB++;
						lbSlack[i] = true;
						//slackLBVariablesList.add(slackLBVariablesList.size(), i);
						//we have lb[i] < 0, so must split this variable (because it is not forced to be non negative)
						splittedVariablesList.add(splittedVariablesList.size(), i);  
					}else if(lbCompare > 0){
						//we have lb[i] > 0, and this must become a row in the standardA matrix (standard lb limits are all = 0)
						nOfSlackLB++;
						lbSlack[i] = true;
						//slackLBVariablesList.add(slackLBVariablesList.size(), i);
					}
				}
				if(!isUbUnbounded(ubi)){
					//this lb must become a row in the standardA matrix (there are no standard ub limits)
					nOfSlackUB++;
					ubSlack[i] = true;
					//slackUBVariablesList.add(slackUBVariablesList.size(), i);
				}
			}
			nOfSplittedVariables = splittedVariablesList.size();
			//nOfSlackLB = slackLBVariablesList.size();
			//nOfSlackUB = slackUBVariablesList.size();
		}
		
		//The first step: introduce slack variables s[i] for all the inequalities
		this.standardS = nOfSlackG + nOfSlackUB + nOfSlackLB;
		this.standardN = standardS + originalN + nOfSplittedVariables;
		if(standardS==0 && nOfSplittedVariables==0){
			standardA = originalA;
			standardB = originalB;
			standardC = originalC;
			standardLB = originalLB;
			standardUB = originalUB;
		}else{
			//we must build a final A matrix that is different from the original
			
			//standardA = (useSparsity)? new SparseDoubleMatrix2D(standardS + A.rows(), standardN) : F2.make(standardS + A.rows(), standardN);
			if(originalA!=null){
				standardA = F2.make(standardS + originalA.rows(), standardN);
				standardB = F1.make(standardS + originalB.size());
			}else{
				standardA = F2.make(standardS, standardN);
				standardB = F1.make(standardS);
			}
			
			//filling with original G values
			for(int i=0; i<nOfSlackG; i++){
				standardA.set(i, i, 1);//slack variable position
				standardB.setQuick(i, originalH.getQuick(i));
			}
			if(originalG instanceof SparseDoubleMatrix2D){
				originalG.forEachNonZero(new IntIntDoubleFunction() {
					@Override
					public double apply(int i, int j, double gij) {
						standardA.set(i, standardS + j, gij);
						return gij;
					}
				});
			}else{
				for(int i=0; i<nOfSlackG; i++){
					for(int j=0; j<originalN; j++){
						standardA.set(i, standardS + j, originalG.getQuick(i, j));
					}
				}
			}
			
			//filling for the lower and upper bounds
			int cntSlackLB = 0;
			int cntSlackUB = 0;
			for(int i=0; i<originalN; i++ ){
				if(lbSlack[i]){
					standardA.set(nOfSlackG + cntSlackLB, nOfSlackG + cntSlackLB, 1);//slack variable position
					standardA.set(nOfSlackG + cntSlackLB, standardS + i,  -1);
					standardB.setQuick(nOfSlackG + cntSlackLB, -originalLB.getQuick(i));
					cntSlackLB++;
				}
				if(ubSlack[i]){
					standardA.set(nOfSlackG + nOfSlackLB + cntSlackUB, nOfSlackG + nOfSlackLB + cntSlackUB, 1);//slack variable position
					standardA.set(nOfSlackG + nOfSlackLB + cntSlackUB, standardS + i,  1);
					standardB.setQuick(nOfSlackG + nOfSlackLB + cntSlackUB, originalUB.getQuick(i));
					cntSlackUB++;
				}
			}
			
//			//filling for LB slack variables
//			for(int sv=0; sv<nOfSlackLB; sv++ ){
//				int i = slackLBVariablesList.get(sv);
//				standardA.set(nOfSlackG + nOfSlackUB + sv, nOfSlackG + nOfSlackUB + sv, 1);//slack variable position
//				standardA.set(nOfSlackG + nOfSlackUB + sv, standardS + i, -1);
//				standardB.setQuick(nOfSlackG + nOfSlackUB + sv, -lb.getQuick(i));
//			}
			
			//filling with original A values
			for(int i=0; originalA!=null && i<originalA.rows(); i++){
				for(int j=0; j<originalN; j++){
					standardA.set(standardS + i, standardS + j, originalA.get(i, j));//@TODO: implementation for sparse G
				}
				standardB.setQuick(standardS + i, originalB.getQuick(i));
			}
			
			//filling for splitted variables
			cntSlackLB = 0;
			cntSlackUB = 0;
			int previousSplittedVariables = 0;
			for(int sv=0; sv<nOfSplittedVariables; sv++ ){
				int i = splittedVariablesList.get(sv);
				//variable i was splitted
				for(int r=0; r<nOfSlackG; r++){//n of rows of G
					standardA.set(r, standardS + originalN + sv, -originalG.getQuick(r, i));
				}
				
				if(lbSlack[i]){
					for(int k=previousSplittedVariables; k<i; k++){
						if(lbSlack[k]){
							//for this lb we have a row (and a slack variable) in the standard A
							cntSlackLB++;
						}
					}
					standardA.set(nOfSlackG + cntSlackLB, standardS + originalN + sv, 1);//lower bound
				}
				
				if(ubSlack[i]){
					for(int k=previousSplittedVariables; k<i; k++){
						if(ubSlack[k]){
							//for this ub we have a row (and a slack variable) in the standard A
							cntSlackUB++;
						}
					}
					standardA.set(nOfSlackG + nOfSlackLB + cntSlackUB, standardS + originalN + sv, -1);//upper bound
				}
				
				previousSplittedVariables = i;
				
				//standardA.set(nOfSlackG + nOfSlackUB + pos-1, standardS + originalN + sv, 1);//lower bound
				for(int r=0; originalA!=null && r<originalA.rows(); r++){
					standardA.set(standardS + r, standardS + originalN + sv, -originalA.get(r, i));
				}
			}
			
			standardC = F1.make(standardN);
			standardLB = F1.make(standardN);
			standardUB = F1.make(standardN, unboundedUBValue);//the slacks are upper unbounded
			for(int i=0; i<originalN; i++){
				standardC.setQuick(standardS + i, originalC.getQuick(i));
			}
			for(int i=0; i<standardS; i++){
				standardLB.setQuick(i, 0.);
			}
			for(int i=0; i<originalN; i++){
				standardLB.setQuick(standardS + i, originalLB.getQuick(i));
			}
			for(int i=0; i<originalN; i++){
				standardUB.setQuick(standardS + i, originalUB.getQuick(i));
			}
		}
		
		if(strictlyStandardForm){
			standardLB = F1.make(standardN, 0.);//brand new lb
			standardUB = null;//no ub for the strictly standard form 
		}
	}
public void toStandardForm ( DoubleMatrix1D originalC , DoubleMatrix2D originalG , DoubleMatrix1D originalH , DoubleMatrix2D originalA , DoubleMatrix1D originalB , DoubleMatrix1D originalLB , DoubleMatrix1D originalUB ) { this . F1 = ( useSparsity ) ? DoubleFactory1D . sparse : DoubleFactory1D . dense ; this . F2 = ( useSparsity ) ? DoubleFactory2D . sparse : DoubleFactory2D . dense ; this . originalN = originalC . size ( ) ; if ( originalLB != null && originalUB != null ) { if ( originalLB . size ( ) != originalUB . size ( ) ) { throw new IllegalArgumentException ( "lower and upper bounds have different size" ) ; } } if ( originalLB == null ) { originalLB = F1 . make ( originalN , unboundedLBValue ) ; } if ( originalUB == null ) { originalUB = F1 . make ( originalN , unboundedUBValue ) ; } if ( originalG == null && ! strictlyStandardForm ) { this . standardN = originalN ; this . standardA = originalA ; this . standardB = originalB ; this . standardC = originalC ; this . standardLB = originalLB ; this . standardUB = originalUB ; return ; } int nOfSlackG = ( originalG != null ) ? originalG . rows ( ) : 0 ; int nOfSlackUB = 0 ; int nOfSplittedVariables = 0 ; int nOfSlackLB = 0 ; lbSlack = new boolean [ originalN ] ; ubSlack = new boolean [ originalN ] ; if ( strictlyStandardForm ) { for ( int i = 0 ; i < originalN ; i ++ ) { double lbi = originalLB . getQuick ( i ) ; double ubi = originalUB . getQuick ( i ) ; if ( isLbUnbounded ( lbi ) ) { splittedVariablesList . add ( splittedVariablesList . size ( ) , i ) ; } else { int lbCompare = Double . compare ( lbi , 0. ) ; if ( lbCompare < 0 ) { nOfSlackLB ++ ; lbSlack [ i ] = true ; splittedVariablesList . add ( splittedVariablesList . size ( ) , i ) ; } else if ( lbCompare > 0 ) { nOfSlackLB ++ ; lbSlack [ i ] = true ; } } if ( ! isUbUnbounded ( ubi ) ) { nOfSlackUB ++ ; ubSlack [ i ] = true ; } } nOfSplittedVariables = splittedVariablesList . size ( ) ; } this . standardS = nOfSlackG + nOfSlackUB + nOfSlackLB ; this . standardN = standardS + originalN + nOfSplittedVariables ; if ( standardS == 0 && nOfSplittedVariables == 0 ) { standardA = originalA ; standardB = originalB ; standardC = originalC ; standardLB = originalLB ; standardUB = originalUB ; } else { if ( originalA != null ) { standardA = F2 . make ( standardS + originalA . rows ( ) , standardN ) ; standardB = F1 . make ( standardS + originalB . size ( ) ) ; } else { standardA = F2 . make ( standardS , standardN ) ; standardB = F1 . make ( standardS ) ; } for ( int i = 0 ; i < nOfSlackG ; i ++ ) { standardA . set ( i , i , 1 ) ; standardB . setQuick ( i , originalH . getQuick ( i ) ) ; } if ( originalG instanceof SparseDoubleMatrix2D ) { originalG . forEachNonZero ( new IntIntDoubleFunction ( ) { @ Override public double apply ( int i , int j , double gij ) { standardA . set ( i , standardS + j , gij ) ; return gij ; } } ) ; } else { for ( int i = 0 ; i < nOfSlackG ; i ++ ) { for ( int j = 0 ; j < originalN ; j ++ ) { standardA . set ( i , standardS + j , originalG . getQuick ( i , j ) ) ; } } } int cntSlackLB = 0 ; int cntSlackUB = 0 ; for ( int i = 0 ; i < originalN ; i ++ ) { if ( lbSlack [ i ] ) { standardA . set ( nOfSlackG + cntSlackLB , nOfSlackG + cntSlackLB , 1 ) ; standardA . set ( nOfSlackG + cntSlackLB , standardS + i , - 1 ) ; standardB . setQuick ( nOfSlackG + cntSlackLB , - originalLB . getQuick ( i ) ) ; cntSlackLB ++ ; } if ( ubSlack [ i ] ) { standardA . set ( nOfSlackG + nOfSlackLB + cntSlackUB , nOfSlackG + nOfSlackLB + cntSlackUB , 1 ) ; standardA . set ( nOfSlackG + nOfSlackLB + cntSlackUB , standardS + i , 1 ) ; standardB . setQuick ( nOfSlackG + nOfSlackLB + cntSlackUB , originalUB . getQuick ( i ) ) ; cntSlackUB ++ ; } } for ( int i = 0 ; originalA != null && i < originalA . rows ( ) ; i ++ ) { for ( int j = 0 ; j < originalN ; j ++ ) { standardA . set ( standardS + i , standardS + j , originalA . get ( i , j ) ) ; } standardB . setQuick ( standardS + i , originalB . getQuick ( i ) ) ; } cntSlackLB = 0 ; cntSlackUB = 0 ; int previousSplittedVariables = 0 ; for ( int sv = 0 ; sv < nOfSplittedVariables ; sv ++ ) { int i = splittedVariablesList . get ( sv ) ; for ( int r = 0 ; r < nOfSlackG ; r ++ ) { standardA . set ( r , standardS + originalN + sv , - originalG . getQuick ( r , i ) ) ; } if ( lbSlack [ i ] ) { for ( int k = previousSplittedVariables ; k < i ; k ++ ) { if ( lbSlack [ k ] ) { cntSlackLB ++ ; } } standardA . set ( nOfSlackG + cntSlackLB , standardS + originalN + sv , 1 ) ; } if ( ubSlack [ i ] ) { for ( int k = previousSplittedVariables ; k < i ; k ++ ) { if ( ubSlack [ k ] ) { cntSlackUB ++ ; } } standardA . set ( nOfSlackG + nOfSlackLB + cntSlackUB , standardS + originalN + sv , - 1 ) ; } previousSplittedVariables = i ; for ( int r = 0 ; originalA != null && r < originalA . rows ( ) ; r ++ ) { standardA . set ( standardS + r , standardS + originalN + sv , - originalA . get ( r , i ) ) ; } } standardC = F1 . make ( standardN ) ; standardLB = F1 . make ( standardN ) ; standardUB = F1 . make ( standardN , unboundedUBValue ) ; for ( int i = 0 ; i < originalN ; i ++ ) { standardC . setQuick ( standardS + i , originalC . getQuick ( i ) ) ; } for ( int i = 0 ; i < standardS ; i ++ ) { standardLB . setQuick ( i , 0. ) ; } for ( int i = 0 ; i < originalN ; i ++ ) { standardLB . setQuick ( standardS + i , originalLB . getQuick ( i ) ) ; } for ( int i = 0 ; i < originalN ; i ++ ) { standardUB . setQuick ( standardS + i , originalUB . getQuick ( i ) ) ; } } if ( strictlyStandardForm ) { standardLB = F1 . make ( standardN , 0. ) ; standardUB = null ; } }
Transforms the problem from a general form to the (quasi) standard LP form.

@param originalLB if null, all lower bounds default to this.unspecifiedLBValue
@param originalUB if null, all upper bounds default to this.unspecifiedUBValue

@see Converting LPs to standard form, "Convex Optimization", p 147