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_glopt_bnd_mcs_optset_real (e05jg)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_glopt_bnd_mcs_optset_real (e05jg) may be used to supply individual real optional parameters to nag_glopt_bnd_mcs_solve (e05jb). The initialization function nag_glopt_bnd_mcs_init (e05ja) must have been called before calling nag_glopt_bnd_mcs_optset_real (e05jg).

Syntax

[comm, ifail] = e05jg(optstr, rvalue, comm)
[comm, ifail] = nag_glopt_bnd_mcs_optset_real(optstr, rvalue, comm)

Description

nag_glopt_bnd_mcs_optset_real (e05jg) may be used to supply values for real optional parameters to nag_glopt_bnd_mcs_solve (e05jb). It is only necessary to call nag_glopt_bnd_mcs_optset_real (e05jg) for those arguments whose values are to be different from their default values. One call to nag_glopt_bnd_mcs_optset_real (e05jg) sets one argument value.
Each real optional parameter is defined by a single character string in optstr and the corresponding value in rvalue. For example the following illustrates how the local searches tolerance could be defined:
loctol = 1.0E-10;
[comm, ifail] = e05jg('Local Searches Tolerance', loctol, comm);
A complete list of optional parameters, their symbolic names and default values is given in Optional Parameters in nag_glopt_bnd_mcs_solve (e05jb).

References

None.

Parameters

Compulsory Input Parameters

1:     optstr – string
A string identifying a real-valued optional parameter (as described in Optional Parameters in nag_glopt_bnd_mcs_solve (e05jb)).
2:     rvalue – double scalar
The value associated with the optional parameter in optstr.
3:     commlcomm – double array

Optional Input Parameters

None.

Output Parameters

1:     commlcomm – double array
lcomm=100.
2:     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:
   ifail=1
Constraint: lcomm100.
Initialization function nag_glopt_bnd_mcs_init (e05ja) has not been called.
   ifail=2
The supplied optional parameter is invalid. A keyword or keyword combination was not recognized.
   ifail=3
Attempt to assign an out-of-bounds value of Infinite Bound Size (infbnd):
Attempt to assign too small a value of Local Searches Tolerance (loctol):
Attempt to assign too small a value of Target Objective Error (objerr):
Attempt to assign too small a value of Target Objective Safeguard (objsfg):
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

nag_glopt_bnd_mcs_optset_string (e05jd) may also be used to supply real optional parameters to nag_glopt_bnd_mcs_solve (e05jb).

Example

function e05jg_example


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

% Problem data for peaks function
prob = 'peaks';
xres = 100;
yres = 100;
n    = 2;
bl   = [-3; -3];
bu   = -bl;
fglob = -6.55;
xglob = [0.23; -1.63];

% Initialize e05jb
[comm, ifail] = e05ja;

disp('Solve with no options or initial list data');

ibound = int64(0);
list   = zeros(n,3);
numpts = zeros(n, 1, 'int64');
initpt = zeros(n, 1, 'int64');

[bl, bu, list, numpts, initpt, xbest, obj, comm, user, ifail] = ...
    e05jb(...
          @objective, ibound, bl, bu, list, numpts, initpt, @monitor, comm);

fprintf('xbest:\n   ');
fprintf(' %7.3f',xbest);
fprintf('\nObjective Function:\n   ');
fprintf(' %7.3f\n\n',obj);

% Set some options.
fprintf('Solve with options and initial list data\n');

% Echo the setting of opt. params.
comm = e05jd('List', comm);

comm = e05jd('Function Evaluations Limit = 100000', comm);
comm = e05jf('Static Limit', int64(3*n), comm);

% Get infbnd and increase by factor 10.
infbnd = e05jl('Infinite Bound Size', comm);
comm = e05jg('Infinite Bound Size', 10*infbnd, comm);

comm = e05je('Local Searches', 'on', comm);

% Set the initialization-list data.
iinit      = int64(3);
list       = zeros(n, 3);
list(:, 1) = bl;
list(:, 2) = [-1; 0];
list(:, 3) = bu;
numpts(1:n) = int64(3);
initpt(1:n) = int64(2);

[bl, bu, list, numpts, initpt, xbest, obj, comm, user, ifail] = ...
    e05jb(...
          @objective, ibound, bl, bu, list, numpts, initpt, ...
          @monitor, comm, 'iinit', iinit);

fprintf('xbest:\n   ');
fprintf(' %7.3f',xbest);
fprintf('\nObjective Function:\n   ');
fprintf(' %7.3f\n\n',obj);



function [f,user,inform] = objective(n,x,nstate,user)
if (n==2)
    inform = int64(0);
else
    inform = int64(-1);
end

if (inform >= 0)

    % Evaluate the objective
    if (nstate == 1)
        disp(sprintf('\n'));
        disp('(OBJFUN was just called for the first time)');
    end

    f = peaks(x(1), x(2));
end

function [user,inform] = ...
     monitor(...
             n,ncall,xbest,icount,ninit,list,numpts,initpt,nbaskt,...
             xbaskt,boxl,boxu,nstate,user)
inform = int64(0);

if (nstate == 0 || nstate == 1)
    fprintf('\n----- monitoring information ------\n');
end

if (nstate <= 0)
  fprintf('Total sub-boxes             = %5d\n', icount(1));
  fprintf('Total function evaluations  = %5d\n', ncall);
  fprintf('Local function evaluations  = %5d\n', icount(2));
  fprintf('Points used in local search = %5d\n', icount(3));
  fprintf('Total sweeps through levels = %5d\n', icount(4));
  fprintf('Total splits by init. list  = %5d\n', icount(5));
  fprintf('Lowest unsplit level        = %5d\n', icount(6));
  fprintf('Candidate minima in basket  = %5d\n', nbaskt);
  fprintf('Shopping basket:\n');
  fprintf(' %7.3f',xbaskt);
  fprintf('\n');
  fprintf('-----------------------------------\n');
end
e05jg example results

Solve with no options or initial list data


(OBJFUN was just called for the first time)

----- monitoring information ------
Total sub-boxes             =   228
Total function evaluations  =   196
Local function evaluations  =    87
Points used in local search =    13
Total sweeps through levels =    12
Total splits by init. list  =     5
Lowest unsplit level        =     7
Candidate minima in basket  =     2
Shopping basket:
  -1.347   0.205   0.228  -1.626
-----------------------------------
xbest:
      0.228  -1.626
Objective Function:
     -6.551

Solve with options and initial list data
      FUNCTION EVALUATIONS LIMIT =           100000
      STATIC LIMIT =                6
      INFINITE BOUND SIZE =     1.1579208923731620E+78
      LOCAL SEARCHES = on


(OBJFUN was just called for the first time)

----- monitoring information ------
Total sub-boxes             =   146
Total function evaluations  =   169
Local function evaluations  =   102
Points used in local search =     7
Total sweeps through levels =     7
Total splits by init. list  =     5
Lowest unsplit level        =     4
Candidate minima in basket  =     2
Shopping basket:
   0.228  -1.626  -1.347   0.205
-----------------------------------
xbest:
      0.228  -1.626
Objective Function:
     -6.551


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