Class QPConstraintMatrix
- All Implemented Interfaces:
AnyMatrix,RealLinearOperator,RealMatrix,Blendable<RealMatrix>
The represented matrix has the form:
A = [ Ae ]
[ Ai ]
[ Ab ]
[ -Ab ]
where each constraint gradient is stored as a row. The class keeps only
references to the original equality, inequality and bounded-constraint
matrices. In particular, the upper-bound block -Ab is generated on
demand and is never stored.
The global row ordering is:
- equality constraints,
- inequality constraints,
- lower bounded constraints,
- upper bounded constraints.
The matrix is intentionally read-only. Calling copy() creates a
physical independent matrix, but normal solver operations such as
getEntry(int, int), getRowVector(int) and
operate(RealVector) do not materialize the global matrix.
-
Constructor Summary
ConstructorsConstructorDescriptionQPConstraintMatrix(int variableCount, RealMatrix equalityMatrix, RealMatrix inequalityMatrix, RealMatrix boundedMatrix) Build a row-oriented virtual QP constraint matrix. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Materialize an independent deep copy.createMatrix(int rowDimension, int columnDimension) Create an independent physical matrix for results of generic operations.intReturns the number of columns of this matrix.doublegetEntry(int row, int column) Get a coefficient without constructing the global matrix.double[]getRow(int row) Get a constraint gradient as an array.intReturns the number of rows of this matrix.getRowVector(int row) Get a constraint gradient as a row vector.Evaluate all linear constraint expressions A x.voidsetEntry(int row, int column, double value) This view is read-only.Methods inherited from class org.hipparchus.linear.AbstractRealMatrix
add, addToEntry, copySubMatrix, copySubMatrix, equals, getColumn, getColumnMatrix, getColumnVector, getData, getFrobeniusNorm, getRowMatrix, getSubMatrix, getSubMatrix, getTrace, hashCode, isSquare, multiply, multiplyEntry, operate, power, preMultiply, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, subtract, toString, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hipparchus.linear.RealLinearOperator
isTransposable, operateTransposeMethods inherited from interface org.hipparchus.linear.RealMatrix
blendArithmeticallyWith, getNorm1, getNormInfty, map, mapToSelf, multiplyTransposed, transposeMultiply
-
Constructor Details
-
QPConstraintMatrix
public QPConstraintMatrix(int variableCount, RealMatrix equalityMatrix, RealMatrix inequalityMatrix, RealMatrix boundedMatrix) Build a row-oriented virtual QP constraint matrix.- Parameters:
variableCount- number of primal variablesequalityMatrix- equality matrix, ornullinequalityMatrix- inequality matrix, ornullboundedMatrix- bounded-expression matrix, ornull
-
-
Method Details
-
getRowDimension
public int getRowDimension()Returns the number of rows of this matrix.- Specified by:
getRowDimensionin interfaceAnyMatrix- Specified by:
getRowDimensionin interfaceRealLinearOperator- Specified by:
getRowDimensionin classAbstractRealMatrix- Returns:
- the number of rows.
-
getColumnDimension
public int getColumnDimension()Returns the number of columns of this matrix.- Specified by:
getColumnDimensionin interfaceAnyMatrix- Specified by:
getColumnDimensionin interfaceRealLinearOperator- Specified by:
getColumnDimensionin classAbstractRealMatrix- Returns:
- the number of columns.
-
getEntry
public double getEntry(int row, int column) Get a coefficient without constructing the global matrix.- Specified by:
getEntryin interfaceRealMatrix- Specified by:
getEntryin classAbstractRealMatrix- Parameters:
row- global constraint indexcolumn- primal-variable index- Returns:
- coefficient A[row, column]
-
getRowVector
Get a constraint gradient as a row vector.The backing Hipparchus matrix already returns an independent vector. For an upper bound that same newly allocated vector is negated in place, avoiding an additional vector allocation.
- Specified by:
getRowVectorin interfaceRealMatrix- Overrides:
getRowVectorin classAbstractRealMatrix- Parameters:
row- global constraint index- Returns:
- constraint gradient
-
getRow
public double[] getRow(int row) Get a constraint gradient as an array.- Specified by:
getRowin interfaceRealMatrix- Overrides:
getRowin classAbstractRealMatrix- Parameters:
row- global constraint index- Returns:
- independent coefficient array
-
operate
Evaluate all linear constraint expressions A x.Each physical backing block is multiplied only once. The product of the bounded matrix is reused for both the lower and upper blocks, with opposite signs.
- Specified by:
operatein interfaceRealLinearOperator- Specified by:
operatein interfaceRealMatrix- Overrides:
operatein classAbstractRealMatrix- Parameters:
x- primal vector- Returns:
- A x
-
setEntry
public void setEntry(int row, int column, double value) This view is read-only.- Specified by:
setEntryin interfaceRealMatrix- Specified by:
setEntryin classAbstractRealMatrix- Parameters:
row- Row index of entry to be set.column- Column index of entry to be set.value- the new value of the entry.
-
createMatrix
Create an independent physical matrix for results of generic operations.- Specified by:
createMatrixin interfaceRealMatrix- Specified by:
createMatrixin classAbstractRealMatrix- Parameters:
rowDimension- the number of rows in the new matrixcolumnDimension- the number of columns in the new matrix- Returns:
- a new matrix of the same type as the instance
-
copy
Materialize an independent deep copy.- Specified by:
copyin interfaceRealMatrix- Specified by:
copyin classAbstractRealMatrix- Returns:
- matrix copy
-