CONOPT
Loading...
Searching...
No Matches

Providing the matrix information and initial values to CONOPT.

The call back routine ReadMatrix described in this section defines the structure of the model. It is a mandatory routine that must be registered with conopt::coidef_readmatrix() defined above before CONOPT is started. CONOPT will call ReadMatrix as the first routine (except for calls of Message). During this call, the modeller must provide the matrix that corresponds to the problem instance. It is recommended that the modeller follows the these steps:

  1. Define the variables. This involves specifying the lower and upper bounds (LOWER and UPPER respectively), an initial solution value (CURR), and an initial variable status (VSTA). The modeller must take note of the array indices that correspond to the model variables. These indices are used when specifying the structure of the matrix and Hessian.
  2. Define the constraints. The constraints are defined by specifying the type (TYPE)—either equality, greater than or equal, or less than or equal—the right hand side of the constraint (RHS), and the initial status of the constraint slack variables (ESTA). It is important to note that CONOPT only accepts one-sided constraints. As such, range constraints must be added by providing both sides of the constraint separately.
  3. Define the matrix. This is the most important part of the ReadMatrix callback, since it defines the instance that will be solved. The matrix is provided to CONOPT in a column-oriented format with the arrays COLSTA, ROWNO, NLFLAG and VALUE.
    • COLSTA has a length of the number of variables. Each element i corresponds to the index j in ROWNO, VALUE and NLFLAG (the same index for all) that is the start of the non-zeros for variable i.
    • ROWNO has a length of the number of non-zeros. These are the row numbers for the non-zeros of the columns.
    • VALUE has a length of the number of non-zeros. These are the non-zero coefficients for the columns in the matrix.
    • NLFLAG has a length of the number of non-zeros. This is a flag that is set to 1 to indicate whether the column is in a nonlinear expression in the corresponding row. This is 0 by default. If the NLFLAG is set to 1, then the corresponding entry in VALUE is ignored.

As an example of specifying the matrix, consider column 2 that has 4 non-zeros. These are in rows 2, 4, 7, 8. The non-zeros in rows 2 and 7 are 0.5 and 1.6 respectively. Column 2 is in a nonlinear expression in rows 4 and 8. In this example, let column 1 have 5 non-zeros in the matrix. Then,

If there is a third variable, then COLSTA[3] = 10.

Regarding the specification of nonlinear expressions in the matrix, consider the row

\[a_1 x_1 + a_2 x_2 + a_3 x_3 + a_4 x_3^2 + a_5 x_4 x_5. \]

The NLFLAG for variables \(x_1\) and \(x_2\) are set to 0, and the NLFLAG for \(x_3\), \(x_4\) and \(x_5\) are set to 1. Even though \(x_3\) is also in a linear term, the linear term is considered part of the nonlinear expression containing \(x_3\). This definition of the nonlinear expressions is important when performing the evaluation in the FDEval callback.

The Tutorial and Examples using CONOPT provided with the Library show several methods for specifying a model instance using the ReadMatrix callback.


ReadMatrix – Read Matrix

Attention
Mandatory callback routine.
Integer Function ReadMatrix( LOWER, CURR, UPPER, VSTA, &
TYPE, RHS, ESTA, COLSTA &
ROWNO, VALUE, NLFLAG, &
N, M, NZ, USRMEM )
INTEGER, Intent (IN) :: N, M, NZ
INTEGER, Dimension(N), Intent(IN OUT) :: VSTA
INTEGER, Dimension(M), Intent(IN OUT) :: TYPE, ESTA
INTEGER, Dimension(N+1),Intent(IN OUT) :: COLSTA
INTEGER, Dimension(NZ), Intent(IN OUT) :: ROWNO, NLFLAG
REAL*8, Dimension(N), Intent(IN OUT) :: LOWER, CURR, UPPER
REAL*8, Dimension(M), Intent(IN OUT) :: RHS
REAL*8, Dimension(NZ), Intent(IN OUT) :: VALUE
REAL*8, Intent(IN OUT) :: USRMEM(*)

where:



The lower bounds in LOWER must be less than or equal to the upper bounds in UPPER. Some of the bounds may be -INF or +INF, which are the bounds CONOPT assigns by default. If a bound is infinite, the user should normally not change the corresponding entry in LOWER or UPPER. If it is more convenient for the modeler to assign a value representing infinity it should be done using the values that are present in LOWER and UPPER when ReadMatrix is called, for example taken from the first element before any assignments are done. As an alternative, you may define the numerical value of Infinity to be used by the solution algorithm in option RTMAXV and store the same value in UPPER and -RTMAXV in LOWER.

The values in CURR, both those defined by the modeler and those defined by default, are without warning moved to the nearest bound if they are outside the bounds.

Note
CONOPT assumes that all functions are defined for all values of the variables between their bounds. CONOPT will never attempt to evaluate the functions in points outside the bounds specified by LOWER and UPPER.