re pseudo inverse
On the point of generalised inverses - GINV is usually taken to mean the
moore-penrose pseudo inverse - this is the least squares projection.
There are others - e.g. the Drazin inverse which amounts to diagonalisation
- of course this inverse may not be available in R.
Gerard
"Gabor
Grothendieck"
<ggrothendieck at gm To
ail.com> "Chris Line"
Sent by: <chris.line at tibra.com.au>
r-help-bounces at r- cc
project.org "r-help at r-project.org"
<r-help at r-project.org>
Subject
11/12/2008 12:14 Re: [R] Simplex function in R
Try the pseudo inverse:
m <- rbind(c(1, 1, 1), c(1, 0, 1), c(0, 1, 0))
b <- c(5, 2, 3)
library(MASS)
ginv(m) %*% b
On Thu, Dec 11, 2008 at 2:20 AM, Chris Line <chris.line at tibra.com.au>
wrote:
I have a set of linear equations and would like to find any feasible
solution. A simplex solution works in Case 1 below, but not in Case 2. I
would be grateful for any help.
Case 1: Find any feasible solution for the set of linear equations:
a + b + c = 5
a + b + 0c = 4
0a + b + c = 4
Solution - a feasible (and unique) solution is a=1, b=3, c=1.
The following R code returns a feasible solution:
A3M = matrix(c(1,1,0,1,1,1,1,0,1),nrow=3)
b3M = matrix(c(5,4,4),ncol=1)
A1M = matrix(c(1,0,0,0,1,0,0,0,1),nrow=3)
b1M = matrix(c(10,10,10),ncol=1)
AM = matrix(c(1,1,1),nrow=1)
simplex(a = AM, A1 = A1M, b1 = b1M, A2 = NULL, b2 = NULL, A3 = A3M, b3 =
b3M, maxi = TRUE)
Case 2: Find any feasible solution for the set of linear equations
a + b + c = 5
a + 0b + c = 2
0a + b + 0c = 3
Solution - one feasible solution of many is a=1, b=3, c=1. There are
infinite possible solutions in Case 2.
However, the following R code fails to return any feasible solution:
A3M = matrix(c(1,1,0,1,0,1,1,1,0),nrow=3)
b3M = matrix(c(5,2,3),ncol=1)
A1M = matrix(c(1,0,0,0,1,0,0,0,1),nrow=3)
b1M = matrix(c(10,10,10),ncol=1)
AM = matrix(c(1,1,1),nrow=1)
simplex(a = AM, A1 = A1M, b1 = b1M, A2 = NULL, b2 = NULL, A3 = A3M, b3 =
b3M, maxi = TRUE)
The code returns the error:
Error in A.out[, basic] <- iden(M) : subscript out of bounds
Am I using the Simplex function incorrectly? There may be a better way
to approach the problem of finding a feasible solution.
Cheers,
Chris.
The contents of this email including any attachments are confidential. If
you have received this email in error, please advise the sender by return
email and delete this email. Any unauthorised use of the contents of the
email is prohibited and you must not disseminate, copy or distribute the
message or use the information contained in the email or its attachments in
any way.
The views or opinions expressed are the author's own and may not reflect
the views or opinions of Tibra. Tibra does not guarantee the integrity of
any emails or attached files. E-mails may be interfered with, may contain
computer viruses or other defects. Under no circumstances do we accept
liability for any loss or damage which may result from your receipt of this
message or any attachments.
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
**********************************************************************************
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. It is the policy of the Department of Justice, Equality and Law Reform and the Agencies and Offices using its IT services to disallow the sending of offensive material.
Should you consider that the material contained in this message is offensive you should contact the sender immediately and also mailminder[at]justice.ie.
Is le haghaidh an duine n? an eintitis ar a bhfuil s? d?rithe, agus le haghaidh an duine n? an eintitis sin amh?in, a bhearta?tear an fhaisn?is a tarchuireadh agus f?adfaidh s? go bhfuil ?bhar faoi r?n agus/n? faoi phribhl?id inti. Toirmisctear aon athbhreithni?, atarchur n? leathadh a dh?anamh ar an bhfaisn?is seo, aon ?s?id eile a bhaint aisti n? aon ghn?omh a dh?anamh ar a hiontaoibh, ag daoine n? ag eintitis seachas an faighteoir beartaithe. M? fuair t? ? seo tr? dhearmad, t?igh i dteagmh?il leis an seolt?ir, le do thoil, agus scrios an t-?bhar as aon r?omhaire. Is ? beartas na Roinne Dl? agus Cirt, Comhionannais agus Athch?irithe Dl?, agus na nOif?g? agus na nGn?omhaireachta? a ?s?ideann seirbh?s? TF na Roinne, seoladh ?bhair chol?il a dh?chead?.
M?s rud ? go measann t? gur ?bhar col?il at? san ?bhar at? sa teachtaireacht seo is ceart duit dul i dteagmh?il leis an seolt?ir l?ithreach agus le mailminder[ag]justice.ie chomh maith.
***********************************************************************************