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_qpconvex2_sparse_init (e04np)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_opt_qpconvex2_sparse_init (e04np) is used to initialize the function nag_opt_qpconvex2_sparse_solve (e04nq).

Syntax

[cw, iw, rw, ifail] = e04np
[cw, iw, rw, ifail] = nag_opt_qpconvex2_sparse_init

Description

nag_opt_qpconvex2_sparse_init (e04np) initializes the arrays cw, iw and rw for the function nag_opt_qpconvex2_sparse_solve (e04nq).

References

None.

Parameters

Compulsory Input Parameters

None.

Optional Input Parameters

None.

Output Parameters

1:     cwlencw – cell array of strings
2:     iwleniw int64int32nag_int array
3:     rwlenrw – double array
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Accuracy

Not applicable.

Further Comments

The time taken by nag_opt_qpconvex2_sparse_init (e04np) is negligible.

Example

function e04np_example


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

start = 'C';
m     = int64(8);
n     = int64(7);
lenc  = int64(0);
ncolh = int64(7);
iobj  = int64(8);
objadd = 0;
prob  = '        ';
% A elements by column
a     = [ 0.02;  0.02;  0.03;    1;     0.7;     0.02;     0.15; -200;
          0.06;  0.75;  0.03;    0.04;  0.05;    0.04;     1;    -2000;
          0.02;  1;     0.01;    0.08;  0.08;    0.8;  -2000;
          1;     0.12;  0.02;    0.02;  0.75;    0.04; -2000;
          0.01;  0.8;   0.02;    1;     0.02;    0.06;     0.02; -2000;
          1;     0.01;  0.01;    0.97;  0.01;  400;
          0.97;  0.03;  1;     400];
% Row indices of nonzero elments of A
irow   = int64([ 7; 5; 3; 1; 6; 4; 2; 8;
                   7; 6; 5; 4; 3; 2; 1; 8;
                   2; 1; 4; 3; 7; 6; 8;
                   1; 7; 3; 4; 6; 2; 8;
                   5; 6; 7; 1; 2; 3; 4; 8;
                   1; 2; 3; 6; 7; 8;
                   7; 2; 1; 8]);
% Index in a of start of column
icolzp = int64([1;9;17;24;31;39;45;49]);

% Bounds on variables and constraints
bl(1:n)     = [   0;    0; 400;  100;     0;   0;   0;];
bu(1:n)     = [ 200; 2500; 800;  700;  1500;1e25;1e25];
bl(n+1:n+m) = [2000;-1e25;-1e25;-1e25;-1e25;1500; 250;-1e25];
bu(n+1:n+m) = [2000;   60; 100;   40;    30;1e25; 300; 1e25];
c = [0];
names = {' '};
helast = zeros(m+n,1,'int64');
hs     = zeros(m+n,1,'int64');
x      = zeros(m+n,1);
ns     = int64(0);
% Initialize and set options
[cw, iw, rw, ifail] = e04np;
[cw, iw, rw, ifail] = e04ns('NoList', cw, iw, rw);
[cw, iw, rw, ifail] = e04ns('Print Level = 0', cw, iw, rw);
[hs, x, pi, rc, ns, ninf, sinf, obj, cuser, cw, iw, rw, ifail] = ...
     e04nq(...
           start, @qphx, m, n, lenc, ncolh, iobj, objadd, prob, a, ...
           irow, icolzp, bl, bu, c, names, helast, hs, x, ns, cw, iw, rw);
fprintf('Minimum value     :  %10.1f\n\n',obj);
fprintf('Found at x:\n   ');
fprintf(' %8.1f',x(1:n));
fprintf('\nLinear contrained values Ax:\n   ');
fprintf(' %8.1f',x(n+1:n+m));
fprintf('\n');



function [hx, user] = qphx(ncolh, x, nstate, user)
  hx = zeros(ncolh, 1);

  hx(1) = 2*x(1);
  hx(2) = 2*x(2);
  hx(3) = 2*(x(3)+x(4));
  hx(4) = hx(3);
  hx(5) = 2*x(5);
  hx(6) = 2*(x(6)+x(7));
  hx(7) = hx(6);
e04np example results

Minimum value     :  -1847784.7

Found at x:
         0.0    349.4    648.9    172.8    407.5    271.4    150.0
Linear contrained values Ax:
      2000.0     49.2    100.0     32.1     14.6   1500.0    250.0 -2988690.4

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