NAG FL Interfacee04rxf (handle_​set_​get_​real)

▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

1Purpose

e04rxf is a part of the NAG optimization modelling suite. It allows a piece of real information to be read from or written to the problem stored in the handle. For example, it may be used to extract the current approximation of the solution during a monitoring step.

2Specification

Fortran Interface
 Subroutine e04rxf ( rarr,
 Integer, Intent (In) :: ioflag Integer, Intent (Inout) :: lrarr, ifail Real (Kind=nag_wp), Intent (Inout) :: rarr(lrarr) Character (*), Intent (In) :: cmdstr Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04rxf_ (void **handle, const char *cmdstr, const Integer *ioflag, Integer *lrarr, double rarr[], Integer *ifail, const Charlen length_cmdstr)
The routine may be called by the names e04rxf or nagf_opt_handle_set_get_real.

3Description

e04rxf adds an additional means of communication to routines within the NAG optimization modelling suite. It allows you to either read or write a piece of information in the handle in the form of a real array. The item is identified by cmdstr and the direction of the communication is set by ioflag.
The following cmdstr are available:
Primal Variables or X
The current value of the primal variables.
Dual Variables or U
The current value of the dual variables (Lagrangian multipliers for bounds, linear, quadratic and nonlinear constraints).
Dual Cone Variables or UC
The current value of the dual cone variables (Lagrangian multipliers for quadratic cone constraints).
Dual Matrix Variables or UA
The current value of the dual matrix variables (Lagrangian multipliers for matrix inequality constraints).
Residual Weights or RW
Array of residual weights.
Covariance Matrix or COV
Covariance matrix of the primal variables.
Hessian Matrix or HES
The current value of the Hessian matrix.
Variance or VAR
Variance for the primal variables.
MCS List or MCSL
Used to provide a custom initialization list for the solver e05kbf.
Slack or SLK
Slack variables.
The functionality is supported by all solvers within the NAG optimization modelling suite for the retrieval of their final solutions. e04rxf, moreover, can also be used by a selection of the solvers in the NAG Library, such as, e04mtf and e04ptf for the retrieval of the approximate solutions within the monitoring step. See the documentation of the individual solvers. In addition, you can retrieve solutions from a specific solver by adding the solver name after the available cmdstr mentioned above, e.g., keywords X e04mt or X handle_solve_lp_ipm return the value of primal variables only from the linear programming solver e04mtf. This is useful when a problem is solved by several different solvers. See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

None.

5Arguments

1: $\mathbf{handle}$Type (c_ptr) Input
On entry: the handle to the problem. It needs to be initialized by e04raf and must not be changed between calls to the NAG optimization modelling suite.
2: $\mathbf{cmdstr}$Character(*) Input
On entry: a string which identifies the item within the handle to be read or written. The string is case insensitive and space tolerant.
Constraint: ${\mathbf{cmdstr}}=\text{'}\mathrm{Primal Variables}\text{'},\text{'}\mathrm{Dual Variables}\text{'},\text{'}\mathrm{Dual Cone Variables}\text{'},\text{'}\mathrm{Dual Matrix Variables}\text{'},\text{'}\mathrm{Residual Weights}\text{'},\text{'}\mathrm{Covariance Matrix}\text{'},\text{'}\mathrm{Hessian Matrix}\text{'},\text{'}\mathrm{Variance}\text{'},\text{'}\mathrm{Slack}\text{'},\text{'}\mathrm{X}\text{'},\text{'}\mathrm{U}\text{'},\text{'}\mathrm{UC}\text{'},\text{'}\mathrm{UA}\text{'},\text{'}\mathrm{RW}\text{'},\text{'}\mathrm{COV}\text{'},\text{'}\mathrm{HES}\text{'},\text{'}\mathrm{VAR}\text{'},\text{or ​}\text{'}\mathrm{SLK}\text{'}$.
3: $\mathbf{ioflag}$Integer Input
On entry: indicates the direction of the communication.
${\mathbf{ioflag}}\ne 0$
e04rxf will extract the requested information from the handle to rarr.
${\mathbf{ioflag}}=0$
The writing mode will apply and the content of rarr will be copied to the handle.
4: $\mathbf{lrarr}$Integer Input/Output
On entry: the dimension of the array rarr.
On exit: the correct expected dimension of rarr if lrarr does not match the item identified by cmdstr (in this case e04rxf returns ${\mathbf{ifail}}={\mathbf{2}}$).
5: $\mathbf{rarr}\left({\mathbf{lrarr}}\right)$Real (Kind=nag_wp) array Input/Output
On entry: if ${\mathbf{ioflag}}=0$ (write mode), rarr must contain the information to be written to the handle; otherwise, it does not need to be set.
On exit: if ${\mathbf{ioflag}}\ne 0$ (read mode), rarr contains the information requested by cmdstr; otherwise, rarr is unchanged.
6: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $-1$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
Note: in some cases e04rxf may return useful information.
${\mathbf{ifail}}=1$
The supplied handle does not define a valid handle to the data structure for the NAG optimization modelling suite. It has not been properly initialized or it has been corrupted.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{lrarr}}=⟨\mathit{\text{value}}⟩$, expected $\mathrm{value}=⟨\mathit{\text{value}}⟩$.
Constraint: lrarr must match the size of the data identified in cmdstr.
${\mathbf{ifail}}=3$
The provided cmdstr is not recognised.
${\mathbf{ifail}}=4$
Reading mode is not supported for the given cmdstr.
${\mathbf{ifail}}=5$
Writing mode is not supported for the given cmdstr.
${\mathbf{ifail}}=6$
The request cannot be processed at this phase.
The requested information is not available.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

8Parallelism and Performance

e04rxf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
e04rxf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

10Example

This example demonstrates how to use e04rxf to extract the current approximation of the solution when the monitoring routine monit is called during the solve by e04mtf.
We solve the following linear programming problem:
 $-0.02x1 -0.2x2 -0.2x3 -0.2x4 -0.2x5 +0.04x6 +0.04x7$
subject to the bounds
 $-0.01≤x1≤ 0.01 -0.10≤x2≤ 0.15 -0.01≤x3≤ 0.03 -0.04≤x4≤ 0.02 -0.10≤x5≤ 0.05 -0.01≤x6 ≤ 0.00 -0.01≤x7 ≤ 0.00$
and the general constraints
 $x1 + x2 + x3 + x4 + x5 + x6 + x7 = -0.13 0.15x1 + 0.04x2 + 0.02x3 + 0.04x4 + 0.02x5 + 0.01x6 + 0.03x7 ≤ -0.0049 0.03x1 + 0.05x2 + 0.08x3 + 0.02x4 + 0.06x5 + 0.01x6 ≤ -0.0064 00.02x1 + 0.04x2 + 0.01x3 + 0.02x4 + 0.02x5 ≤ -0.0037 0.02x1 + 0.03x2 + 0.01x5 ≤ -0.0012 -0.0992 ≤ 0.70x1 + 0.75x2 + 0.80x3 + 0.75x4 + 0.80x5 + 0.97x6 -0.003 ≤ 0.02x1 + 0.06x2 + 0.08x3 + 0.12x4 + 0.02x5 + 0.01x6 + 0.97x7 ≤ -0.002.$
During the monitoring step of e04mtf, if the three convergence measures are below an acceptable threshold, the approximate solution is extracted with e04rxf and printed on the standard output.

10.1Program Text

Program Text (e04rxfe.f90)

10.2Program Data

Program Data (e04rxfe.d)

10.3Program Results

Program Results (e04rxfe.r)