Lsei: Solves a linear inverse model using the least squares method.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Solves a linear inverse model using the least squares method

Input presented as:

Useful for solving overdetermined lims.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Lsei(...)
## S3 method for class 'double'
Lsei(...)
## S3 method for class 'lim'
Lsei(lim, exact = NULL, parsimonious = FALSE, ...)
## S3 method for class 'limfile'
Lsei(file, exact = NULL, parsimonious = FALSE, 
             verbose = TRUE, ...)
## S3 method for class 'character'
Lsei(...)

Arguments

lim

a list that contains the linear inverse model specification, as generated by function setup.limfile.

exact

if not NULL, a vector containing the numbers of the equations to be solved exactly; if NULL, all equations are considered exact.

parsimonious

if TRUE, also minimises the sum of squared unknowns.

file

name of the inverse input file.

verbose

if TRUE: when reading the file, prints warnings and messages to the screen.

...

other arguments passed to function lsei from packagelimSolve.

Details

Solves the following inverse problem:

\min(||AAx-BB||^2)

, the approximate equations subject to

Ex=F

, the mass balances

Gx>=H

, the constraints.

and where E and F make up the equations from A and B, as specified by vector exact.

AA and BB are the equations from A and B, NOT in vector exact.

in case exact = NULL, there are no approximate equations.

in case parsimonious = TRUE, then the sum of squared unknowns is also minimised. This means that AA is augmented with the unity matrix (of size Nunknowns) and BB contains Nunknowns additional zeros.

For overdetermined lim problems, for instance, the inverse equations may be split up in the mass balance equations which have to be exactly met and the other equations which have to be approximated.

This is, it is assumed that the first *NComponents* equations, the mass balances, should be met exactly and the call to the function is: Lsei(lim,exact = 1:lim$NComponents,...)

If the lim is underdetermined, an alternative is to use Ldei instead.

This will return the parsimonious solution.

The results should be similar with Lsei(...,parsimonious=TRUE).

In theory both Lsei.lim and Ldei should return the same value for underdetermined systems.

Value

a list containing:

X

vector containing the solution of the least squares problem.

residualNorm

scalar, the sum of residuals of equalities and violated inequalities.

solutionNorm

scalar, the value of the minimised quadratic function at the solution.

IsError

TRUE if an error occurred.

Error

error text.

type

lsei.

Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

References

K. H. Haskell and R. J. Hanson, An algorithm for linear least squares problems with equality and nonnegativity constraints, Report SAND77-0552, Sandia Laboratories, June 1978.

K. H. Haskell and R. J. Hanson, Selected algorithms for the linearly constrained least squares problem - a users guide, Report SAND78-1290, Sandia Laboratories,August 1979.

K. H. Haskell and R. J. Hanson, An algorithm for linear least squares problems with equality and nonnegativity constraints, Mathematical Programming 21 (1981), pp. 98-118.

R. J. Hanson and K. H. Haskell, Two algorithms for the linearly constrained least squares problem, ACM Transactions on Mathematical Software, September 1982.

See Also

lsei, the more general function from package limSolve

Linp, to solve the linear inverse problem by linear programming

Ldei, to solve the linear inverse problem by least distance programming

function lsei from packagelimSolve

Examples

1
  Lsei(LIMRigaAutumn, parsimonious = TRUE)

Example output

Loading required package: limSolve
Loading required package: diagram
Loading required package: shape
$X
               P1->CO2 Flow(P2,CO2)=ZeroOrder  Flow(Z,CO2)=ZeroOrder 
             17.225012              29.953988              30.195805 
 Flow(N,CO2)=ZeroOrder  Flow(B,CO2)=ZeroOrder Flow(CO2,P1)=ZeroOrder 
             13.402970             244.992226              31.318203 
Flow(CO2,P2)=ZeroOrder   Flow(P1,Z)=ZeroOrder   Flow(P1,N)=ZeroOrder 
             54.461797              10.494312               4.122970 
Flow(P1,DOC)=ZeroOrder      P1->Sedimentation Flow(P2,DOC)=ZeroOrder 
              1.565910               0.100000               2.723090 
  Flow(P2,Z)=ZeroOrder   Flow(P2,D)=ZeroOrder Flow(P2,Sedimentation) 
             16.797554               4.457164               0.340000 
 Flow(N,DOC)=ZeroOrder    Flow(N,Z)=ZeroOrder  Flow(Z,DOC)=ZeroOrder 
              0.000000               0.000000               3.963226 
   Flow(Z,D)=ZeroOrder       Z->Sedimentation    Flow(D,Z)=ZeroOrder 
              3.183226               0.780000              12.340390 
 Flow(D,DOC)=ZeroOrder       D->Sedimentation    Flow(B,N)=ZeroOrder 
              0.000000              13.920000               9.440000 
      B->Sedimentation  Flow(DOC,B)=ZeroOrder 
              0.000000             261.182226 

$residualNorm
[1] 5.245498e-12

$solutionNorm
[1] 135370.4

$IsError
[1] FALSE

$type
[1] "lsei"

LIM documentation built on May 2, 2019, 4:19 p.m.