[scilab-Users] Genetic Algoritm

michael.baudin at contrib.scilab.org michael.baudin at contrib.scilab.org
Tue Jul 10 10:14:36 CEST 2012


 Hi,

 Sorry for the bug in my previous message.

 s*convert_to_float(x,8,1,0)

 returns an integer in the range [0,s], if s=2^8-1.

 Best regards,

 Michaël

 On Tue, 10 Jul 2012 10:06:11 +0200, <michael.baudin at contrib.scilab.org> 
 wrote:
> Hi,
>
> You are right, the "Optimization in Scilab" document does not provide
> examples of the GA with integer variables. But the demos of Scilab 
> can
> help - please type :
>
> demo_gui()
>
> in the console, and search for the "Optimization and Simulation >
> Genetic Algorithms > Genetic Algorithms" demo. If you click this, it
> will execute the demo. The graphics window then contains a button
> "View Code", which lets you explore the code. The "binary" example is
> at the end of the script. We used this demo in a training dedicated 
> to
> optimization we did last year, because it shows the sensitivity of 
> the
> encoding on the convergence on the algorithm.
>
> In this example, the real variable is encoded in binary form. This
> requires to change the objective function, which now gets x as a
> string which contains a binary coding of the real variable. Before
> calling the function func (which manages real inputs), we convert the
> binary string into a real with the convert_to_float function which is
> provided by the GA toolbox.
>
> function y=f(x)
>   BinLen = get_param(ga_params,'binary_length')
>   tmp    = convert_to_float(x, BinLen, Max, Min)
>   y      = func(tmp)
> endfunction
>
> Then there are some particular settings for managing the binary
> coding of the problem. We first have to set the 'binary_length' 
> option
> which counts the number of bits used in the encoding and then set the
> crossover_ga_binary, mutation_ga_binary and coding_ga_binary
> functions.
>
> ga_params = add_param(ga_params,'binary_length',8);
> ga_params = 
> set_param(ga_params,'crossover_func',crossover_ga_binary);
> ga_params = set_param(ga_params,'mutation_func',mutation_ga_binary);
> ga_params = set_param(ga_params,'codage_func',coding_ga_binary);
>
> In another context, working with integer variables may force you to
> write dedicated crossover_func, mutation_func and codage_func
> functions. But you may be able to use the current functions with
> binary encoding : just multiply the output of convert_to_float by 2^8
> and you get an integer, uniform in the [0,2^8-1] range.
>
> -->floor(convert_to_float("11010101",8, 1, 0)*2^8)
>  ans  =
>     213.
> -->floor(convert_to_float("00000000",8, 1, 0)*2^8)
>  ans  =
>     0.
>
> Notice that, in multi-dimensional problems, the string x is the
> concatenation of the strings in all dimensions. For example, if the
> problem is in dimension 2, then the 8-bytes string x="11111111" can
> represent two different 4-bytes values.
>
> Best regards,
>
> Michaël
>
> PS
> The convert_to_float function has no help page :
>
> http://bugzilla.scilab.org/show_bug.cgi?id=7912
>
> On Mon, 9 Jul 2012 14:32:46 -0700 (PDT), rcbsimoes
> <rcbsimoes at hotmail.com> wrote:
>> Hi All,
>>
>> i'm looking for a nice tutorial (with examples) for genetic 
>> algorithms.
>> specificaly descrete (not continous) input variables.
>>
>> can same one point me a link?
>>
>> i've seen the presentation from
>> http://www.scilab.org/support/documentation/tutorials  ->  
>> Optimization in
>> Scilab
>>
>> this one is nice, but i would like same more tutorials.
>>
>> greetings from pt, and thanks in advance.
>> rui
>>
>>
>> --
>> View this message in context:
>> http://mailinglists.scilab.org/Genetic-Algoritm-tp4024549.html
>> Sent from the Scilab users - Mailing Lists Archives mailing list
>> archive at Nabble.com.
>>
>> --
>> To unsubscribe from this mailing-list, please send an empty mail to
>> users-unsubscribe at lists.scilab.org
>> To check the archives of this mailing list, see
>> http://mailinglists.scilab.org/
>
>
> --
> To unsubscribe from this mailing-list, please send an empty mail to
> users-unsubscribe at lists.scilab.org
> To check the archives of this mailing list, see
> http://mailinglists.scilab.org/




More information about the users mailing list