Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Ravi Varadhan
I would recommend that you use auglag() rather than constrOptim.nl() in the package "alabama." It is a better algorithm, and it does not require feasible starting values. Best, Ravi -Original Message- From: Rainer M Krug [mailto:rai...@krugs.de] Sent: Thursday, October 01, 2015 3:37

Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Rainer M Krug
Envoyé de mon iPhone > Le 1 oct. 2015 à 15:17, Ravi Varadhan a écrit : > > I would recommend that you use auglag() rather than constrOptim.nl() in the > package "alabama." It is a better algorithm, and it does not require > feasible starting values. Thanks - that was one question I wanted

Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Rainer M Krug
Ravi Varadhan writes: > Hi Rainer, > It is very simple to specify the constraints (linear or nonlinear) in > "alabama" . They are specified in a function called `hin', where the > constraints are written such that they are positive. OK - I somehow missed the part that, when the values x are val

Re: [R] optimizing with non-linear constraints

2015-09-30 Thread Ravi Varadhan
Hi Rainer, It is very simple to specify the constraints (linear or nonlinear) in "alabama" . They are specified in a function called `hin', where the constraints are written such that they are positive. Your two nonlinear constraints would be written as follows: hin <- function(x, LAI) { h <-

Re: [R] optimizing code

2013-10-10 Thread Carl Witthoft
FMRPROG wrote > I am generating random numbers from a normal distribution using > [snip] > > I need to optimize the speed WITHOUT using the rnorm function but have no > idea how to do this. I assume I should minimise what goes in the loop? > > Any help would be very much appreciated. Looks like

Re: [R] Optimizing nested function with nlminb()

2012-11-23 Thread Berend Hasselman
On 22-11-2012, at 22:55, Дмитрий Островский wrote: > I am trying to optimize custom likelyhood with nlminb() > Arguments h and f are meant to be fixed. > > example.R: > > compute.hyper.log.likelyhood <- function(a, h, f) { > a1 <- a[1] > a2 <- a[2] > l <- 0.0 > for (j in 1:length(f)) { >

Re: [R] Optimizing

2012-11-17 Thread Gabor Grothendieck
On Wed, Nov 14, 2012 at 8:23 PM, Sam Asin wrote: > Hello, > > I am fairly new with R and am having trouble finding an optimal group. I > checked the help functions for the various optimize commands and it was a > little over my head. > > I have a dataset with 4 columns, name, type, value, and cos

Re: [R] Optimizing

2012-11-17 Thread R. Michael Weylandt
On Thu, Nov 15, 2012 at 7:49 PM, Sam Asin wrote: > Hey, > > It's actually not homework, what gave you that impression? Real data sets don't usually have people named A,B,C with wages 3,4,5. ;-) To your question at hand, it's close to a classic problem in combinatorial optimization known as the k

Re: [R] Optimizing

2012-11-15 Thread Sam Asin
Hey, It's actually not homework, what gave you that impression? I graduated in May and studied Math, economics, and international relations, so I don't have much of a programming background. This is a project that I'm working on out of personal interest. Obviously, I've tried doing some homewor

Re: [R] Optimizing

2012-11-14 Thread Bert Gunter
Sam: 1. Homework? R has a no homework policy. 2. But in any case, check out the Optimization task view on CRAN. You should be able to find something there that meets your needs. Of course, if something is "a little over your head," that's not an excuse, but rather an admission that you have to d

Re: [R] Optimizing variables represented in a matrix

2012-05-31 Thread nataraj
will try my best to explain it more. But please do reply. Regards, B.Nataraj -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, May 31, 2012 8:19 PM To: Nataraj B (ORLL-Biotech) Cc: r-help@r-project.org Subject: Re: [R] Optimizing variables represented

Re: [R] Optimizing variables represented in a matrix

2012-05-31 Thread Bert Gunter
Inline ... On Thu, May 31, 2012 at 9:09 AM, Kjetil Halvorsen wrote: > If you want an helpful answer, you must describe your real problem > MUCH    better! This is way too confused. Absolutely! -- But we certainly can say: > > Kjetil > > On Thu, May 31, 2012 at 7:37 AM,   wrote: >> >> Dear R-list

Re: [R] Optimizing variables represented in a matrix

2012-05-31 Thread Kjetil Halvorsen
If you want an helpful answer, you must describe your real problem MUCHbetter! This is way too confused. Kjetil On Thu, May 31, 2012 at 7:37 AM, wrote: > > Dear R-list members, > > I have a matrix with non-numeric variables in it and I have to optimize the > variables of the matrix in a fo

Re: [R] Optimizing variables represented in a matrix

2012-05-31 Thread David Winsemius
On May 31, 2012, at 7:37 AM, > wrote: Dear R-list members, I have a matrix with non-numeric variables in it and I have to optimize the variables of the matrix in a formula using optim routine of the stats4 package. I know the matrix can only take numeric data Some of the things you

Re: [R] Optimizing problem R

2012-05-24 Thread Petr Savicky
On Wed, May 23, 2012 at 10:56:43PM -0700, kylmala wrote: > Hi, > > and thanks for replying this. Yes, you are right that the term > min(24/bb,26/cc) is actually min(bb/24,cc/26) - my mistake. But still I > don't get it. If the objective function is > > #min(m1,m2,m3) > f.obj <- c(1, 1, 1) > > #

Re: [R] Optimizing problem R

2012-05-24 Thread kylmala
Hi, and thanks for replying this. Yes, you are right that the term min(24/bb,26/cc) is actually min(bb/24,cc/26) - my mistake. But still I don't get it. If the objective function is #min(m1,m2,m3) f.obj <- c(1, 1, 1) #and we now that # a+aa<=15 # b+bb+bbb<=35 # cc+ccc<=40 # so # 1a + 0b +

Re: [R] Optimizing problem R

2012-05-23 Thread Petr Savicky
On Wed, May 23, 2012 at 12:35:31AM -0700, kylmala wrote: > Hi, > > I have a problem with R optimization. I try to copy excel solver acts to R. > Solver has some problems with nonlinear optimisation. > > Suppose we have resources: (X,Y,Z)=(20, 30, 25) and services: > matrix(10,11,0, 13,12,10, 0,24

Re: [R] Optimizing problem R

2012-05-23 Thread kylmala
I'have tried to do something like that staring values: pars=c(x1=1,x2=1,x3=1,x4=1,x5=1,x6=1,x7=1) and the function f=function(pars){ min(pars[1]/10,pars[2]/11)+min(pars[3]/20,pars[4]/22,pars[5]/25)+min(pars[6]/36,pars[7]/28) } optim(pars,f) but how can I get the constraints in there also? --

Re: [R] Optimizing compilation of R

2010-11-12 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Patrick, thanks a lot. No, I am not using MKL, but I am going to try the flags you mention in your blog. Cheers, Rainer On 11/12/2010 03:58 PM, Richardson, Patrick wrote: > Rainer, > > The attached link might give you some insight. It's for co

Re: [R] Optimizing given two vectors of data (confusedSoul)

2010-06-25 Thread Prof. John C Nash
I am trying to estimate an Arrhenius-exponential model in R. I have one vector of data containing failure times, and another containing corresponding temperatures. I am trying to optimize a maximum likelihood function given BOTH these vectors. However, the optim command takes only one such vect

Re: [R] Optimizing given two vectors of data

2010-06-25 Thread Joris Meys
Optim uses vectors of _parameters_, not of data. You add a (likelihood) function, give initial values of the parameters, and get the optimized parameters back. See ?optim and the examples therein. It contains an example for optimization using multiple data columns. Cheers Joris On Fri, Jun 25, 20

Re: [R] Optimizing C code

2010-01-23 Thread Christophe Genolini
Duncan Murdoch a écrit : On 22/01/2010 12:52 PM, Christophe Genolini wrote: Thanks both of you. > > > Inf - Inf > [1] NaN So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev will be NA and !ISNAN(dev) will detect it... Sothe loop cool be 8.for(i = 0 ; i < taille ; i++)

Re: [R] Optimizing C code

2010-01-22 Thread Duncan Murdoch
On 22/01/2010 12:52 PM, Christophe Genolini wrote: Thanks both of you. > > > Inf - Inf > [1] NaN So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev will be NA and !ISNAN(dev) will detect it... Sothe loop cool be 8.for(i = 0 ; i < taille ; i++) { 10.dev = (x[i] -

Re: [R] Optimizing C code

2010-01-22 Thread Henrik Bengtsson
A side note: The NA vs NaN does not seem to play a role here, because: #define both_non_NA(a,b) (!ISNAN(a) && !ISNAN(b)) So, it is the same type of test used in line 9 and in line 11. /Henrik On Fri, Jan 22, 2010 at 9:52 AM, Christophe Genolini wrote: > Thanks both of you. > >> >> > Inf - Inf

Re: [R] Optimizing C code

2010-01-22 Thread Christophe Genolini
Thanks both of you. > Inf - Inf [1] NaN So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev will be NA and !ISNAN(dev) will detect it... Sothe loop cool be 8.for(i = 0 ; i < taille ; i++) { 10.dev = (x[i] - y[i]); 11.if(!ISNAN(dev)) { 12. dist +

Re: [R] Optimizing C code

2010-01-22 Thread Duncan Murdoch
Christophe Genolini wrote: Hi the list, I need to write some efficient distances function, so I read the code for the Euclidean distance. I do not understand the purpose of the line 11 : if x[i] and y[i] are not NA (line 9), can dev be NA ? As Romain said, the test is for NaN as well as N

Re: [R] Optimizing C code

2010-01-22 Thread Romain Francois
Bonjour Christophe, NA and NaN are different things... Actually this is tricky because NA is implemented as a special kind of NaN : See this extract of R_ext/Arith.h : int R_IsNA(double); /* True for R's NA only */ int R_IsNaN(double);/* True for special NaN, *not* for

Re: [R] optimizing function over x,y

2009-05-23 Thread Esmail
Ravi Varadhan wrote: Look at nlminb() or optim(), in particular the option `method = "L-BFGS-B"' or the function spg() in "BB" package. With these you can optimize over any number of variables. Ravi. Hi Ravi, Thanks for the leads, I'll take a look, though right now I have run into problems

Re: [R] optimizing function over x,y

2009-05-23 Thread Ravi Varadhan
Look at nlminb() or optim(), in particular the option `method = "L-BFGS-B"' or the function spg() in "BB" package. With these you can optimize over any number of variables. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Div

Re: [R] Optimizing Multiple Models...any suggestions?

2009-02-13 Thread Paul Heinrich Dietrich
Hi Max, Thanks for the suggestion, that's exactly what I was looking for. Thanks again. Paul -- View this message in context: http://www.nabble.com/Optimizing-Multiple-Models...any-suggestions--tp21979556p22006494.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] Optimizing Multiple Models...any suggestions?

2009-02-12 Thread Gabor Grothendieck
See: http://cran.r-project.org/web/views/Optimization.html On Thu, Feb 12, 2009 at 11:31 AM, Paul Heinrich Dietrich wrote: > > There are multiple marketing models in place to predict individual-level > probabilities of whether or not someone would respond to a solicitation, > whether or not they

Re: [R] optimizing speed of calculation (recursive product)

2008-09-03 Thread Uwe Ligges
Wolfgang Raffelsberger wrote: Dear list, I'm wondering how to optimize functions/processes like the one shown below (which simplifies something we're trying to do with very large datasets). In many cases I've noticed that using apply, sapply etc can help speeding up processes, but in this ca