[R] Optimize a function with Discrete inputs

loyolite270 loyolite270 at gmail.com
Thu Aug 2 12:58:53 CEST 2012


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(dataFrame[a,x[j]])
      }
    
    if(length(x)==1){
      sc1<-0
    }
    
    else{ 
       if(length(x)>1){
          for(i in 1:(length(x)-1)){
               for(j in (i+1):(length(x))){
                      sc1 <- sc1+abs(dataFrame[(x[i]-1),x[j]])
               }
          }
       }
    }
   score <- sc-sc1
   return(score)
 }

Given the value of "a",  i would like to use some optimization function (
value of x) to maximize the score, such that x can be any combination ?

Thanks






--
View this message in context: http://r.789695.n4.nabble.com/Optimize-a-function-with-Discrete-inputs-tp4638644p4638851.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list