overview of functions provided#

// typedefs

typedef float spc_;
typedef double rpc_;
typedef int ipc_;

// structs

struct ugo_control_type;
struct ugo_inform_type;
struct ugo_time_type;

// function calls

void ugo_initialize(void **data, struct ugo_control_type* control, ipc_ *status);
void ugo_read_specfile(struct ugo_control_type* control, const char specfile[]);

void ugo_import(
    struct ugo_control_type* control,
    void **data,
    ipc_ *status,
    const rpc_* x_l,
    const rpc_* x_u
);

void ugo_reset_control(
    struct ugo_control_type* control,
    void **data,
    ipc_ *status
);

void ugo_solve_direct(
    void **data,
    void *userdata,
    ipc_ *status,
    rpc_* x,
    rpc_* f,
    rpc_* g,
    rpc_* h,
    ipc_(*)(rpc_, rpc_*, rpc_*, rpc_*, const void*) eval_fgh
);

void ugo_solve_reverse(
    void **data,
    ipc_ *status,
    ipc_ *eval_status,
    rpc_* x,
    rpc_* f,
    rpc_* g,
    rpc_* h
);

void ugo_information(void **data, struct ugo_inform_type* inform, ipc_ *status);

void ugo_terminate(
    void **data,
    struct ugo_control_type* control,
    struct ugo_inform_type* inform
);

typedefs#

typedef float spc_

spc_ is real single precision

typedef double rpc_

rpc_ is the real working precision used, but may be changed to float by defining the preprocessor variable REAL_32 or (if supported) to __real128 using the variable REAL_128.

typedef int ipc_

ipc_ is the default integer word length used, but may be changed to int64_t by defining the preprocessor variable INTEGER_64.

function calls#

void ugo_initialize(void **data, struct ugo_control_type* control, ipc_ *status)

Set default control values and initialize private data

Parameters:

data

holds private internal data

control

is a struct containing control information (see ugo_control_type)

status

is a scalar variable of type ipc_, that gives the exit status from the package. Possible values are (currently):

  • 0

    The initialization was successful.

void ugo_read_specfile(struct ugo_control_type* control, const char specfile[])

Read the content of a specification file, and assign values associated with given keywords to the corresponding control parameters. An in-depth discussion of specification files is available, and a detailed list of keywords with associated default values is provided in $GALAHAD/src/ugo/UGO.template. See also Table 2.1 in the Fortran documentation provided in $GALAHAD/doc/ugo.pdf for a list of how these keywords relate to the components of the control structure.

Parameters:

control

is a struct containing control information (see ugo_control_type)

specfile

is a character string containing the name of the specification file

void ugo_import(
    struct ugo_control_type* control,
    void **data,
    ipc_ *status,
    const rpc_* x_l,
    const rpc_* x_u
)

Import problem data into internal storage prior to solution.

Parameters:

control

is a struct whose members provide control paramters for the remaining prcedures (see ugo_control_type)

data

holds private internal data

status

is a scalar variable of type ipc_, that gives the exit status from the package. Possible values are:

  • 1

    The import was successful, and the package is ready for the solve phase

  • -1

    An allocation error occurred. A message indicating the offending array is written on unit control.error, and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -2

    A deallocation error occurred. A message indicating the offending array is written on unit control.error and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

x_l

is a scalar variable of type rpc_, that holds the value \(x^l\) of the lower bound on the optimization variable \(x\).

x_u

is a scalar variable of type rpc_, that holds the value \(x^u\) of the upper bound on the optimization variable \(x\).

void ugo_reset_control(
    struct ugo_control_type* control,
    void **data,
    ipc_ *status
)

Reset control parameters after import if required.

Parameters:

control

is a struct whose members provide control paramters for the remaining prcedures (see ugo_control_type)

data

holds private internal data

status

is a scalar variable of type ipc_, that gives the exit status from the package. Possible values are:

  • 1

    The import was successful, and the package is ready for the solve phase

void ugo_solve_direct(
    void **data,
    void *userdata,
    ipc_ *status,
    rpc_* x,
    rpc_* f,
    rpc_* g,
    rpc_* h,
    ipc_(*)(rpc_, rpc_*, rpc_*, rpc_*, const void*) eval_fgh
)

Find an approximation to the global minimizer of a given univariate function with a Lipschitz gradient in an interval.

This version is for the case where all function/derivative information is available by function calls.

Parameters:

data

holds private internal data

userdata

is a structure that allows data to be passed into the function and derivative evaluation programs (see below).

status

is a scalar variable of type ipc_, that gives the entry and exit status from the package.

On initial entry, status must be set to 1.

Possible exit values are:

  • 0

    The run was successful

  • -1

    An allocation error occurred. A message indicating the offending array is written on unit control.error, and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -2

    A deallocation error occurred. A message indicating the offending array is written on unit control.error and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -7

    The objective function appears to be unbounded from below

  • -18

    Too many iterations have been performed. This may happen if control.maxit is too small, but may also be symptomatic of a badly scaled problem.

  • -19

    The CPU time limit has been reached. This may happen if control.cpu_time_limit is too small, but may also be symptomatic of a badly scaled problem.

  • -40

    The user has forced termination of solver by removing the file named control.alive_file from unit unit control.alive_unit.

x

is a scalar variable of type rpc_, that holds the value of the approximate global minimizer \(x\) after a successful (status = 0) call.

f

is a scalar variable of type rpc_, that holds the the value of the objective function \(f(x)\) at the approximate global minimizer \(x\) after a successful (status = 0) call.

g

is a scalar variable of type rpc_, that holds the the value of the gradient of the objective function \(f^{\prime}(x)\) at the approximate global minimizer \(x\) after a successful (status = 0) call.

h

is a scalar variable of type rpc_, that holds the the value of the second derivative of the objective function \(f^{\prime\prime}(x)\) at the approximate global minimizer \(x\) after a successful (status = 0) call.

eval_fgh

is a user-provided function that must have the following signature:

ipc_ eval_fgh( rpc_ x,
              rpc_ *f,
              rpc_ *g,
              rpc_ *h,
              const void *userdata)

The value of the objective function \(f(x)\) and its first derivative \(f^{\prime}(x)\) evaluated at x= \(x\) must be assigned to f and g respectively, and the function return value set to 0. In addition, if control.second_derivatives_available has been set to true, when calling ugo_import, the user must also assign the value of the second derivative \(f^{\prime\prime}(x)\) in h; it need not be assigned otherwise. If the evaluation is impossible at x, return should be set to a nonzero value.

void ugo_solve_reverse(
    void **data,
    ipc_ *status,
    ipc_ *eval_status,
    rpc_* x,
    rpc_* f,
    rpc_* g,
    rpc_* h
)

Find an approximation to the global minimizer of a given univariate function with a Lipschitz gradient in an interval.

This version is for the case where function/derivative information is only available by returning to the calling procedure.

Parameters:

data

holds private internal data

status

is a scalar variable of type ipc_, that gives the entry and exit status from the package.

On initial entry, status must be set to 1.

Possible exit values are:

  • 0

    The run was successful

  • -1

    An allocation error occurred. A message indicating the offending array is written on unit control.error, and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -2

    A deallocation error occurred. A message indicating the offending array is written on unit control.error and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -7

    The objective function appears to be unbounded from below

  • -18

    Too many iterations have been performed. This may happen if control.maxit is too small, but may also be symptomatic of a badly scaled problem.

  • -19

    The CPU time limit has been reached. This may happen if control.cpu_time_limit is too small, but may also be symptomatic of a badly scaled problem.

  • -40

    The user has forced termination of solver by removing the file named control.alive_file from unit unit control.alive_unit.

  • 3

    The user should compute the objective function value \(f(x)\) and its first derivative \(f^{\prime}(x)\), and then re-enter the function. The required values should be set in f and g respectively, and eval_status (below) should be set to 0. If the user is unable to evaluate \(f(x)\) or \(f^{\prime}(x)\) - for instance, if the function or its first derivative are undefined at x - the user need not set f or g, but should then set eval_status to a non-zero value. This value can only occur when control.second_derivatives_available = false.

  • 4

    The user should compute the objective function value \(f(x)\) and its first two derivatives \(f^{\prime}(x)\) and \(f^{\prime\prime}(x)\) at x= \(x\), and then re-enter the function. The required values should be set in f, g and h respectively, and eval_status (below) should be set to 0. If the user is unable to evaluate \(f(x)\), \(f^{\prime}(x)\) or \(f^{\prime\prime}(x)\) - for instance, if the function or its derivatives are undefined at x - the user need not set f, g or h, but should then set eval_status to a non-zero value. This value can only occur when control.second_derivatives_available = true.

eval_status

is a scalar variable of type ipc_, that is used to indicate if objective function and its derivatives can be provided (see above).

x

is a scalar variable of type rpc_, that holds the next value of \(x\) at which the user is required to evaluate the objective (and its derivatives) when status > 0, or the value of the approximate global minimizer when status = 0

f

is a scalar variable of type rpc_, that must be set by the user to hold the value of \(f(x)\) if required by status > 0 (see above), and will return the value of the approximate global minimum when status = 0

g

is a scalar variable of type rpc_, that must be set by the user to hold the value of \(f^{\prime}(x)\) if required by status > 0 (see above), and will return the value of the first derivative of \(f\) at the approximate global minimizer when status = 0

h

is a scalar variable of type rpc_, that must be set by the user to hold the value of \(f^{\prime\prime}(x)\) if required by status > 0 (see above), and will return the value of the second derivative of \(f\) at the approximate global minimizer when status = 0

void ugo_information(void **data, struct ugo_inform_type* inform, ipc_ *status)

Provides output information

Parameters:

data

holds private internal data

inform

is a struct containing output information (see ugo_inform_type)

status

is a scalar variable of type ipc_, that gives the exit status from the package. Possible values are (currently):

  • 0

    The values were recorded successfully

void ugo_terminate(
    void **data,
    struct ugo_control_type* control,
    struct ugo_inform_type* inform
)

Deallocate all internal private storage

Parameters:

data

holds private internal data

control

is a struct containing control information (see ugo_control_type)

inform

is a struct containing output information (see ugo_inform_type)