Adjust a vector \(\boldsymbol{x}\) to meet constraints \(\boldsymbol{Ax} \leq \boldsymbol{b}\). As of version 0.2 this function is deprecated. Please use
project
from package lintools
to replace adjust.matrix
sparse_project
from pacakge lintools
to replace adjust.sparseConstraints
adjust(object, ...)# S3 method for editmatrix
adjust(object, x, w = rep(1, length(x)), method = c("dense", "sparse"), ...)
# S3 method for sparseConstraints
adjust(object, x, w = rep(1, length(x)), tol = 0.01, maxiter = 1000L, ...)
# S3 method for matrix
adjust(
object,
b,
x,
neq = length(b),
w = rep(1, length(x)),
tol = 0.01,
maxiter = 1000L,
...
)
Object of class adjusted
.
an R
object describing constraints (see details)
Arguments to be passed to other methods
The vector to be adjusted
A positive weight vector
use dense or sparse matrix method.
The maximum allowed deviation from the constraints (see details).
maximum number of iterations
Constant vector of the constraint system \(Ax\leq b\)
the first neq
linear relations are equalities.
adjust
is a generic function allowing several definitions of the constraints in object
.
editmatrix
:If object
is an editmatrix
, the function will
try to match the names of x
to the variable names in object
before further
processing. In that case the length
of x
is unimportant, as long as all variables in object
are also in x
. Depending on the choice of method
, object
is converted to matrix
or
sparseConstraints
format before solving the adjustment problem.
matrix
: If object
is a matrix
, you also need to provide the constant vector
b
and the number of equations neq
to define the problem. It is assumed that the first
neq
rows of object
and the first new
elements of b
correspond to equalities. No names are matched, so x
must be in the correct order and must be of the right dimension.
See sparseConstraints
on how to translate
a matrix
problem to the sparse version.
sparseConstraints
: If object
is of class sparseConstraints
,
the sparse method is used to adjust x
. Some basic checks on x
and w
are performed, but no attempt is made to match names of x
to those of object
.
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.