Learn R Programming

limSolve (version 1.4)

ldei: Weighted Least Distance Programming with equality and inequality constraints.

Description

Solves the following underdetermined inverse problem: $$\min(\sum {x_i}^2)$$ subject to $$Ex=f$$ $$Gx>=h$$

uses least distance programming subroutine ldp (FORTRAN) from Linpack

The model has to be UNDERdetermined, i.e. the number of independent equations < number of unknowns.

Usage

ldei(E, F, G=NULL, H=NULL,
  tol=sqrt(.Machine$double.eps), verbose=TRUE)

Arguments

E
numeric matrix containing the coefficients of the equality constraints $Ex=F$; if the columns of E have a names attribute, they will be used to label the output.
F
numeric vector containing the right-hand side of the equality constraints.
G
numeric matrix containing the coefficients of the inequality constraints $Gx>=H$; if the columns of G have a names attribute and the columns of E do not, they will be used to label the output.
H
numeric vector containing the right-hand side of the inequality constraints.
tol
tolerance (for singular value decomposition, equality and inequality constraints).
verbose
logical to print ldei error messages.

Value

  • a list containing:
  • Xvector containing the solution of the least distance with equalities and inequalities problem.
  • unconstrained.solutionvector containing the unconstrained solution of the least distance problem, i.e. ignoring $Gx>=h$.
  • residualNormscalar, the sum of absolute values of residuals of equalities and violated inequalities; should be zero or very small if the problem is feasible.
  • solutionNormscalar, the value of the quadratic function at the solution, i.e. the value of $\sum {w_i*x_i}^2$.
  • IsErrorlogical, TRUE if an error occurred.
  • typethe string "ldei", such that how the solution was obtained can be traced.

References

Lawson C.L.and Hanson R.J. 1974. Solving Least Squares Problems, Prentice-Hall

Lawson C.L.and Hanson R.J. 1995. Solving Least Squares Problems. SIAM classics in applied mathematics, Philadelphia. (reprint of book)

See Also

lsei, linp

ldp

Examples

Run this code
# parsimonious (simplest) solution of the mink diet problem
A <- rbind(Minkdiet$Prey,rep(1,7))
B <- c(Minkdiet$Mink,1)

parsimonious <- ldei(A,B,G=diag(7),H=rep(0,7))
data.frame(food=colnames(Minkdiet$Prey),fraction=parsimonious$X)
dotchart(x=as.vector(parsimonious$X),
         labels=colnames(Minkdiet$Prey),
         main="Diet composition of Mink extimated using ldei",
         xlab="fraction")

Run the code above in your browser using DataLab