-- Bug description --
There is a design issue with optim_ga.
We do not understand why, for example, the "dimension" parameter is
stored into ga_params, while it is not presented
in the list of parameters of optim_ga.
The reason behind this is that the "dimension" parameter
is not used by optim_ga, but is used by init_ga_default.
The optim_ga function only passes the param variable
to the init_func function :
Pop = init_func(pop_size,param);
There are several issues with this :
* the example is not consistent : why to define the
"dimension" argument if it is not a parameter of the optim_ga function ?
* the param variable contains much more that required by the init_func function.
For example, the 'codage_func' field is in the param variable which is recieved by the init_func function.
The solution may be to re-design the optim_ga function,
by defining the init function as a list.
The goal is to provide to the init function only the parameters
that are given by the user for this purpose.
The following is a proposal of implementation.
// Define the parameters of the init function
initpar = init_param();
initpar = add_param(initpar ,"minbound",[-2; -2]);
initpar = add_param(initpar ,"maxbound",[2; 2]);
initpar = add_param(initpar ,"dimension",2);
// Define the parameters of the optim_ga function
ga_params = init_param();
ga_params = add_param(ga_params,"init_func",list(init_ga_default,initpar));
In the body of optim_ga, we could put the following source
code, which uses directly the init parameter if it is a
function and adds the parameter if the init parameter is a
list.
[init_arg,err] = get_param(param,"init_func",init_ga_default);
if ( typeof(init_arg) == "function" ) then
init_func = init_arg
Pop = init_func (pop_size)
elseif ( typeof(init_arg) == "list" ) then
init_func = init_arg(1)
init_par = init_arg(2)
Pop = init_func (pop_size,init_par)
else
error ( "Unexpected init function type (function or list is expected)." )
end
-- Scilab error message --
-- How to reproduce the bug --