-- Bug description --
The optim_ga function does not protect against unexpected parameters.
Consider the script below.
Obviously, the parameter "BeatlesForEver" is not likely to be
valid field.
Still, the script runs smoothly.
If the check_param function is added in the body, the following
error is generated.
-->[pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);
!--error 10000
check_param: Unexpected key "BeatlesForEver" in parameter list.
at line 75 of function check_param called by :
at line 28 of function optim_ga called by :
opSize, NbGen, Proba_mut, Proba_cross, Log, ga_params)
The check_param is from the bug #7883.
Notice that the patched optim_ga makes the bug #7705
more apparent, as the modified implementation makes
explicit the list of available parameters.
The help page for optim_ga should be updated accordingly,
although this is less important than the current modification.
-- Scilab error message --
-- How to reproduce the bug --
Created an attachment (id=1961)
A patched optim_ga.
function y=f(x)
y = sum(x.^2)
endfunction
Min = [-2; -2];
Max = [2; 2];
x0 = (Max - Min) .* rand(size(Min,1),size(Min,2)) + Min;
PopSize = 100;
Proba_cross = 0.7;
Proba_mut = 0.1;
NbGen = 2;
NbCouples = 110;
Log = %T;
nb_disp = 10; // Nb point to display from the optimal population
pressure = 0.05;
ga_params = init_param();
ga_params = add_param(ga_params,'BeatlesForEver',3.1415926);
ga_params = add_param(ga_params,'minbound',Min);
ga_params = add_param(ga_params,'maxbound',Max);
[pop_opt, fobj_pop_opt, pop_init, fobj_pop_init] = optim_ga(f, PopSize, NbGen, Proba_mut, Proba_cross, Log, ga_params);