Hi Patrick, Actually, I feel just the opposite, i.e. it is not a good idea to use `T' for `TRUE'. I have been snared by this trap many a times in my early days with S-Plus and R. It is a good practice to use unabbreviated values.
Best, Ravi. -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Patrick Burns Sent: Wednesday, July 28, 2010 3:54 AM To: r-help@r-project.org; u.kleinwech...@uni-hohenheim.de Subject: Re: [R] T and F (was: Optimization problem with nonlinear constraint) Some care is in order: Using 'T' as a variable name is quite dangerous in R since it is an alias for 'TRUE'. Rules to live by: * Avoid using 'T' and 'F' as object names. * Use 'TRUE' and 'FALSE', not 'T' and 'F'. If you follow these, then you won't be tripped up, and you won't trip other people either. On 28/07/2010 08:31, Uli Kleinwechter wrote: > Dear Ravi, > > As I've already written to you, the problem indeed is to find a solution > to the transcendental equation y = x * T^(x-1), given y and T and the > optimization problem below only a workaround. > > John C. Nash has been so kind to help me on here. In case anyone faces a > similar problem in the future, the solution looks as follows: > > ***** > > func1 <- function(y,x,T){ > out <- x*T^(x-1)-y > return(out) > } > > # Assign the known values to y and T: > y <- 3 > T <- 123 > > root <- uniroot(func1,c(-10,100),y=y,T=T) > print(root) > > ******** > > Somewhat simpler than I thought.... > > Thanks again! > > Uli > > > > Am 26.07.2010 17:44, schrieb Ravi Varadhan: >> Hi Uli, >> >> I am not sure if this is the problem that you really want to solve. The >> answer is the solution to the equation y = x * T^(x-1), provided a >> solution >> exists. There is no optimization involved here. What is the real problem >> that you are trying to solve? >> >> If you want to solve a more meaningful constrained optimization >> problem, you >> may want to try the "abalama" package which I just put on CRAN. It can >> optimize smooth nonlinear functions subject to linear and nonlinear >> equality >> and inequality constraints. >> >> http://cran.r-project.org/web/packages/alabama/index.html >> >> Let me know if you run into any problems using it. >> >> Best, >> Ravi. >> >> >> -----Original Message----- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On >> Behalf Of Uli Kleinwechter >> Sent: Monday, July 26, 2010 10:16 AM >> To: r-help@r-project.org >> Subject: [R] Optimization problem with nonlinear constraint >> >> Dear all, >> >> I'm looking for a way to solve a simple optimization problem with a >> nonlinear constraint. An example would be >> >> max x s.t. y = x * T ^(x-1) >> >> where y and T are known values. >> >> optim() and constrOptim() do only allow for box or linear constraints, >> so I did not succedd here. I also found hints to donlp2 but this does >> not seem to be available anymore. >> >> Any hints are welcome, >> >> Uli >> > > ______________________________________________ > R-help@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. > -- Patrick Burns pbu...@pburns.seanet.com http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') ______________________________________________ R-help@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. ______________________________________________ R-help@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.