mercredi 22 juillet 2015

R-If Statement-Condition Length greater than 1-Golden section Search

I have been trying the golden section search algorithm in R to be used in ANN with stochastic Error Correction for Load Forecasting. There are a column of data and while executing i am getting a warning stating condition length greater than 1, only first element will be used, how to use all the elements of the column? the code ive written is

f1 = f(x1)
f2 = f(x2)
iteration = 0

   while (abs(upper.bound - lower.bound) > tolerance)
   {
      iteration = iteration + 1



      if (f1 < f2)

   {
         lower.bound = x2
         x2 = x1
         f2 = f1


         x1 = lower.bound + golden.ratio*(upper.bound - lower.bound)
         f1 = f(x1)
} 

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire