overview of functions provided#

// typedefs

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

// structs

struct snls_control_type;
struct snls_inform_type;
struct snls_time_type;

// function calls

void snls_initialize(
    void **data,
    struct snls_control_type* control,
    struct snls_inform_type* inform
);

void snls_read_specfile(struct snls_control_type* control, const char specfile[]);

void snls_import(
    struct snls_control_type* control,
    void **data,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    const char J_type[],
    ipc_ J_ne,
    const ipc_ J_row[],
    const ipc_ J_col[],
    ipc_ J_ptr_ne,
    const ipc_ J_ptr[],
    const ipc_ cohort[],
);

void snls_import_withot_jac(
    struct snls_control_type* control,
    void **data,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    const ipc_ cohort[],
);

void snls_reset_control(
    struct snls_control_type* control,
    void **data,
    ipc_ *status
);

void snls_solve_with_jac(
    void **data,
    void *userdata,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    ipc_(*)(ipc_, ipc_, const rpc_[], rpc_[], const void*) eval_r,
    ipc_ j_ne,
    ipc_(*)(ipc_, ipc_, ipc_, const rpc_[], rpc_[], const void*) eval_jr,
    const rpc_ w[]

);

void snls_solve_with_jacprod(
    void **data,
    void *userdata,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    ipc_(*)(ipc_, ipc_, const rpc_[], rpc_[], const void*) eval_r,
    ipc_(*)(ipc_, ipc_, const rpc_[], const bool, rpc_[], const rpc_[], bool, const void*) eval_jr_prod,
    ipc_(*)(ipc_, ipc_, const rpc_[], ipc_, rpc_[], ipc_[], ipc_, bool, const void*) eval_scol,
    ipc_(*)(ipc_, ipc_, const rpc_[], const bool, const rpc_[], rpc_[], const ipc_[], ipc_, bool, const void*) eval_sprod,
    const rpc_ w[]
);

void snls_solve_reverse_with_jac(
    void **data,
    ipc_ *status,
    ipc_ *eval_status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    ipc_ jr_ne,
    rpc_ Jr_val[],
    const rpc_ w[]
);

void snls_solve_reverse_with_jacprod(
    void **data,
    ipc_ *status,
    ipc_ *eval_status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    rpc_ v[],
    ipc_ iv[],
    rpc_ v[],
    ipc_ *lvl,
    ipc_ *lvu,
    ipc_ *index,
    const rpc_ p[],
    const ipc_ ip[],
    ipc_ lp,
    const rpc_ w[]
);

void snls_information(void **data, struct snls_inform_type* inform, ipc_ *status);

void snls_terminate(
    void **data,
    struct snls_control_type* control,
    struct snls_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 and structure names#

The function and structure names described below are appropriate for the default real working precision (double) and integer word length (int32_t). To use the functions and structures with different precisions and integer word lengths, an additional suffix must be added to their names (and the arguments set accordingly). The appropriate suffices are:

_s for single precision (float) reals and standard 32-bit (int32_t) integers;

_q for quadruple precision (__real128) reals (if supported) and standard 32-bit (int32_t) integers;

_64 for standard precision (double) reals and 64-bit (int64_t) integers;

_s_64 for single precision (float) reals and 64-bit (int64_t) integers; and

_q_64 for quadruple precision (__real128) reals (if supported) and 64-bit (int64_t) integers.

Thus a call to snls_initialize below will instead be

void snls_initialize_s_64(void **data, struct snls_control_type_s_64* control,
                         int64_t *status)

if single precision (float) reals and 64-bit (int64_t) integers are required. Thus it is possible to call functions for this package with more that one precision and/or integer word length at same time. An example is provided for the package expo, and the obvious modifications apply equally here.

function calls#

void snls_initialize(
    void **data,
    struct snls_control_type* control,
    struct snls_inform_type* inform
)

Set default control values and initialize private data

Parameters:

data

holds private internal data

control

is a struct containing control information (see snls_control_type)

inform

is a struct containing output information (see snls_inform_type)

void snls_read_specfile(struct snls_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/snls/SNLS.template. See also Table 2.1 in the Fortran documentation provided in $GALAHAD/doc/snls.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 snls_control_type)

specfile

is a character string containing the name of the specification file

void snls_import(
    struct snls_control_type* control,
    void **data,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    const char J_type[],
    ipc_ J_ne,
    const ipc_ J_row[],
    const ipc_ J_col[],
    ipc_ J_ptr_ne,
    const ipc_ J_ptr[],
    const ipc_ cohort[]
)

Import problem data into internal storage prior to solution.

Parameters:

control

is a struct whose members provide control paramters for the remaining prcedures (see snls_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.

  • -3

    The restrictions n > 0, m_r > 0 or requirement that Jr_type contains its relevant string ‘dense’, ‘dense_by_rows’, ‘dense_by_columns’, ‘coordinate’, ‘sparse_by_rows’, or ‘sparse_by_columns’ has been violated.

n

is a scalar variable of type ipc_, that holds the number of variables.

m_r

is a scalar variable of type ipc_, that holds the number of residuals.

m_c

is a scalar variable of type ipc_, that holds the number of cohorts.

J_type

is a one-dimensional array of type char that specifies the unsymmetric storage scheme used for the Jacobian, \(J_r\). It should be one of ‘coordinate’, ‘sparse_by_rows’, ‘dense’ or ‘absent’, the latter if access to the Jacobian is via matrix-vector products; lower or upper case variants are allowed.

J_ne

is a scalar variable of type ipc_, that holds the number of entries in \(J_r\) in the sparse co-ordinate storage scheme. It need not be set for any of the other schemes.

J_row

is a one-dimensional array of size J_ne and type ipc_, that holds the row indices of \(J_r\) in the sparse co-ordinate and sparse column-wise storage schemes. It need not be set for any of the remaining schemes, and in this case can be NULL.

J_col

is a one-dimensional array of size J_ne and type ipc_, that holds the column indices of \(J_r\) in either the sparse co-ordinate, or the sparse row-wise storage scheme. It need not be set for any of the remaining schemes, and in this case can be NULL.

J_ptr_ne

is a scalar variable of type ipc_, that holds the length of the pointer array if sparse row or column storage scheme is used for \(J_r\). For the sparse row scheme, Jr_ptr_ne should be at least m_r+1, while for the sparse column scheme, it should be at least n+1, It should be set to 0 when the other schemes are used.

J_ptr

is a one-dimensional array of size m+1 and type ipc_, that holds the starting position of each row of \(J_r\), as well as the total number of entries, in the sparse row-wise storage scheme, or the starting position of each column of \(J_r\), as well as the total number of entries, in the sparse column-wise storage scheme. It need not be set when the other schemes are used, and in this case can be NULL.

cohort

is a one-dimensional array of size m and type ipc_, that specifies which cohort each variable is assigned to. If variable \(x_j\) is associated with cohort \(\cal C_i\), \(0 \leq i \leq m_c-1\), cohort[j] should be set to i, while if \(x_j\) is unconstrained cohort[j] = -1 should be assigned. At least one value cohort[j] for \(j = 0,\ldots\,n-1\) is expected to take the value \(i\) for every \(0 \leq i \leq m_c-1\), that is no empty cohorts are allowed. If all the variables lie in a single simplex, cohort can be set to NULL.

void snls_import_without_jac(
    struct snls_control_type* control,
    void **data,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    const ipc_ cohort[]
)

Import problem data, excluding the structure of \(J_r(x)\), into internal storage prior to solution.

Parameters:

control

is a struct whose members provide control paramters for the remaining prcedures (see snls_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.

  • -3

    The restrictions n > 0, m_r > 0 has been violated.

n

is a scalar variable of type ipc_, that holds the number of variables.

m_r

is a scalar variable of type ipc_, that holds the number of residuals.

m_c

is a scalar variable of type ipc_, that holds the number of cohorts.

cohort

is a one-dimensional array of size m and type ipc_, that specifies which cohort each variable is assigned to. If variable \(x_j\) is associated with cohort \(\cal C_i\), \(0 \leq i \leq m_c-1\), cohort[j] should be set to i, while if \(x_j\) is unconstrained cohort[j] = -1 should be assigned. At least one value cohort[j] for \(j = 0,\ldots\,n-1\) is expected to take the value \(i\) for every \(0 \leq i \leq m_c-1\), that is no empty cohorts are allowed. If all the variables lie in a single simplex, cohort can be set to NULL.

void snls_reset_control(
    struct snls_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 snls_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 snls_solve_with_jac(
    void **data,
    void *userdata,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    ipc_(*)(ipc_, ipc_, const rpc_[], rpc_[], const void*) eval_r,
    ipc_ jr_ne,
    ipc_(*)(ipc_, ipc_, ipc_, const rpc_[], rpc_[], const void*) eval_jr,
    const rpc_ w[]
)

Solve the simplex-constrained nonlinear least-squares problem when the Jacobian \(J_r(x)\) 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.

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.

  • -3

    The restriction n > 0 or requirement that type contains its relevant string ‘dense’, ‘coordinate’, ‘sparse_by_rows’, ‘diagonal’ or ‘absent’ has been violated.

  • -9

    The analysis phase of the factorization failed; the return status from the factorization package is given in the component inform.factor_status

  • -10

    The factorization failed; the return status from the factorization package is given in the component inform.factor_status.

  • -11

    The solution of a set of linear equations using factors from the factorization package failed; the return status from the factorization package is given in the component inform.factor_status.

  • -16

    The problem is so ill-conditioned that further progress is impossible.

  • -17

    The step is too small to make further impact.

  • -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.

  • -82

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

n

is a scalar variable of type ipc_, that holds the number of variables.

m_r

is a scalar variable of type ipc_, that holds the number of residuals.

m_c

is a scalar variable of type ipc_, that holds the number of cohorts.

x

is a one-dimensional array of size n and type rpc_, that holds the values \(x\) of the optimization variables. The j-th component of x, j = 0, … , n-1, contains \(x_j\).

y

is a one-dimensional array of size m_c and type rpc_, that holds the values \(y\) of the Lagrange multipliers for the simplex constraints. The i-th component of y, i = 0, … , m_r-1, contains \(y_i\).

z

is a one-dimensional array of size n and type rpc_, that holds the values \(z\) of the dual variables. The j-th component of z, j = 0, … , n-1, contains \(z_j\).

r

is a one-dimensional array of size m and type rpc_, that holds the residual \(r(x)\). The i-th component of r, j = 0, … , n-1, contains \(r_j(x)\).

g

is a one-dimensional array of size n and type rpc_, that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of g, j = 0, … , n-1, contains \(g_j\).

x_stat

is a one-dimensional array of size n and type ipc_, that gives the optimal status of the problem variables. If x_stat[j] is negative, the variable \(x_j\) most likely lies at its zero lower bound, while if it is zero, \(x_j\) is free of its bound (or unconstrained).

eval_r

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

ipc_ eval_r( ipc_ n, ipc_ m_r, const rpc_ x[],
             rpc_ r[], const void *userdata )

The components of the residual function \(r(x)\) evaluated at x= \(x\) must be assigned to r, and the function return value set to 0. If the evaluation is impossible at x, return should be set to a nonzero value. Data may be passed into eval_r via the structure userdata.

j_ne

is a scalar variable of type ipc_, that holds the number of entries in the Jacobian matrix \(J_r\).

eval_jr

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

ipc_ eval_jr( ipc_ n, ipc_ m, ipc_ jr_ne, const rpc_ x[], rpc_ jr[],
             const void *userdata )

The components of the Jacobian \(J_r = \nabla_x r(x\)) of the residuals must be assigned to jr in the same order as presented to snls_import, and the function return value set to 0. If the evaluation is impossible at x, return should be set to a nonzero value. Data may be passed into eval_jr via the structure userdata.

w

is a one-dimensional array of size m_r and type rpc_ that holds the values \(w\) of the weights on the residuals in the least-squares objective function. It need not be set if the weights are all ones, and in this case can be NULL.

void snls_solve_with_jacprod(
    void **data,
    void *userdata,
    ipc_ *status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    ipc_(*)(ipc_, ipc_, const rpc_[], rpc_[], const void*) eval_r,
    ipc_(*)(ipc_, ipc_, const rpc_[], const bool, rpc_[], const rpc_[], bool, const void*) eval_jr_prod,
    ipc_(*)(ipc_, ipc_, const rpc_[], ipc_, rpc_[], ipc_[], ipc_, bool, const void*) eval_scol,
    ipc_(*)(ipc_, ipc_, const rpc_[], const bool, const rpc_[], rpc_[], const ipc_[], ipc_, bool, const void*) eval_sprod,
    const rpc_ w[]
)

Solve the simplex-constrained nonlinear least-squares problem when the products of the Jacobian \(J_r(x)\) and its transpose are 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.

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.

  • -3

    The restriction n > 0 or requirement that type contains its relevant string ‘dense’, ‘coordinate’, ‘sparse_by_rows’, ‘diagonal’ or ‘absent’ has been violated.

  • -9

    The analysis phase of the factorization failed; the return status from the factorization package is given in the component inform.factor_status

  • -10

    The factorization failed; the return status from the factorization package is given in the component inform.factor_status.

  • -11

    The solution of a set of linear equations using factors from the factorization package failed; the return status from the factorization package is given in the component inform.factor_status.

  • -16

    The problem is so ill-conditioned that further progress is impossible.

  • -17

    The step is too small to make further impact.

  • -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.

  • -82

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

n

is a scalar variable of type ipc_, that holds the number of variables

m_r

is a scalar variable of type ipc_, that holds the number of residuals.

m_c

is a scalar variable of type ipc_, that holds the number of cohorts.

x

is a one-dimensional array of size n and type rpc_, that holds the values \(x\) of the optimization variables. The j-th component of x, j = 0, … , n-1, contains \(x_j\).

r

is a one-dimensional array of size m and type rpc_, that holds the residual \(r(x)\). The i-th component of r, j = 0, … , n-1, contains \(r_j(x)\).

g

is a one-dimensional array of size n and type rpc_, that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of g, j = 0, … , n-1, contains \(g_j\).

x_stat

is a one-dimensional array of size n and type ipc_, that gives the optimal status of the problem variables. If x_stat[j] is negative, the variable \(x_j\) most likely lies at its zero lower bound, while if it is zero, \(x_j\) is free of its bound (or unconstrained).

eval_r

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

ipc_ eval_r( ipc_ n, ipc_ m_r, const rpc_ x[],
             rpc_ r[], const void *userdata )

The components of the residual function \(r(x)\) evaluated at x= \(x\) must be assigned to r, and the function return value set to 0. If the evaluation is impossible at x, return should be set to a nonzero value. Data may be passed into eval_r via the structure userdata.

eval_jr_prod

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

ipc_ eval_jr_prod( ipc_ n, ipc_ m_r, const rpc_ x[], bool transpose,
                   const rpc_ v[],  rpc_ p[], bool got_jr,
                   const void *userdata )

The product \(p = J_r(x) v\) (if tranpose is false) or \(p = J_r^T(x) v\) (if tranpose is true) bewteen the product of the Jacobian \(J_r(x) = \nabla_{x}c_(x)\) or its tranpose with the vector v= \(v\) and the vector $ \(u\) must be returned in p, and the function return value set to 0. If the evaluation is impossible at x, return should be set to a nonzero value. Data may be passed into eval_jr_prod via the structure userdata.

eval_jr_scol

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

ipc_ eval_jr_scol( ipc_ n, ipc_ m_r, const rpc_ x[],
                   ipc_ index, rpc_ val[],
                   ipc_ row[], ipc_ nz, bool got_jr,
                   const void *userdata )

The nonzeros and corresponding row entries of the index-th colum of \(J_r(x)\) must be returned in val and row, respectively, together with the number of entries, nz, and the function return value set to 0. If the evaluation is impossible at x, return should be set to a nonzero value. Data may be passed into eval_jr_scol via the structure userdata.

eval_jr_sprod

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

ipc_ eval_jr_sprod( ipc_ n, ipc_ m_r, const rpc_ x[],
                    const bool transpose, const rpc_ v[],
                    rpc_ p[], const ipc_ free[], ipc_ n_free,
                    bool got_jr, const void *userdata )

The product \(J_r(x) v\) (if tranpose is false) or \(J_r^T(x) v\) (if tranpose is true) bewteen the Jacobian \(J_r(x) = \nabla_{x}r(x)\) or its tranpose with the vector v=\(v\) must be returned in p, and the function return value set to 0. If transpose is false, only the components free[0 : n_free-1] of \(v\) will be nonzero, while if transpose is true, only the components free[0 : n_free-1] of p should be set. If the evaluation is impossible at x, return should be set to a nonzero value. Data may be passed into eval_jr_sprod via the structure userdata.

w

is a one-dimensional array of size m_r and type rpc_ that holds the values \(w\) of the weights on the residuals in the least-squares objective function. It need not be set if the weights are all ones, and in this case can be NULL.

void snls_solve_reverse_with_jac(
    void **data,
    ipc_ *status,
    ipc_ *eval_status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    ipc_ jr_ne,
    rpc_ Jr_val[],
    const rpc_ w[]
)

Solve the simplex-constrained nonlinear least-squares problem when the Jacobian \(J_r(x)\) may be computed by the calling program.

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.

  • -3

    The restriction n > 0 or requirement that type contains its relevant string ‘dense’, ‘coordinate’, ‘sparse_by_rows’, ‘diagonal’ or ‘absent’ has been violated.

  • -9

    The analysis phase of the factorization failed; the return status from the factorization package is given in the component inform.factor_status

  • -10

    The factorization failed; the return status from the factorization package is given in the component inform.factor_status.

  • -11

    The solution of a set of linear equations using factors from the factorization package failed; the return status from the factorization package is given in the component inform.factor_status.

  • -16

    The problem is so ill-conditioned that further progress is impossible.

  • -17

    The step is too small to make further impact.

  • -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.

  • -82

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

  • 2

    The user should compute the vector of residuals \(r(x)\) at the point \(x\) indicated in x and then re-enter the function. The required value should be set in r, and eval_status should be set to 0. If the user is unable to evaluate \(r(x)\) for instance, if the function is undefined at \(x\) the user need not set r, but should then set eval_status to a non-zero value.

  • 3

    The user should compute the Jacobian of the vector of residual functions, \(J_r(x) = \nabla_x r(x)\), at the point \(x\) indicated in x and then re-enter the function. The l-th component of the Jacobian stored according to the scheme specified for the remainder of \(J_r\) in the earlier call to snls_import should be set in Jr_val[l], for l = 0, …, Jr_ne-1 and eval_status should be set to 0. If the user is unable to evaluate a component of \(J_r\) for instance, if a component of the matrix is undefined at \(x\) the user need not set Jr_val, but should then set eval_status to a non-zero value.

eval_status

is a scalar variable of type ipc_, that is used to indicate if objective function/gradient/Hessian values can be provided (see above)

n

is a scalar variable of type ipc_, that holds the number of variables

m_r

is a scalar variable of type ipc_, that holds the number of residuals.

m_c

is a scalar variable of type ipc_, that holds the number of cohorts.

x

is a one-dimensional array of size n and type rpc_, that holds the values \(x\) of the optimization variables. The j-th component of x, j = 0, … , n-1, contains \(x_j\).

r

is a one-dimensional array of size m and type rpc_, that holds the residual \(r(x)\). The i-th component of r, j = 0, … , n-1, contains \(r_j(x)\). See status = 2, above, for more details.

g

is a one-dimensional array of size n and type rpc_, that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of g, j = 0, … , n-1, contains \(g_j\).

x_stat

is a one-dimensional array of size n and type ipc_, that gives the optimal status of the problem variables. If x_stat[j] is negative, the variable \(x_j\) most likely lies at its zero lower bound, while if it is zero, \(x_j\) is free of its bound (or unconstrained).

jr_ne

is a scalar variable of type ipc_, that holds the number of entries in the Jacobian matrix \(J_r\).

Jr_val

is a one-dimensional array of size jr_ne and type rpc_, that holds the values of the entries of the Jacobian matrix \(J_r\) in any of the available storage schemes. See status = 3, above, for more details.

w

is a one-dimensional array of size m_r and type rpc_ that holds the values \(w\) of the weights on the residuals in the least-squares objective function. It need not be set if the weights are all ones, and in this case can be NULL.

void snls_solve_reverse_with_jacprod(
    void **data,
    ipc_ *status,
    ipc_ *eval_status,
    ipc_ n,
    ipc_ m_r,
    ipc_ m_c,
    rpc_ x[],
    rpc_ y[],
    rpc_ z[],
    rpc_ r[],
    rpc_ g[],
    ipc_ x_stat[],
    rpc_ v[],
    ipc_ iv[],
    rpc_ v[],
    ipc_ *lvl,
    ipc_ *lvu,
    ipc_ *index,
    const rpc_ p[],
    const ipc_ ip[],
    ipc_ lp,
    const rpc_ w[]
)

Solve the simplex-constrained nonlinear least-squares problem when the products of the Jacobian \(J_r(x)\) and its transpose with specified vectors may be computed by the calling program.

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.

  • -3

    The restriction n > 0 or requirement that type contains its relevant string ‘dense’, ‘coordinate’, ‘sparse_by_rows’, ‘diagonal’ or ‘absent’ has been violated.

  • -9

    The analysis phase of the factorization failed; the return status from the factorization package is given in the component inform.factor_status

  • -10

    The factorization failed; the return status from the factorization package is given in the component inform.factor_status.

  • -11

    The solution of a set of linear equations using factors from the factorization package failed; the return status from the factorization package is given in the component inform.factor_status.

  • -16

    The problem is so ill-conditioned that further progress is impossible.

  • -17

    The step is too small to make further impact.

  • -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.

  • -82

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

  • 2

    The user should compute the vector of residuals \(r(x)\) at the point \(x\) indicated in x and then re-enter the function. The required value should be set in r, and eval_status should be set to 0. If the user is unable to evaluate \(r(x)\) for instance, if the function is undefined at \(x\) the user need not set r, but should then set eval_status to a non-zero value.

  • 4

    The user should compute the product \(p = J_r(x) v\), at the point \(x\) indicated in x, between the product of the Jacobian \(J_r(x) = \nabla_{x}c_(x)\) with the vector v= \(v\), and then re-enter the function. The result should be set in p, and eval_status should be set to 0. If the user is unable to evaluate the product, for instance, if the Jacobian is undefined at \(x\) the user need not set p, but should then set eval_status to a non-zero value.

  • 5

    The user should compute the product \(p = J_r^T(x) v\), at the point \(x\) indicated in x, between the product of the transpose of the Jacobian \(J_r(x) = \nabla_{x}c_(x)\) with the vector v= \(v\), and then re-enter the function. The result should be set in p, and eval_status should be set to 0. If the user is unable to evaluate the product, for instance, if the Jacobian is undefined at \(x\) the user need not set p, but should then set eval_status to a non-zero value.

  • 6

    The user should compute the \(j\)-th column of \(J_r(x)\), with \(j\) provided in index, at the point \(x\) given in x. The resulting nonzeros and their corresponding row indices of the \(j\)-th column of \(J_r(x)\) must be placed in p[0:lp-1] and ip[0:lp-1] with lp set accordingly, and eval_status should be set to 0. If the user is unable to evaluate the column, for instance, if the Jacobian is undefined at \(x\) the user need not set p, ip and nz but should then set eval_status to a non-zero value.

  • 7

    The user should compute the product \(p = J_r(x) v\) involving the residual Jacobian \(J_r(x)\) at the point \(x\), given in x, and a given sparse vector \(v\), whose nonzeros are in positions iv[lvl:lvu] of v. The resulting \(p\) should be placed in p and eval_status should be set to 0. If the user is unable to evaluate the product, for instance, if the Jacobian is undefined at \(x\) the user need not set p, but should then set eval_status to a non-zero value.

  • 8

    The user should compute selected components of the product \(p = J_r^T(x) v\) involving the transpose of the residual Jacobian \(J_r(x)\) at the point \(x\), given in x, and a given vector \(v\). Only components iv[lvl:lvu] of \(p\) should be computed, and recorded in p[iv[lvl:lvu]], and eval_status should be set to 0. If the user is unable to evaluate the product, for instance, if the Jacobian is undefined at \(x\) the user need not set p, but should then set eval_status to a non-zero value.

  • 9

    The user has the opportunity to replace the estimate \(x\) in x by an improved value \(x^+\) for which \(f(x^+) \leq f(x)\); in that case r must also be reset to hold \(r(x^+)\).

eval_status

is a scalar variable of type ipc_, that is used to indicate if objective function/gradient/Hessian values can be provided (see above)

n

is a scalar variable of type ipc_, that holds the number of variables

m_r

is a scalar variable of type ipc_, that holds the number of residuals.

m_c

is a scalar variable of type ipc_, that holds the number of cohorts.

x

is a one-dimensional array of size n and type rpc_, that holds the values \(x\) of the optimization variables. The j-th component of x, j = 0, … , n-1, contains \(x_j\).

r

is a one-dimensional array of size m and type rpc_, that holds the residual \(r(x)\). The i-th component of r, j = 0, … , n-1, contains \(r_j(x)\). See status = 2, above, for more details.

g

is a one-dimensional array of size n and type rpc_, that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of g, j = 0, … , n-1, contains \(g_j\).

x_stat

is a one-dimensional array of size n and type ipc_, that gives the optimal status of the problem variables. If x_stat[j] is negative, the variable \(x_j\) most likely lies at its zero lower bound, while if it is zero, \(x_j\) is free of its bound (or unconstrained).

v

is a one-dimensional array of size max(n,m_r) and type rpc_, that is used for reverse communication. See status = 4, 5, 7 and 8 above for more details.

iv

is a one-dimensional array of size max(n,m_r) and type ipc_, that is used for reverse communication. See status = 7 and 8 above for more details.

lvl

is a scalar variable of type ipc_, that is used for reverse communication. See status = 7 and 8 above for more details.

lvu

is a scalar variable of type ipc_, that is used for reverse communication. See status = 7 and 8 above for more details.

index

is a scalar variable of type ipc_, that is used for reverse communication. See status = 6 above for more details.

p

is a one-dimensional array of size max(n,m_r) and type rpc_, that is used for reverse communication. See status = 4 to 8 above for more details.

ip

is a one-dimensional array of size n and type ipc_, that is used for reverse communication. See status = 6 above for more details.

lp

is a scalar variable of type ipc_, that is used for reverse communication. See status = 6 above for more details.

w

is a one-dimensional array of size m_r and type rpc_ that holds the values \(w\) of the weights on the residuals in the least-squares objective function. It need not be set if the weights are all ones, and in this case can be NULL.

void snls_information(void **data, struct snls_inform_type* inform, ipc_ *status)

Provides output information

Parameters:

data

holds private internal data

inform

is a struct containing output information (see snls_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 snls_terminate(
    void **data,
    struct snls_control_type* control,
    struct snls_inform_type* inform
)

Deallocate all internal private storage

Parameters:

data

holds private internal data

control

is a struct containing control information (see snls_control_type)

inform

is a struct containing output information (see snls_inform_type)