function  newpop=repair_cerveza(t,pop,value,init)

% REPAIR_CERVEZA	 Function that checks that the genes are in the correct range, and if not it modifies them
%
% NEW_POP=REPAIR_CERVEZA(T,POP,RANGE,INIT) 
%
% It checks that all the genes of POP are between RANGE(1)<= POP <= RANGE(2), and if 
% not, it moves the incorrect values to the closest RANGE.
% 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_REPAIR

% 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


if iscell(pop)
   pop=cell2mat(pop)
end

newpop=pop;
l=find(pop>value(2));
newpop(l)=value(2);
l=find(pop<value(1));
newpop(l)=value(1);
newpop=round(10*newpop)/10;
newpop(:,1)=init;





