callable functions#
function bnls_initialize(T, INT, data, control, inform)
Set default control values and initialize private data
Parameters:
data |
holds private internal data |
control |
is a structure containing control information (see bnls_control_type) |
inform |
is a structure containing output information (see bnls_inform_type) |
function bnls_read_specfile(T, INT, control, 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/bnls/BNLS.template. See also Table 2.1 in the Fortran documentation provided in $GALAHAD/doc/bnls.pdf for a list of how these keywords relate to the components of the control structure.
Parameters:
control |
is a structure containing control information (see bnls_control_type) |
specfile |
is a one-dimensional array of type Vararg{Cchar} that must give the name of the specification file |
function bnls_import(T, INT, control, data, status, n, m_r, Jr_type, Jr_ne, Jr_row, Jr_col, Jr_ptr_ne, Jr_ptr)
Import problem data into internal storage prior to solution.
Parameters:
control |
is a structure whose members provide control parameters for the remaining procedures (see bnls_control_type) |
data |
holds private internal data |
status |
is a scalar variable of type INT that gives the exit status from the package. Possible values are:
|
n |
is a scalar variable of type INT that holds the number of variables. |
m_r |
is a scalar variable of type INT that holds the number of residuals. |
Jr_type |
is a one-dimensional array of type Vararg{Cchar} 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. |
Jr_ne |
is a scalar variable of type INT 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. |
Jr_row |
is a one-dimensional array of size Jr_ne and type INT that holds the row indices of \(J_r\) in the sparse co-ordinate storage scheme. It need not be set for any of the other schemes, and in this case can be C_NULL. |
Jr_col |
is a one-dimensional array of size Jr_ne and type INT 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 when the dense or diagonal storage schemes are used, and in this case can be C_NULL. |
J_ptr_ne |
is a scalar variable of type INT, 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. |
Jr_ptr |
is a one-dimensional array of size m+1 and type INT 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. It need not be set when the other schemes are used, and in this case can be C_NULL. |
function bnls_import_without_jac(T, INT, control, data, status, n, m_r)
Import problem data, excluding the structure of \(J_r(x)\), into internal storage prior to solution.
Parameters:
control |
is a structure whose members provide control parameters for the remaining procedures (see bnls_control_type) |
data |
holds private internal data |
status |
is a scalar variable of type INT that gives the exit status from the package. Possible values are:
|
n |
is a scalar variable of type INT that holds the number of variables. |
m_r |
is a scalar variable of type INT that holds the number of residuals. |
function bnls_reset_control(T, INT, control, data, status)
Reset control parameters after import if required.
Parameters:
control |
is a structure whose members provide control parameters for the remaining procedures (see bnls_control_type) |
data |
holds private internal data |
status |
is a scalar variable of type INT that gives the exit status from the package. Possible values are:
|
function bnls_solve_with_jac(T, INT, data, userdata, status, n, m_r, x_l, x_u, x, z, r, g, x_stat, eval_r, Jr_ne, eval_jr, 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 INT that gives the entry and exit status from the package. On initial entry, status must be set to 1. Possible exit values are:
|
n |
is a scalar variable of type INT that holds the number of variables. |
m_r |
is a scalar variable of type INT that holds the number of residuals. |
x_l |
is a one-dimensional array of size n and type T that holds the values \(x^l\) of the lower bounds on the optimization variables \(x\). The j-th component of |
x_u |
is a one-dimensional array of size n and type T that holds the values \(x^u\) of the upper bounds on the optimization variables \(x\). The j-th component of |
x |
is a one-dimensional array of size n and type T that holds the values \(x\) of the optimization variables. The j-th component of |
z |
is a one-dimensional array of size n and type T that holds the values \(z\) of the dual variables. The j-th component of |
r |
is a one-dimensional array of size m and type T that holds the residual \(r(x)\). The i-th component of |
g |
is a one-dimensional array of size n and type T that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of |
x_stat |
is a one-dimensional array of size n and type INT that gives the optimal status of the problem variables. If x_stat[j] is negative, 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: function eval_r(n, m_r, x, r, userdata) The componnts 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 |
Jr_ne |
is a scalar variable of type INT 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: function eval_jr(n, m_r, jr_ne, x, jr_val, userdata) The components of the Jacobian \(J_r = \nabla_x r(x\)) of
the residuals must be assigned to jr_val in the same order
as presented to bnls_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 |
w |
is a one-dimensional array of size m_r and type T 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 C_NULL. |
function bnls_solve_with_jacprod(T, INT, data, userdata, status, n, m_r, x_l, x_u, x, z, r, g, x_stat, eval_r, eval_jr_prod, eval_jr_prods, eval_jr_sprod, 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 INT that gives the entry and exit status from the package. On initial entry, status must be set to 1. Possible exit values are:
|
n |
is a scalar variable of type INT that holds the number of variables |
m_r |
is a scalar variable of type INT that holds the number of residuals. |
x_l |
is a one-dimensional array of size n and type T that holds the values \(x^l\) of the lower bounds on the optimization variables \(x\). The j-th component of |
x_u |
is a one-dimensional array of size n and type T that holds the values \(x^u\) of the upper bounds on the optimization variables \(x\). The j-th component of |
x |
is a one-dimensional array of size n and type T that holds the values \(x\) of the optimization variables. The j-th component of |
z |
is a one-dimensional array of size n and type T that holds the values \(z\) of the dual variables. The j-th component of |
r |
is a one-dimensional array of size m and type T that holds the residual \(r(x)\). The i-th component of |
g |
is a one-dimensional array of size n and type T that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of |
x_stat |
is a one-dimensional array of size n and type INT that gives the optimal status of the problem variables. If x_stat[j] is negative, 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: function eval_r(n, m_r, x, r, userdata) The componnts 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_jr_prod |
is a user-supplied function that must have the following signature: function eval_jr_prod(n, m_r, x, transpose, v, p, got_jr, userdata) The product \(p = J_r(x) v\) (if the Bool transpose
is false) or \(p = J_r^T(x) v\) (if tranpose is true) between the
Jacobian \(J_r(x) \nabla_{x}r_(x)\), evaluated at x=\(x\), or its
tranpose with the vector v=\(v\) 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_prods |
is a user-supplied function that must have the following signature: function eval_jr_prods(n, m_r, x, v, p, iv, lvl, lvu, ip, lp, got_jr, userdata) The product \(p = J_r(x) v\) bewteen the Jacobian
\(J_r(x) = \nabla_{x}r(x)\) evaluated at x\(=x\) with the vector
v=\(v\) must be returned in p, and the function return value
set to 0. Only the components iv[lvl:lvu] of \(v\) will be
nonzero. If ip or lp is C_NULL, the whole of p[1,m_r] should
be filled. Otherwise, only the lp nonzero components
p[ip[1:lp]] need be specified, and ip and lp returned
accordingly. If the evaluation is impossible at x, return
should be set to a nonzero value. Data may be passed into
|
eval_jr_sprod |
is a user-supplied function that must have the following signature: function eval_jr_sprod(n, m_r, x, transpose, v, p, free, n_free, got_jr, 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)\), evaluated at x=\(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[1:n_free] of \(v\) will be nonzero,
while if transpose is true, only the components free[1:n_free] 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 |
w |
is a one-dimensional array of size m and type T 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 C_NULL. |
function bnls_solve_reverse_with_jac(T, INT, data, status, eval_status, n, m_r, x_l, x_u, x, z, r, g, x_stat, jr_ne, Jr_val, 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 INT that gives the entry and exit status from the package. On initial entry, status must be set to 1. Possible exit values are:
|
eval_status |
is a scalar variable of type INT that is used to indicate if objective function/gradient/Hessian values can be provided (see above) |
n |
is a scalar variable of type INT that holds the number of variables |
m_r |
is a scalar variable of type INT that holds the number of residuals. |
x_l |
is a one-dimensional array of size n and type T that holds the values \(x^l\) of the lower bounds on the optimization variables \(x\). The j-th component of |
x_u |
is a one-dimensional array of size n and type T that holds the values \(x^u\) of the upper bounds on the optimization variables \(x\). The j-th component of |
x |
is a one-dimensional array of size n and type T that holds the values \(x\) of the optimization variables. The j-th component of |
z |
is a one-dimensional array of size n and type T that holds the values \(z\) of the dual variables. The j-th component of |
r |
is a one-dimensional array of size m and type T that holds the residual \(r(x)\). The i-th component of |
g |
is a one-dimensional array of size n and type T that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of |
x_stat |
is a one-dimensional array of size n and type INT that gives the optimal status of the problem variables. If x_stat[j] is negative, 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 INT 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 T 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 and type T 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 C_NULL. |
function bnls_solve_reverse_with_jacprod(T, INT, data, status, eval_status, n, m_r, x_l, x_u, x, z, r, g, x_stat, v, iv, lvl, lvu, p, ip, lp, 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 INT that gives the entry and exit status from the package. On initial entry, status must be set to 1. Possible exit values are:
|
eval_status |
is a scalar variable of type INT that is used to indicate if objective function/gradient/Hessian values can be provided (see above) |
n |
is a scalar variable of type INT that holds the number of variables |
m_r |
is a scalar variable of type INT that holds the number of residuals. |
x_l |
is a one-dimensional array of size n and type T that holds the values \(x^l\) of the lower bounds on the optimization variables \(x\). The j-th component of |
x_u |
is a one-dimensional array of size n and type T that holds the values \(x^u\) of the upper bounds on the optimization variables \(x\). The j-th component of |
x |
is a one-dimensional array of size n and type T that holds the values \(x\) of the optimization variables. The j-th component of |
z |
is a one-dimensional array of size n and type T that holds the values \(z\) of the dual variables. The j-th component of |
r |
is a one-dimensional array of size m and type T that holds the residual \(r(x)\). The i-th component of |
g |
is a one-dimensional array of size n and type T that holds the gradient \(g = \nabla_xf(x)\) of the objective function. The j-th component of |
x_stat |
is a one-dimensional array of size n and type INT that gives the optimal status of the problem variables. If x_stat[j] is negative, 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 T, 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 INT, that is used for reverse communication. See status = 6, 7 and 8 above for more details. |
lvl |
is a scalar variable of type INT, that is used for reverse communication. See status = 6, 7 and 8 above for more details. |
lvu |
is a scalar variable of type INT, that is used for reverse communication. See status = 6, 7 and 8 above for more details. |
p |
is a one-dimensional array of size max(n,m_r) and type T, 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 INT, that is used for reverse communication. See status = 7 above for more details. |
lp |
is a scalar variable of type INT, that is used for reverse communication. See status = 7 above for more details. |
w |
is a one-dimensional array of size m and type T 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 C_NULL. |
function bnls_information(T, INT, data, inform, status)
Provides output information
Parameters:
data |
holds private internal data |
inform |
is a structure containing output information (see bnls_inform_type) |
status |
is a scalar variable of type INT that gives the exit status from the package. Possible values are (currently):
|
function bnls_terminate(T, INT, data, control, inform)
Deallocate all internal private storage
Parameters:
data |
holds private internal data |
control |
is a structure containing control information (see bnls_control_type) |
inform |
is a structure containing output information (see bnls_inform_type) |