1. Home
  2. MIN1DIMENSION procedure

MIN1DIMENSION procedure

Finds the minimum of a function in one dimension (R.W. Payne).

Options

PRINT = string tokens What output to produce (minimum, monitoring, plot); default mini
CALCULATION = expression structures Expressions to calculate the target function
FUNCTIONVALUE = scalars Identifier of the scalar, calculated by CALCULATION, whose value is to be minimized
DATA = any type Data to be used with procedure _MIN1DFUNCTION
CRITERION = string token Criterion for convergence (function, parameters); default func
MAXCYCLE = scalars Maximum number of iterations; default 250
EXIT = scalars Indicates whether there has been convergence (0) or non-convergence (1)
TOLERANCE = scalars Convergence criterion; default 10-6 or variate

Parameters

PARAMETER = scalars Parameters to be estimated
LOWER = scalars Lower bound for each parameter
UPPER = scalars Upper bound for each parameter
STEPLENGTH = scalars Step length for each parameter
INITIAL = scalars Initial value for each parameter

Description

MIN1DIMENSION searches for the minimum of a function in one dimension. The parameters to be estimated by the minimization are listed by the PARAMETER parameter of MIN1DIMENSION. Step lengths and initial values must be supplied using the STEPLENGTH and INITIAL parameters. When there are several parameters, these also define the dimension in the parameter space over which the function is minimized. Within each step of the minimization, the same multiple is used for the step length of every parameter. So the dimension is defined as the set of parameter values that can be calculated as

PARAMETER[1...p] = INITIAL[1...p] + Move * STEPLENGTH[1...p]

where Move is a scalar, and p is the number of parameters. You can also specify lower bounds with the LOWER parameter, and upper bounds with the UPPER parameter.

The function can be defined by specifying a list of Genstat calculation structures with the CALCULATION option, similarly to the way in which functions for optimization are specified for the FITNONLINEAR directive (see the Guide to the Genstat Command Language, Part 2 Statistics, Section 3.8). For example, you could find the minimum of the function 5*X-25*LOG(X) as follows.

EXPRESSION Calc; VALUE=!e(Fx = 5 * X - 25 * LOG(X))

MIN1DIMENSION [PRINT=minimum,monitor,plot; EXIT=exit;\

              CALCULATION=Calc; FUNCTIONVALUE=Fx]\

              X; STEPLENGTH=1; INITIAL=1; LOWER=0.001

Alternatively, more complicated functions can be specified by defining a procedure _MIN1DFUNCTION, which operates similarly to the RESAMPLE procedure that is called by procedures BOOTSTRAP and JACKKNIFE. This is more complicated to specify, but it has the advantage that you can use any Genstat command to obtain the function value (e.g. ANOVA, FIT, SVD and so on). The DATA option is then used to list any data structures that are needed by _MIN1DFUNCTION to calculate the value of the function. Details are given in the Methods Section.

The PRINT option controls printed output with the settings:

    minimum to print the minimum function value and parameter values,
    monitoring to print to monitor information showing the progress of the minimization, and
    plot to plot the function values around the initial values.

By default, PRINT=minimum.

The scalars specified by the PARAMETER parameter save the estimated values of the parameters, and the FUNCTIONVALUE scalar saves the minimum value. You can also save a scalar, using the EXIT option, which is set to 0 if the minimization was successful or to 1 if it did not converge.

The MAXCYCLE option sets a limit on the number of iterations; by default this is 250. The TOLERANCE option specifies the tolerance for convergence (default 10-6), and the CRITERION option specifies what is tested. When CRITERION=function, convergence is achieved when the current function evaluations differ by less than the (scalar) value supplied by TOLERANCE. Alternatively, when CRITERION=parameters, the parameter values at the current evaluations must differ by less than TOLERANCE, which can then be set to either a scalar (to use the same tolerance with every parameter) or a variate (for different tolerances).

Options: PRINT, CALCULATION, FUNCTIONVALUE, DATA, CRITERION, MAXCYCLE, EXIT, TOLERANCE.

Parameters: PARAMETER, LOWER, UPPER, STEPLENGTH, INITIAL.

Method

MIN1DIMENSION performs a series of iterations in which three points are moved in the one dimension to locate the minimum. The idea is that the two outer points should bracket the minimum, while the inner point locates it.

The procedure _MIN1DFUNCTION, which you can use to calculate the function instead of the CALCULATION and FUNCTIONVALUE options, has two options. DATA supplies a pointer containing the data structures specified by the DATA option of MIN1DIMENSION (so, DATA[1] is the first of these structures, DATA[2] is the second, and so on). FUNCTIONVALUE is a scalar, which should be set to the function value. There is one parameter, called PARAMETER. The PROCEDURE statement that defines _MIN1DFUNCTION should set option PARAMETER=pointer. The parameters of the function can then be referred to as PARAMETER[1], PARAMETER[2], and so on (and these will be in the same order as in the PARAMETER parameter of MIN1DIMENSION). The definition below has the same effect as the expression

EXPRESSION Calc; VALUE=!e(Fx = 5 * X - 25 * LOG(X))

shown in the description.

PROCEDURE [PARAMETER=pointer] '_MIN1DFUNCTION'

" calculates the function for MIN1DIMENSION "

OPTION NAME=\

  'DATA', "(I: pointer) data to calculate the function"\

  'FUNCTIONVALUE'; "(O: scalar) returns the function value"\

  MODE=p; TYPE='pointer','scalar'

PARAMETER NAME=\

  'PARAMETER'; "(I: scalar) parameter values"\

  MODE=p; TYPE='scalar'; SET=yes; DECLARED=yes; PRESENT=yes

CALCULATE FUNCTIONVALUE = 5*PARAMETER[1] - 25*LOG(PARAMETER[1])

ENDPROCEDURE

The parameter X can then be estimated by the statement

MIN1DIMENSION [PRINT=minimum,monitor,plot; EXIT=exit]\

              X; STEPLENGTH=1; INITIAL=1; LOWER=0.001

Action with RESTRICT

The effects of restrictions on the data variables will depend on how the calculation is defined (by the CALCULATION option or within the _MIN1DFUNCTION procedure).

See also

Directive: FITNONLINEAR.

Procedures: DEMC, FPARETOSET, MINIMIZE, SIMPLEX.

Commands for: Regression analysis.

Example

CAPTION        'MIN1DIMENSION examples',\
               'Define the function using the CALCULATION option';\
               STYLE=meta,plain
EXPRESSION     Calc; VALUE=!e(Fx = 5 * X - 25 * LOG(X))
MIN1DIMENSION  [PRINT=minimum,monitor,plot; EXIT=exit;\
               CALCULATION=Calc; FUNCTIONVALUE=Fx]\
               X; STEPLENGTH=1; INITIAL=1; LOWER=0.001

CAPTION        'Define the function using the _MIN1DFUNCTION procedure'
PROCEDURE [PARAMETER=pointer] '_MIN1DFUNCTION'
" calculates the function for MIN1DIMENSION "
OPTION NAME=\
  'DATA',         "(I: pointer) data to calculate the function"\ 
  'FUNCTIONVALUE';"(O: scalar) returns the function value"\ 
  MODE=p; TYPE='pointer','scalar'
PARAMETER NAME=\
  'PARAMETER';  "(I: scalar) parameter values"\ 
  MODE=p; TYPE='scalar'; SET=yes; DECLARED=yes; PRESENT=yes
CALCULATE      FUNCTIONVALUE = 5 * PARAMETER[1] - 25 * LOG(PARAMETER[1])
ENDPROCEDURE

MIN1DIMENSION  [PRINT=minimum,monitor,plot; EXIT=exit]\
               X; STEPLENGTH=1; INITIAL=1; LOWER=0.001
Updated on March 7, 2019

Was this article helpful?