varranges: Calculates ranges of inverse variables in a linear inverse...

View source: R/varranges.R

varrangesR Documentation

Calculates ranges of inverse variables in a linear inverse problem

Description

Given the linear constraints

Ex=f

Gx>=h

and a set of "variables" described by the linear equations

Var = EqA.x+EqB

finds the minimum and maximum values of the variables by successively minimising and maximising each variable equation

Usage

varranges(E=NULL, F=NULL, G=NULL, H=NULL, EqA, EqB=NULL, 
  ispos=FALSE, tol=1e-8, verbose=TRUE, lower=NULL, upper=NULL)

Arguments

E

numeric matrix containing the coefficients of the equalities Ex=F.

F

numeric vector containing the right-hand side of the equalities.

G

numeric matrix containing the coefficients of the inequalities Gx>=H.

H

numeric vector containing the right-hand side of the inequalities.

EqA

numeric matrix containing the coefficients that define the variable equations.

EqB

numeric vector containing the right-hand side of the variable equations.

ispos

if TRUE, it is imposed that unknowns are positive quantities.

tol

tolerance for equality and inequality constraints.

verbose

logical to print warnings and messages.

upper, lower

vector containing upper and lower bounds on the unknowns. If one value, it is assumed to apply to all unknowns. If a vector, it should have a length equal to the number of unknowns; this vector can contain NA for unbounded variables. The upper and lower bounds are added to the inequality conditions G*x>=H.

Value

a 2-column matrix with the minimum and maximum value of each equation (variable)

Note

uses linear programming function lp from package lpSolve.

Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

References

Michel Berkelaar and others (2010). lpSolve: Interface to Lp_solve v. 5.5 to solve linear/integer programs. R package version 5.6.5. http://CRAN.R-project.org/package=lpSolve

See Also

Minkdiet, for a description of the Mink diet example.

xranges, to estimate ranges of inverse unknowns.

xsample, to randomly sample the lsei problem

lp: linear programming function from package lpSolve.

Examples

# Ranges in the contribution of food 3+4+5 in the diet of Mink (try ?Minkdiet)

E     <- rbind(Minkdiet$Prey, rep(1, 7))
F     <- c(Minkdiet$Mink, 1)
EqA   <- c(0, 0, 1, 1, 1, 0, 0)                    # sum of food 3,4,5
(isoA <- varranges(E, F, EqA = EqA, ispos = TRUE)) # ranges of part of food 3+4+5

# The same, but explicitly imposing positivity
varranges(E, F, EqA = EqA, G = diag(7), H = rep(0, 7)) 

# The same, but shorter - using lower bound:
varranges(E, F, EqA = EqA, lower=0) 


limSolve documentation built on May 29, 2024, 11:53 a.m.