Leonardo Monasterio
2011-May-11 20:28 UTC
[R] Problem with constrained optimization with maxBFGS
Dear all,
I need to maximize the v:
v= D' W D
D is a column vector ( n , 1)
W is a given matrix (n, n)
subject to:
sum D= 1
(BTW, n is less than 300)
I´ve tried to use maxBFGS, as follows:
#####################################
objectiveFunction<-function(x)
{
return(t(D)%*%W%*%D)
}
Amat<-diag(nrow(D))
Amat<-rbind((rep(-1, nrow(D))), Amat)
bvec<-matrix( c(0), nrow(D)+1, 1)
bvec[1,1]<-c(1)
startValues=rep(1/nrow(D),nrow(D)) #Istart value is homogeneous distribution
res <<- maxBFGS(objectiveFunction, start=startValues,
constraints=list(ineqA=Amat, ineqB=bvec))
########################################
The outcome is equal to the startValues. I´ve tried several initial values
and nothing changes.
Please, what am I doing wrong? Any suggestion?
Thanks a lot!
Leo.
[[alternative HTML version deleted]]
Prof. John C Nash
2011-May-12 22:15 UTC
[R] Problem with constrained optimization with maxBFGS
Is this a homework problem in finding the largest eigensolution of W? If not, I'd be trying to maximize (D' W D)/ (D' D) using (n-1) values of D and setting one value to 1 -- hopefully a value that is not going to be zero. JN> > Date: Wed, 11 May 2011 17:28:54 -0300 > From: Leonardo Monasterio <leonardo.monasterio at gmail.com> > To: r-help at r-project.org > Subject: [R] Problem with constrained optimization with maxBFGS > Message-ID: <BANLkTimJ0quyHgPA2ycMzO4ZPkhgPomNbw at mail.gmail.com> > Content-Type: text/plain > > Dear all, > > I need to maximize the v: > > v= D' W D > > > D is a column vector ( n , 1) > W is a given matrix (n, n) > > subject to: > sum D= 1 > > (BTW, n is less than 300) > I?ve tried to use maxBFGS, as follows: > > ##################################### > objectiveFunction<-function(x) > { > return(t(D)%*%W%*%D) > } > > Amat<-diag(nrow(D)) > Amat<-rbind((rep(-1, nrow(D))), Amat) > bvec<-matrix( c(0), nrow(D)+1, 1) > bvec[1,1]<-c(1) > startValues=rep(1/nrow(D),nrow(D)) #Istart value is homogeneous distribution > res <<- maxBFGS(objectiveFunction, start=startValues, > constraints=list(ineqA=Amat, ineqB=bvec)) > ######################################## > The outcome is equal to the startValues. I?ve tried several initial values > and nothing changes. > Please, what am I doing wrong? Any suggestion? > > Thanks a lot! > > Leo. > > [[alternative HTML version deleted]] > > > > -
Seemingly Similar Threads
- Fwd: The results of your email commands
- R:Maximum likelihood estimation using BHHH and BFGS
- Mixed logit models with a random coefficient
- Structural equation models with R
- Need help with self-defined function to perform nonlinear regression and get prediction interval