Re: [R] Optimize a function with Discrete inputs

2012-08-02 Thread R. Michael Weylandt
On Thu, Aug 2, 2012 at 5:58 AM, loyolite270 wrote: > oh sorry .. > > The detailed description of the problem is given below > > dataFrame is matrix of dim 100X100 with some values Odd name for something that's not a dataFrame (i.e., data.frame != matrix) > a is a vector of length 1 > x is a

Re: [R] Optimize a function with Discrete inputs

2012-08-02 Thread loyolite270
oh sorry .. The detailed description of the problem is given below dataFrame is matrix of dim 100X100 with some values a is a vector of length 1 x is a vector of any length between 1 to 99 funcScore<-function(a,x){ sc<-0 sc1<-0 for(j in 1:(length(x))){ sc<-sc+abs(d

Re: [R] Optimize a function with Discrete inputs

2012-08-01 Thread R. Michael Weylandt
You'll have to give a more realistic description to get detailed help: otherwise, look up "combinatorial optimization" and "parallelization" for some generic pointers. Best, Michael On Wed, Aug 1, 2012 at 11:34 AM, loyolite270 wrote: > Thanks for the reply, but the example i have given above is

Re: [R] Optimize a function with Discrete inputs

2012-08-01 Thread loyolite270
Thanks for the reply, but the example i have given above is a sample function. I would be using a function with input vector of size more than 100 and the function will compute some score based on the 100 vector combinations. Since i don't want to do this computation sequentially for all these com

Re: [R] Optimize a function with Discrete inputs

2012-08-01 Thread peter dalgaard
On Aug 1, 2012, at 16:34 , Sarah Goslee wrote: > combn() gives ordered combinations, while expand.grid() gives all > combinations. ...and there's one more function that is designed to tabulate a function of two variables over a grid. And yet another one to find which value is max in an array

Re: [R] Optimize a function with Discrete inputs

2012-08-01 Thread Sarah Goslee
combn() gives ordered combinations, while expand.grid() gives all combinations. I'd give worked code but this hints at homework to me. Sarah On Wed, Aug 1, 2012 at 10:23 AM, Eik Vettorazzi wrote: > Hi, > not sure if that is what you are looking for, but have a look at > > cmb<-t(combn(c(0,3,5,8

Re: [R] Optimize a function with Discrete inputs

2012-08-01 Thread Eik Vettorazzi
Hi, not sure if that is what you are looking for, but have a look at cmb<-t(combn(c(0,3,5,8),2)) #get all pairs of combinations cbind(cmb,apply(cmb,1,diff)) #for each pair, get the difference cheers Am 01.08.2012 12:29, schrieb loyolite270: > Hi > > I need to optimize the below function: >