Is there a trick to getting Octave's genetic algorithm solver to respect upper and lower bounds? For example,
options = gaoptimset('Generations', 10);
nvars = 6;
LB = ones(1,nvars);
UB = LB*10;
[soln, fval, exitflag] = ga(@fitnessfcn, nvars, [], [], [], [], LB, UB, [], options)
The solver returns a solution with undetermined bounds. For example,
soln = 0.551420 1.369775 -0.313379 -0.038621 0.274696 1.359802
UPDATE: I checked the scripts in the Octave package. I am pretty sure the ga function does not use the upper and lower bounds arguments. It does seems to read some upper/lower bound information from the gaoptim set. I'll play around with it when I have some time.
As per version 0.10 seems the bounds passed as parameter to ga
are pretty much ignored. For now the only way to specify a bound is through the parameter PopInitRange
of gaoptimset
, which requires a 2xN matrix containing the LBs in the first row and the UBs in the second one. if a 2x1 vector is provided.
The LB and UB parameters are supposed to mimic the original Matlab's ga
function, but apparently the implementation is taking his own way.