hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_opt_qp_dense_option_string (e04nh)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

To supply individual optional parameters to nag_opt_qp_dense_solve (e04nf).

Syntax

[lwsav, iwsav, rwsav, inform] = e04nh(str, lwsav, iwsav, rwsav)
[lwsav, iwsav, rwsav, inform] = nag_opt_qp_dense_option_string(str, lwsav, iwsav, rwsav)

Description

nag_opt_qp_dense_option_string (e04nh) may be used to supply values for optional parameters to nag_opt_qp_dense_solve (e04nf). It is only necessary to call nag_opt_qp_dense_option_string (e04nh) for those arguments whose values are to be different from their default values. One call to nag_opt_qp_dense_option_string (e04nh) sets one argument value.
Each optional parameter is defined by a single character string, of up to 72 characters, consisting of one or more items. The items associated with a given option must be separated by spaces, or equals signs =. Alphabetic characters may be upper or lower case. The string
Print Level = 1
is an example of a string used to set an optional parameter. For each option the string contains one or more of the following items:
a mandatory keyword;
a phrase that qualifies the keyword;
a number that specifies an integer or double value. Such numbers may be up to 16 contiguous characters in Fortran's I, F, E or D formats, terminated by a space if this is not the last item on the line.
Blank strings and comments are ignored. A comment begins with an asterisk (*) and all subsequent characters in the string are regarded as part of the comment.
For nag_opt_qp_dense_option_string (e04nh), each user-specified option is normally printed as it is defined, on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)), but this printing may be suppressed using the keyword Nolist. Thus the statement
[lwsav, iwsav, rwsav, inform] = e04nh('Nolist', lwsav, iwsav, rwsav);
suppresses printing of this and subsequent options. Printing will automatically be turned on again after a call to nag_opt_qp_dense_solve (e04nf) and may be turned on again at any time using the keyword List.
Optional parameter settings are preserved following a call to nag_opt_qp_dense_solve (e04nf) and so the keyword Defaults is provided to allow you to reset all the optional parameters to their default values before a subsequent call to nag_opt_qp_dense_solve (e04nf).
A complete list of optional parameters, their abbreviations, synonyms and default values is given in Optional Parameters in nag_opt_qp_dense_solve (e04nf).

References

None.

Parameters

Compulsory Input Parameters

1:     str – string
A single valid option string (as described in Description and in Optional Parameters in nag_opt_qp_dense_solve (e04nf)).
2:     lwsav120 – logical array
3:     iwsav610 int64int32nag_int array
4:     rwsav475 – double array
The arrays lwsav, iwsav and rwsav must not be altered between calls to any of the functions nag_opt_qp_dense_option_string (e04nh), nag_opt_qpconvex1_sparse_solve (e04nk) or nag_opt_init (e04wb).

Optional Input Parameters

None.

Output Parameters

1:     lwsav120 – logical array
2:     iwsav610 int64int32nag_int array
3:     rwsav475 – double array
4:     inform int64int32nag_int scalar
Contains zero if a valid option string has been supplied and a value>0 otherwise (see Error Indicators and Warnings).

Error Indicators and Warnings

   inform=5
The supplied option is invalid. Check that the keywords are neither ambiguous nor misspelt.

Accuracy

Not applicable.

Further Comments

None.

Example

function e04nh_example


fprintf('e04nh example results\n\n');

% Problem specification
n     = 7;
m     = 7;
nclin = 7;
a     = [ 1,     1,       1,       1,       1,      1,       1;
          0.15,  0.04,    0.02,    0.04,    0.02,   0.01,    0.03;
          0.03,  0.05,    0.08,    0.02,    0.06,   0.01,    0;
          0.02,  0.04,    0.01,    0.02,    0.02,   0.00,    0;
          0.02,  0.03,    0.00,    0.00,    0.01,   0.00,    0;
          0.70,  0.75,    0.80,    0.75,    0.80,   0.97,    0;
          0.02,  0.06,    0.08,    0.12,    0.02,   0.01,    0.97];
bl    = [-0.01; -0.10;   -0.01;   -0.04;   -0.10;  -0.01;   -0.01;...
         -0.13; -1e25;   -1e25;   -1e25;   -1e25;  -0.0992; -0.003];
bu    = [ 0.01;  0.15;    0.03;    0.02;    0.05;   1e25;    1e25;...
         -0.13; -0.0049; -0.0064; -0.0037; -0.0012; 1e25;    0.002];
cvec  = [-0.02; -0.2;    -0.2;    -0.2;    -0.2;    0.04;    0.04];
x     = [-0.01; -0.03;    0;      -0.01;   -0.1;    0.02;    0.01];

h     = zeros(m,n);
h(1,  1)   = 2;
h(2,  2)   = 2;
h(3:4,3:4) = 2;
h(5,  5)   = 2;
h(6:7,6:7) = -2;

% Initialize and set options
istate     = zeros(14, 1, 'int64');
[cwsav,lwsav,iwsav,rwsav,ifail] = e04wb('e04nf');
[lwsav, iwsav, rwsav, inform] = e04nh(...
                                      'NoList', lwsav, iwsav, rwsav);
[lwsav, iwsav, rwsav, inform] = e04nh(...
                                      'Print Level = 0', lwsav, iwsav, rwsav);
[lwsav, iwsav, rwsav, inform] = e04nh(...
                                 'Check Frequency = 10', lwsav, iwsav, rwsav);

% Solve
[istate, x, iter, obj, ax, clamda, user, lwsav, iwsav, rwsav, ifail] = ...
    e04nf(...
          a, bl, bu, cvec, h, @qphess, istate, x, lwsav, iwsav, rwsav);
fprintf('Minimum value     :  %9.4f\n\n',obj);
fprintf('Found after %3d iterations at x:\n   ',iter);
fprintf(' %9.4f',x);
fprintf('\nLinear contrained values Ax:\n   ');
fprintf(' %9.4f',ax);
fprintf('\n');



function [hx, user, iwsav] = qphess(n, jthcol, h, ldh, x, user, iwsav)

  if (iwsav(365) == 3 || iwsav(365) == 4)
    % Problem type QP1 and QP2
    hx = h*x;
  elseif(iwsav(365) == 5 || iwsav(365) == 6)
    hx = transpose(h)*h*x;
  else
    hx = zeros(n,1);
  end
e04nh example results

Minimum value     :     0.0370

Found after   7 iterations at x:
      -0.0100   -0.0699    0.0183   -0.0243   -0.0620    0.0138    0.0041
Linear contrained values Ax:
      -0.1300   -0.0059   -0.0064   -0.0045   -0.0029   -0.0992   -0.0030

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015