adelie.constraint.linear#

adelie.constraint.linear(A: ndarray | csr_matrix | MatrixConstraintBase32 | MatrixConstraintBase64, lower: ndarray, upper: ndarray, *, vars: ndarray | None = None, copy: bool = False, method: str = 'proximal_newton', configs: dict | None = None, dtype: float32 | float64 | None = None)[source]#

Creates a linear constraint.

The linear constraint is given by \(\ell \leq A x \leq u\) where \(\ell \leq 0 \leq u\). This constraint object is intended to support general linear constraints. If \(A\) is structured (e.g. box constraint), it is more efficient to use specialized constraint types.

Parameters:
A(m, d) Union[ndarray, csr_matrix, MatrixConstraintBase32, MatrixConstraintBase64]

Constraint matrix \(A\).

lower(m,) ndarray

Lower bound \(\ell\).

upper(m,) ndarray

Upper bound \(u\).

varsndarray, optional

Equivalent to \(\mathrm{diag}(AA^\top)\). If None and A is ndarray or csr_matrix, it is computed internally. Otherwise, it must be explicitly provided by the user. Default is None.

copybool, optional

If True, a copy of the inputs are stored internally. Otherwise, a reference is stored instead. Default is False.

methodstr, optional

Method for solve(). It must be one of the following:

  • "proximal_newton": proximal Newton algorithm.

Default is "proximal_newton".

configsdict, optional

Configurations specific to method. For each method type, the following arguments are used:

  • "proximal_newton":
    max_itersint, optional

    Maximum number of proximal Newton iterations. Default is 100.

    tolfloat, optional

    Convergence tolerance for proximal Newton. Default is 1e-9.

    nnls_max_itersint, optional

    Maximum number of coordinate descent iterations for the non-negative least squares solver. Default is int(1e5).

    nnls_tolfloat, optional

    Convergence tolerance for the non-negative least squares solver. Default is 1e-7.

    pinball_max_itersint, optional

    Maximum number of coordinate descent iterations for the pinball least squares solver. Default is int(1e5).

    pinball_tolfloat, optional

    Convergence tolerance for the pinball least squares solver. Default is 1e-7.

    slackfloat, optional

    Slackness for backtracking when proximal Newton overshoots the boundary where primal is zero. The smaller the value, the less slack so that the backtrack takes the iterates closer to (but outside) the boundary.

    Warning

    If this value is too small, solve() may not converge!

    Default is 1e-4.

    n_threadsint, optional

    Number of threads. Default is 1.

If None, the default values are used. Default is None.

dtypeUnion[float32, float64], optional

The underlying data type. If None, it is inferred from A, lower, or upper, in which case one of them must have an underlying data type of numpy.float32 or numpy.float64. Default is None.

Returns:
wrap

Wrapper constraint object.