NAG Library Routine Document

e04rxf (handle_set_get_real)

1
Purpose

e04rxf is a part of the NAG optimization modelling suite. It allows you to read or write a piece of information 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.

2
Specification

Fortran Interface
Subroutine e04rxf ( handle, cmdstr, ioflag, lrarr, rarr, ifail)
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
C Header Interface
#include <nagmk26.h>
void  e04rxf_ (void **handle, const char *cmdstr, const Integer *ioflag, Integer *lrarr, double rarr[], Integer *ifail, const Charlen length_cmdstr)

3
Description

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).
The functionality is limited in this release of the NAG Library to the retrieval of the approximate solution within the monitoring step of e04mtf or its final solution.

4
References

None.

5
Arguments

1:     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:     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: cmdstr=Primal Variables,Dual Variables,X or U.
3:     ioflag – IntegerInput
On entry: indicates the direction of the communication.
ioflag0
e04rxf will extract the requested information from the handle to rarr.
ioflag=0
The writing mode will apply and the content of rarr will be copied to the handle.
4:     lrarr – IntegerInput/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 ifail=2).
5:     rarrlrarr – Real (Kind=nag_wp) arrayInput/Output
On entry: if 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 ioflag0 (read mode), rarr contains the information requested by cmdstr; otherwise rarr is unchanged.
6:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if ifail0 on exit, the recommended value is -1. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Note: e04rxf may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
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 initialized by e04raf or it has been corrupted.
ifail=2
On entry, lrarr=value, expected value=value.
Constraint: lrarr must match the size of the data identified in cmdstr.
ifail=3
The provided cmdstr is not recognised.
ifail=4
Reading mode is not supported for the given cmdstr.
ifail=5
Writing mode is not supported for the given cmdstr.
ifail=6
The request cannot be processed at this phase.
The requested information is not available.
ifail=7
The request cannot be processed by the current solver.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

e04rxf is not threaded in any implementation.

9
Further Comments

None.

10
Example

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.01x1 0.01 -0.10x2 0.15 -0.01x3 0.03 -0.04x4 0.02 -0.10x5 0.05 -0.01x6 0.00 -0.01x7 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.1
Program Text

Program Text (e04rxfe.f90)

10.2
Program Data

Program Data (e04rxfe.d)

10.3
Program Results

Program Results (e04rxfe.r)