adjust {rspa} | R Documentation |
DEPRECATED Adjust a data to meet linear (in)equality constraints
Description
Adjust a vector \boldsymbol{x}
to meet
constraints \boldsymbol{Ax} \leq \boldsymbol{b}
.
As of version 0.2 this function is deprecated. Please use
sparse_project
from pacakgelintools
to replaceadjust.sparseConstraints
Usage
adjust(object, ...)
## S3 method for class 'editmatrix'
adjust(object, x, w = rep(1, length(x)), method = c("dense", "sparse"), ...)
## S3 method for class 'sparseConstraints'
adjust(object, x, w = rep(1, length(x)), tol = 0.01, maxiter = 1000L, ...)
## S3 method for class 'matrix'
adjust(
object,
b,
x,
neq = length(b),
w = rep(1, length(x)),
tol = 0.01,
maxiter = 1000L,
...
)
Arguments
object |
an |
... |
Arguments to be passed to other methods |
x |
The vector to be adjusted |
w |
A positive weight vector |
method |
use dense or sparse matrix method. |
tol |
The maximum allowed deviation from the constraints (see details). |
maxiter |
maximum number of iterations |
b |
Constant vector of the constraint system |
neq |
the first |
Value
Object of class adjusted
.
Details
adjust
is a generic function allowing several definitions of the constraints in object
.
editmatrix
:Ifobject
is aneditmatrix
, the function will try to match the names ofx
to the variable names inobject
before further processing. In that case thelength
ofx
is unimportant, as long as all variables inobject
are also inx
. Depending on the choice ofmethod
,object
is converted tomatrix
orsparseConstraints
format before solving the adjustment problem.matrix
: Ifobject
is amatrix
, you also need to provide the constant vectorb
and the number of equationsneq
to define the problem. It is assumed that the firstneq
rows ofobject
and the firstnew
elements ofb
correspond to equalities. No names are matched, sox
must be in the correct order and must be of the right dimension. SeesparseConstraints
on how to translate amatrix
problem to the sparse version.sparseConstraints
: Ifobject
is of classsparseConstraints
, the sparse method is used to adjustx
. Some basic checks onx
andw
are performed, but no attempt is made to match names ofx
to those ofobject
.
The tolerance tol
is defined as the maximum absolute value of the difference vector
\boldsymbol{Ax}-\boldsymbol{b}
for equalities. For inequalities, the difference vector
is set to zero when it's value is lesser than zero (i.e. when the restriction is obeyed). The
function keeps iterating until either the tolerance is met, the number of allowed iterations is
exceeded or divergence is detected.
Note
adjust
does not perform any consistency checks. When the system of constraints is
contradictory (e.g. x>1
and x<0
) this will result in either divergence
or in exceeding the number of iterations.