Hello, Resending this message in "Plain-text". Thank you for the add to the list. I have written a R snippet to solve a non-linear problem using Optim solver. The parameters to be solved are supposed to be in a matrix form as attached such that summation of columns is <=1 except for the first column. ie, P1.F1j + P2.F1j <=1 , P1.F2j + P2.F2j <=1 , P1.F3j + P2.F3j <=1 and so on.. Since OPTIM solver considers "pars" only as vector, I defined the vector as my.data.var <- vector("numeric",length = 12) and in the OPTIM solver, I passed it as optim(my.data.var, Error.func, method="L-BFGS-B", upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1)) Then in the error function, I stacked the vector into a matrix as : my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE) So, my first question is how do I define the constraints for each column except the first one in the OPTIM solver? As you can see, with the UPPER limit in the OPTIM solver, I can fix the upper bound, but there is no way for me set the summation constraint to <=1. Do I need a different solver for this scenario which allows me to use Matrix elements as parameters? Thanks! -------------- next part -------------- A non-text attachment was scrubbed... Name: Matrix.PNG Type: image/png Size: 3957 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160617/ac99d55b/attachment.png>
You need to send e-mail from a properly identifiable address (which has a correct name/e-mail address) and not a made-up scam address. You can easily be reported for impersonation! Ranjan On Fri, 17 Jun 2016 08:51:59 -0500 Narendra Modi <bjpmodi2016 at gmail.com> wrote:> Hello, > Resending this message in "Plain-text". > > Thank you for the add to the list. > > I have written a R snippet to solve a non-linear problem using Optim solver. > > The parameters to be solved are supposed to be in a matrix form as attached > > such that summation of columns is <=1 except for the first column. ie, > P1.F1j + P2.F1j <=1 , P1.F2j + P2.F2j <=1 , P1.F3j + P2.F3j <=1 and so > on.. > > Since OPTIM solver considers "pars" only as vector, I defined the vector as > > my.data.var <- vector("numeric",length = 12) > > and in the OPTIM solver, I passed it as > > optim(my.data.var, Error.func, method="L-BFGS-B", > upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1)) > > Then in the error function, I stacked the vector into a matrix as : > > my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE) > > So, my first question is how do I define the constraints for each column > except the first one in the OPTIM solver? As you can see, with the UPPER > limit in the OPTIM solver, I can fix the upper bound, but there is no way > for me set the summation constraint to <=1. > > Do I need a different solver for this scenario which allows me to use > Matrix elements as parameters? > > Thanks!-- Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses. ____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more!
Ooops. I can change that real quick. Any help on the problem itself Ranjan? Thanks! On Fri, Jun 17, 2016 at 9:22 AM, Ranjan Maitra < maitra.mbox.ignored at inbox.com> wrote:> You need to send e-mail from a properly identifiable address (which has a > correct name/e-mail address) and not a made-up scam address. You can easily > be reported for impersonation! > > Ranjan > > > On Fri, 17 Jun 2016 08:51:59 -0500 Narendra Modi <bjpmodi2016 at gmail.com> > wrote: > > > Hello, > > Resending this message in "Plain-text". > > > > Thank you for the add to the list. > > > > I have written a R snippet to solve a non-linear problem using Optim > solver. > > > > The parameters to be solved are supposed to be in a matrix form as > attached > > > > such that summation of columns is <=1 except for the first column. ie, > > P1.F1j + P2.F1j <=1 , P1.F2j + P2.F2j <=1 , P1.F3j + P2.F3j <=1 and so > > on.. > > > > Since OPTIM solver considers "pars" only as vector, I defined the vector > as > > > > my.data.var <- vector("numeric",length = 12) > > > > and in the OPTIM solver, I passed it as > > > > optim(my.data.var, Error.func, method="L-BFGS-B", > > upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1)) > > > > Then in the error function, I stacked the vector into a matrix as : > > > > my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE) > > > > So, my first question is how do I define the constraints for each column > > except the first one in the OPTIM solver? As you can see, with the UPPER > > limit in the OPTIM solver, I can fix the upper bound, but there is no way > > for me set the summation constraint to <=1. > > > > Do I need a different solver for this scenario which allows me to use > > Matrix elements as parameters? > > > > Thanks! > > > -- > Important Notice: This mailbox is ignored: e-mails are set to be deleted > on receipt. Please respond to the mailing list if appropriate. For those > needing to send personal or professional e-mail, please use appropriate > addresses. > > ____________________________________________________________ > FREE ONLINE PHOTOSHARING - Share your photos online with your friends and > family! > Visit http://www.inbox.com/photosharing to find out more! > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]