adjust: DEPRECATED Adjust a data to meet linear (in)equality...

View source: R/adjust.R

adjustR Documentation

DEPRECATED Adjust a data to meet linear (in)equality constraints

Description

Adjust a vector \boldsymbol{x} to meet constraints \boldsymbol{Ax} ≤q \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

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 R object describing constraints (see details)

...

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 Ax≤q b

neq

the first neq linear relations are equalities.

Value

Object of class adjusted.

Details

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.

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.


rspa documentation built on Dec. 28, 2022, 1:09 a.m.