FNLMath : Optimization : MPS_FREE
MPS_FREE
Deallocates the space allocated for the IMSL derived type s_MPS. This routine is usually used in conjunction with READ_MPS.
Required Arguments
MPS — A structure of IMSL defined derived type s_MPS containing the data read from the MPS file. (Input/Output)
The allocated components of s_MPS will be deallocated on output.
The IMSL defined derived type s_MPS consists of the following components:
Component
Description
character, allocatable :: filename
Name of the MPS file.
character (len=8) name
Name of the problem.
integer nrows
Number of rows in the constraint matrix.
integer ncolumns
Number of columns in the constraint matrix. This is also the number of variables.
integer nonzeros
Number of non-zeros in the constraint matrix.
integer nhessian
Number of non-zeros in the Hessian matrix. If zero, then there is no Hessian matrix.
integer ninteger
Number of variables required to be integer. This includes binary variables.
integer nbinary
Number of variables required to be binary (0 or 1).
real (kind(1e0)), allocatable :: objective(:)
A real array of length ncolumns containing the objective vector.
type (s_SparseMatrixElement), allocatable :: constraint(:)
A derived type array of length nonzeros and of type s_SparseMatrixElement containing the sparse matrix representation of the constraint matrix. See below for details.
type(s_SparseMatrixElement), allocatable :: hessian(:)
A derived type array of length nhessian and of type s_SparseMatrixElement containing the sparse matrix representation of the Hessian matrix. If nhessian is zero, then this field is not allocated.
real (kind(1e0)), allocatable ::lower_range(:)
A real array of length nrows containing the lower constraint bounds. If a constraint is unbounded below, the corresponding entry in lower_range is set to negative_infinity, defined below.
real (kind(1e0)), allocatable ::upper_range(:)
A real array of length nrows containing the upper constraint bounds. If a constraint is unbounded above, the corresponding entry in upper_range is set to positive_infinity, defined below.
real (kind(1e0)), allocatable :: lower_bound(:)
A real array of length ncolumns containing the lower variable bounds. If a variable is unbounded below, the corresponding entry in lower_bound is set to negative_infinity, defined below.
real (kind(1e0)), allocatable :: upper_bound(:)
A real array of length ncolumns containing the upper variable bounds. If a variable is unbounded above, the corresponding entry in upper_bound is set to positive_infinity, defined below.
integer, allocatable :: variable_type(:)
An integer array of length ncolumns containing the type of each variable. Variable types are:
 
0
Continous
 
1
Integer
 
2
Binary (0 or 1)
 
3
Semicontinuous
character (len=8) name_objective
Name of the set in ROWS used for the objective row.
character (len=8) name_rhs
Name of the RHS set used.
character (len=8) name_ranges
Name of the RANGES set used or the empty string if no RANGES section in the file.
character (len=8) name_bounds
Name of the BOUNDS set used or the empty string if no BOUNDS section in the file.
character (len=8), allocatable :: name_row(:)
Array of length nrows containing the row names. The name of the i-th constraint row is name_row(i).
character (len=8), allocatable :: name_column(:)
Array of length ncolumns containing the column names. The name of the i-th column and variable is name_column(i).
real (kind (1e0)) positive_infinity
Value used for a constraint or bound upper limit when the constraint or bound is unbounded above. This can be set using an optional argument. Default is 1.0e+30.
real (kind (1e0)) negative_infinity
Value used for a constraint or bound lower limit when the constraint or bound is unbounded below. This can be set using an optional argument. Default is -1.0e+30.
This derived type stores the constraint and Hessian matrices in a simple sparse matrix format of derived type s_SparseMatrixElement defined in the interface module mp_types. s_SparseMatrixElement consists of three components; a row index, a column index, and a value. For each non-zero element in the constraint and Hessian matrices an element of derived type s_SparseMatrixElement is stored The following code fragment expands the sparse constraint matrix of the derived type s_SparseMatrixElement contained in mps, a derived type of type s_MPS, into a dense matrix:
 
! allocate a matrix
integer nr = mps%nrows
integer nc = mps%ncolumns
real (kind(1e0)), allocatable :: matrix(:,:)
allocate(matrix(nr,nc))
 
matrix = 0.0e0
! expand the sparse matrix
do k = 1, mps%nonzeros
      i = mps%constraint(k)%row
      j = mps%constraint(k)%column
      matrix(i,j) = mps%constraint(k)%value
end do
The IMSL derived type d_MPS is the double precision counterpart to s_MPS. The IMSL derived type d_SparseMatrixElement is the double precision counterpart to s_SparseMatrixElement.
FORTRAN 90 Interface
Generic: CALL MPS_FREE (MPS)
Specific: The specific interface names are S_MPS_FREE and D_MPS_FREE.
Description
This subroutine simply issues deallocate statements for each of the arrays allocated in the IMSL derived type s_MPS defined above. It is supplied as a convenience utility to the user of READ_MPS.
Example
In the following example, the space that had been allocated to accommodate the IMSL derived type S_MPS is deallocated with a call to MPS_FREE after a call to READ_MPS was made.
 
use read_mps_int
use mps_free_int
implicit none
 
TYPE(S_MPS) mps
CALL read_mps ('test.mps', mps)
.
.
.
call mps_free (mps)
end
Published date: 03/19/2020
Last modified date: 03/19/2020