function y=gen_cerveza(t,N,GENSIZE,PARAM,INIT)

%GEN_CERVEZA		Function that generates the genes for the beer problem
%
% POP=GEN_CERVEZA(T,N,GENSIZE,RANGE,INIT)		
%
% If GENSIZE is a single value it generates a N*M numberic matrix of random float numbers with values in the range 
% RANGE(1)<=VALUES<=RANGE(2)
% If GENSIZE is a 2x1 or 1x2 array it generates a N*1 cell matrix, and in each cell there is an array of length
% GENSIZE(1)<=LENGHT<=GENSIZE(2) of random float numbers with values in the range RANGE(1)<=VALUES<=RANGE(2)
% INIT is the initial temperature
%
% T is not used but needs to be an input parameter to mantain the header for the FUNGEN functions
%
% See also IS_NEW, GA_NEWPOP

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 9: El Aprendizaje con Algoritmos Genéticos
% Autores: Bonifacio de Andres y Toro


PARAM=PARAM(:);
r=length(PARAM);
if r~=2
   error('The RANGE in gen_float must be a 2*1 or 1*2 array');
elseif PARAM(1)<PARAM(2)
   GENSIZE=GENSIZE(:);
   r=length(GENSIZE);
   if r==1
      y=round(10*(rand([N,GENSIZE])*(PARAM(2)-PARAM(1)) + PARAM(1)))/10;;
      y(:,1)=INIT;
   else
      x=cumsum([0;round(rand([N,1])*(GENSIZE(2)-GENSIZE(1)) + GENSIZE(1))]);
      aux=round(10*(rand([1,x(end)])*(PARAM(2)-PARAM(1)) + PARAM(1)))/10;;
      for i=1:N
         y{i,1}=aux(x(i)+1:x(i+1));
         y{i,1}(1)=INIT;
      end        
   end   
else
   error('RANGE(1)<RANGE(2) in gen_float');
end


