Genetic Algoritm

rcbsimoes rcbsimoes at hotmail.com
Thu Jul 19 11:30:50 CEST 2012


ok, back again.

i've used the continuous optimization which worked great!

but now while trying to use discrete ga (or binary/integer as you call it),
i could not understand a couple of things. maybe you can make them clear...
please. ;)

1)
when you state binary length, here:
BinLen = get_param(ga_params,'binary_length') 
is this the string length produced by the algorithm regardless of the
dimension?

for instance,
if i have a 3 dimension problem which requires 2 bit lenght for each
variable (x='01', y='00', z='11')
should i set dimension as one, and 6 bits as string lenght?
or should i set dimension to 3 and lenght to 2??

2)
this question is related to the other one also.
your original rastingin is a 2 dimension func,
when you convert the string to float:

*---------------------code------------------------
function y=f(x) 
   BinLen = get_param(ga_params,'binary_length') 
   tmp    = convert_to_float(x, BinLen, Max, Min) 
   y      = func(tmp) 
 endfunction 
--------------------------------------------------*

is this tmp variable a matrix? has it converted the 8 bit string in two
floats (4 for each)?
the thing is i don't understand what happening inside this function:

if i do:*
-----------------code--------------------------------------------
clc
clear

func = 'rastrigin';

function y = rastrigin(x)
  y = x(1)^2+x(2)^2-cos(12*x(1))-cos(18*x(2));
endfunction

deff('y=f(x)','BinLen = 8; ...
               tmp    = convert_to_float(x, BinLen, 1, -1); ...
               y      = '+func+'(tmp);','n');                                                    
? what is 'n' for ?
               
               
------------------------------------------------------------------------------------ 
*  

i can call the rastrigin func but i don't know how to call the new f
function.

*--------------------------------code---------------------------------------               
rastrigin([1 2])
 ans  =
 
    4.2841097  

f(['11110000' '01010101'])
 !--error 15 
Submatrix incorrectly defined.

at line       5 of function convert_to_float called by :  
  = convert_to_float(x, BinLen, 1, -1);                y      = rastrigin(tm
at line       2 of function f called by :  
f(['11110000' '01010101'])
----------------------------------------------------------------------*

how should i call the f function??

thanks
sorry for the longness.
greetings
rui



--
View this message in context: http://mailinglists.scilab.org/Genetic-Algoritm-tp4024549p4024608.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list