The NLP Procedure

MATRIX Statement

  • MATRIX M_name pattern_definitions;

The MATRIX statement defines a matrix H and the vector g, which can be given in the MINQUAD or MAXQUAD statement. The matrix H and vector g are initialized to zero, so that only the nonzero elements are given. The five different forms of the MATRIX statement are illustrated with the following example:

\[ H = \left[ \begin{array}{rrrr} 100 & 10 & 1 & 0 \\ 10 & 100 & 10 & 1 \\ 1 & 10 & 100 & 10 \\ 0 & 1 & 10 & 100 \\ \end{array} \right] \quad g = \left[ \begin{array}{r} 1 \\ 2 \\ 3 \\ 4 \\ \end{array} \right] \quad c = 0 \]

Each MATRIX statement first names the matrix or vector and then lists its elements. If more than one MATRIX statement is given for the same matrix, the later definitions override the earlier ones.

The rows and columns in matrix H and vector g correspond to the order of decision variables in the DECVAR statement.

  • Full Matrix Definition: The MATRIX statement consists of H_name or g_name followed by an equals sign and all (nonredundant) numerical values of the matrix H or vector g. Assuming symmetry, only the elements of the lower triangular part of the matrix H must be listed. This specification should be used mainly for small problems with almost dense H matrices.

       MATRIX H=  100
                   10 100
                    1  10 100
                    0   1  10 100;
       MATRIX G= 1  2  3  4;
    
  • Band-diagonal Matrix Definition: This form of pattern definition is useful if the H matrix has (almost) constant band-diagonal structure. The MATRIX statement consists of H_name followed by empty brackets $ [,]$, an equals sign, and a list of numbers to be assigned to the diagonal and successive subdiagonals.

       MATRIX H[,]=  100 10 1;
       MATRIX G= 1  2  3  4;
    
  • Sparse Matrix Definitions: In each of the following three specification types, the H_name or g_name is followed by a list of pattern definitions separated by commas. Each pattern definition consists of a location specification in brackets on the left side of an equals sign that is followed by a list of numbers.

    • (Sub)Diagonalwise: This form of pattern definition is useful if the H matrix contains nonzero elements along diagonals or subdiagonals. The starting location is specified by an index pair in brackets $ [i,j]$. The expression $ k * \mi{num}$ on the right-hand side specifies that $ \mi{num}$ is assigned to the elements $ [i,j],\ldots ,[i+k-1,j+k-1]$ in a diagonal direction of the H matrix. The special case $ k=1$ can be used to assign values to single nonzero element locations in H.

         MATRIX H [1,1]= 4 * 100,
                  [2,1]= 3 *  10,
                  [3,1]= 2 *   1;
         MATRIX G [1,1]= 1  2  3  4;
      
    • Columnwise Starting in Diagonal: This form of pattern definition is useful if the H matrix contains nonzero elements columnwise starting in the diagonal. The starting location is specified by only one index j in brackets $ [,j]$. The k numbers at the right-hand side are assigned to the elements $ [j,j],\ldots ,[\min (j+k-1,n),j]$.

         MATRIX H [,1]= 100  10   1,
                  [,2]= 100  10   1,
                  [,3]= 100  10,
                  [,4]= 100;
         MATRIX G [,1]= 1  2  3  4;
      
    • Rowwise Starting in First Column: This form of pattern definition is useful if the H matrix contains nonzero elements rowwise ending in the diagonal. The starting location is specified by only one index i in brackets $ [i,]$. The k numbers at the right-hand side are assigned to the elements $ [i,1],\ldots ,[i,\min (k,i)]$.

         MATRIX H [1,]= 100,
                  [2,]=  10 100,
                  [3,]=   1  10 100,
                  [4,]=   0   1  10 100;
         MATRIX G [1,]= 1  2  3  4;