adelie.adelie_core.constraint.ConstraintOneSidedADMM32#
- class adelie.adelie_core.constraint.ConstraintOneSidedADMM32#
Core constraint class for one-sided bound constraint with ADMM solver.
Methods
__init__
(self, sgn, b, max_iters, tol_abs, ...)buffer_size
(self)Returns the buffer size in unit of 8 bytes.
clear
(self)Clears internal data.
dual
(self, arg0, arg1)Returns the current dual variable in sparse format.
duals
(self)Returns the number of dual variables.
duals_nnz
(self)Returns the number of non-zero dual values.
gradient
(self, x, out)Computes the gradient of the Lagrangian.
gradient_static
(self, x, mu, out)Computes the gradient of the Lagrangian.
primals
(self)Returns the number of primal variables.
project
(self, x)Computes a projection onto the feasible set.
solve
(self, x, quad, linear, l1, l2, Q, buffer)Computes the block-coordinate update.
solve_zero
(self, arg0, arg1)Solves the zero primal KKT condition problem.
Attributes
Number of duals.
Number of primals.
- __init__(self: adelie.adelie_core.constraint.ConstraintOneSidedADMM32, sgn: numpy.ndarray[numpy.float32[1, n]], b: numpy.ndarray[numpy.float32[1, n]], max_iters: int, tol_abs: float, tol_rel: float, rho: float) None #
- buffer_size(self: adelie.adelie_core.constraint.ConstraintBase32) int #
Returns the buffer size in unit of 8 bytes.
- Returns:
- sizeint
Buffer size in unit of 8 bytes.
- clear(self: adelie.adelie_core.constraint.ConstraintBase32) None #
Clears internal data.
The state of the constraint object must return back to that of the initial construction.
Warning
This function is not thread-safe!
- dual(self: adelie.adelie_core.constraint.ConstraintBase32, arg0: numpy.ndarray[numpy.int64[1, n], flags.writeable], arg1: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Returns the current dual variable in sparse format.
- Parameters:
- indices(nnz,) ndarray
The indices with non-zero dual values. The size must be at least the value returned by
duals_nnz()
.- values(nnz,) ndarray
The non-zero dual values corresponding to
indices
. The size must be at least the value returned byduals_nnz()
.
- duals(self: adelie.adelie_core.constraint.ConstraintBase32) int #
Returns the number of dual variables.
- Returns:
- sizeint
Number of dual variables.
- duals_nnz(self: adelie.adelie_core.constraint.ConstraintBase32) int #
Returns the number of non-zero dual values.
- Returns:
- nnzint
Number of non-zero dual values.
- gradient(self: adelie.adelie_core.constraint.ConstraintBase32, x: numpy.ndarray[numpy.float32[1, n]], out: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes the gradient of the Lagrangian.
The gradient of the Lagrangian (with respect to the primal) is given by
where
is the Jacobian of at and is the dual solution from the last call tosolve()
.- Parameters:
- x(d,) ndarray
The primal
at which to evaluate the gradient.- out(d,) ndarray
The output vector to store the gradient.
- gradient_static(self: adelie.adelie_core.constraint.ConstraintBase32, x: numpy.ndarray[numpy.float32[1, n]], mu: numpy.ndarray[numpy.float32[1, n]], out: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes the gradient of the Lagrangian.
The gradient of the Lagrangian (with respect to the primal) is given by
where
is the Jacobian of at and is the dual given bymu
.- Parameters:
- x(d,) ndarray
The primal
at which to evaluate the gradient.- mu(m,) ndarray
The dual
at which to evaluate the gradient.- out(d,) ndarray
The output vector to store the gradient.
- primals(self: adelie.adelie_core.constraint.ConstraintBase32) int #
Returns the number of primal variables.
- Returns:
- sizeint
Number of primal variables.
- project(self: adelie.adelie_core.constraint.ConstraintBase32, x: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a projection onto the feasible set.
The feasible set is defined by
. A projection can be user-defined, that is, the user may define any norm such that the function returns a solution toThis function is only used by the solver after convergence to attempt to bring the coordinates into the feasible set. If not overriden, it will perform a no-op, assuming
is already feasible.- Parameters:
- x(d,) ndarray
The primal
to project onto the feasible set. The output is stored back in this argument.
- solve(self: adelie.adelie_core.constraint.ConstraintBase32, x: numpy.ndarray[numpy.float32[1, n], flags.writeable], quad: numpy.ndarray[numpy.float32[1, n]], linear: numpy.ndarray[numpy.float32[1, n]], l1: float, l2: float, Q: numpy.ndarray[numpy.float32[m, n], flags.f_contiguous], buffer: numpy.ndarray[numpy.uint64[1, n], flags.writeable]) None #
Computes the block-coordinate update.
The block-coordinate update is given by solving
where
defines the current constraint.Warning
This function is not thread-safe!
- Parameters:
- x(d,) ndarray
The primal
. The passed-in values may be used as a warm-start for the internal solver. The output is stored back in this argument.- quad(d,) ndarray
The quadratic component
.- linear(d,) ndarray
The linear component
.- l1float
The first regularization
.- l2float
The second regularization
.- Q(d, d) ndarray
Orthogonal matrix
.- buffer(b,) ndarray
Buffer of type
uint64_t
aligned at 8 bytes. The size must be at least as large asbuffer_size()
.
- solve_zero(self: adelie.adelie_core.constraint.ConstraintBase32, arg0: numpy.ndarray[numpy.float32[1, n]], arg1: numpy.ndarray[numpy.uint64[1, n], flags.writeable]) float #
Solves the zero primal KKT condition problem.
The zero primal KKT condition problem is given by
where
is the current constraint function and is the dual variable. It is advised, but not necessary, that the object stores the solution internally so that a subsequent call todual()
will return the solution.Warning
This function is not thread-safe!
- Parameters:
- v(d,) ndarray
The vector
.- buffer(b,) ndarray
Buffer of type
uint64_t
aligned at 8 bytes. The size must be at least as large asbuffer_size()
.
- Returns:
- normfloat
The optimal objective for the zero primal KKT condition problem.
- dual_size#
Number of duals.
- primal_size#
Number of primals.