[scilab-Users] Re: Genetic Algoritm
michael.baudin at contrib.scilab.org
michael.baudin at contrib.scilab.org
Thu Jul 19 15:36:01 CEST 2012
Hi,
On Thu, 19 Jul 2012 02:30:50 -0700 (PDT), rcbsimoes
<rcbsimoes at hotmail.com> wrote:
> ok, back again.
>
> i've used the continuous optimization which worked great!
That's good to hear !
> 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??
This is dimension=3 and binlen=2.
> 2)
> [...]
>
> ? what is 'n' for ?
"n" is an option of the "deff" function : function is not "compiled".
This means that you can see the code more easily
as opposed to a profiled function.
> * [...]
> 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'])
The example you give has two errors:
* The minimum and maximum bounds should be vectors which
size corresponds to the dimension of the problem.
* The argument is "1111000001010101" and not ['11110000' '01010101'].
The algorithm works directly with the concatenation of
two separate genes.
Here is the example with works.
function y = rastrigin(x)
y = x(1)^2+x(2)^2-cos(12*x(1))-cos(18*x(2));
endfunction
function y=f(x)
BinLen = 8
tmp = convert_to_float(x, BinLen, [1 1], [-1 -1])
y = rastrigin(tmp)
endfunction
y=f("1111000001010101")
The previous script produces:
-->y=f("1111000001010101")
y =
0.3256550
Here is an intermediate computation:
-->convert_to_float("1111000001010101", 8, [1 1], [-1 -1])
ans =
0.8823529
- 0.3333333
You may see the bug report :
http://bugzilla.scilab.org/show_bug.cgi?id=7912
for more details and examples.
Best regards,
Michaël
More information about the users
mailing list