www.pudn.com > SGAProToolboxVer.zip > DECODING.M


function [decimal_space]=decoding(min_confines,max_confines,binary_space,bits) 
 
%Decoding Function Of Simple Genetic Algorithm Program (Version 1.0.0.1 ) 
%Support multi-dimesion parameters 
%By chen yi ,CQU .QQ:2376635  Email:cdey@10mail.net  (April,17th,2002 AAPP dat) 
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
%Decoding is the second step in SGA(Simple Genetic Algorithm ) 
%this decoding function is deconding the binary value which coded by coding 
%function ,that is to say you should use coding function first 
%it can transfer binary value to decimal value  
%~ 
%Usage: 
%decimal_space=decoding(min_confines,max_confines,binary_space,bits,bits_No) 
% in the method of 'X=Decimal*decimal_step+min_confines' 
%~~ 
%decimal_space is the decimal number which from binary_space 
%min_confines is the minimum of input value in decimal-space 
%max_confines is the maximum of input value in decimal-space 
%~~~ 
%population is the random decimal value in  [min_confines,max_confines] 
% it is given by yourself and it must be integer and larger than 0 
%~~~~~~ 
%binary_space is the coded space in 0 or 1 
% 
%bits_No is the genetic position pointer of binary_space 
% 
%bits_sum is the total length of the binary_space of all the parameters 
% 
%bits is the length of every parameter 
%e.g.  
% f(x)=2x  x belong to [1,7] 
%[binary_space,bits]=coding(1,7,10,0.01) 
%e.g. 
% f(x)=1./a+sin(b)+exp(c)+log2(d)+10 , a,b,c,d belong to [1,7],[2,8],[3,9],[4,10] 
% [binary_space,bits_sum,bits]=coding([1,2,3,4],[7,8,9,10],10,[0.01,0.01,0.01,0.01]) 
% [decimal_space]=decoding([1,2,3,4],[7,8,9,10],binary_space,bits) 
 
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
%  See Also CODING ,SELECTION ,CROSSOVER,MUTATION,FITNESS, 
%           FITNESS_FUNCTION, SGA	  
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 
if     size(min_confines)~=size(max_confines) % min_confines & max_confines check 
       disp(':( Warning !! The size of min_confines&max_confines do not match !') 
       break;%Reinforce the robust of this function  
 
elseif (min_confines