adelie.constraint.linear#
- adelie.constraint.linear(A: ndarray, lower: ndarray, upper: ndarray, *, svd: tuple | None = None, 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\).
- Parameters:
- A(m, d) ndarray
Constraint matrix \(A\).
- lower(m,) ndarray
Lower bound \(\ell\).
- upper(m,) ndarray
Upper bound \(u\).
- svdtuple, optional
A tuple
(u, d, vh)
as outputted bynumpy.linalg.svd()
. However,u
must have"F"
-ordering. IfNone
, it is computed internally. Default isNone
.- varsndarray, optional
Equivalent to
np.sum(A ** 2, axis=1)
. IfNone
, it is computed internally. Default isNone
.- copybool, optional
If
True
, a copy of the inputs are stored internally. Otherwise, a reference is stored instead. Default isFalse
.- 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_batch_sizeint, optional
Batch size of active dual variables to include at a time. Default is
10
.- nnls_max_itersint, optional
Maximum number of non-negative least squares iterations. Default is
int(1e5)
.- nnls_tolfloat, optional
Maximum number of non-negative least squares iterations. Default is
1e-9
.- cs_tolfloat, optional
Complementary slackness tolerance. Default is
1e-9
.- 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 isNone
.- dtypeUnion[float32, float64], optional
The underlying data type. If
None
, it is inferred fromA
,lower
, orupper
, in which case one of them must have an underlying data type ofnumpy.float32
ornumpy.float64
. Default isNone
.
- Returns:
- wrap
Wrapper constraint object.