From: <sla...@us...> - 2008-08-07 07:34:25
|
Revision: 5224 http://octave.svn.sourceforge.net/octave/?rev=5224&view=rev Author: slackydeb Date: 2008-08-07 07:34:34 +0000 (Thu, 07 Aug 2008) Log Message: ----------- changed meaning of crossoverscattered Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/crossoverscattered.m trunk/octave-forge/main/ga/inst/gacreationuniform.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2008-08-05 21:14:13 UTC (rev 5223) +++ trunk/octave-forge/main/ga/DESCRIPTION 2008-08-07 07:34:34 UTC (rev 5224) @@ -1,6 +1,6 @@ Name: ga -Version: 0.4.8 -Date: 2008-08-05 +Version: 0.4.9 +Date: 2008-08-07 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm and Direct Search Modified: trunk/octave-forge/main/ga/inst/crossoverscattered.m =================================================================== --- trunk/octave-forge/main/ga/inst/crossoverscattered.m 2008-08-05 21:14:13 UTC (rev 5223) +++ trunk/octave-forge/main/ga/inst/crossoverscattered.m 2008-08-07 07:34:34 UTC (rev 5224) @@ -24,25 +24,33 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 4.0.2 +## Version: 5.0.1 function xoverKids = \ crossoverscattered (parents, options, nvars, FitnessFcn, unused, thisPopulation) - concatenated_parents = [(__ga_doubles2concatenated_bitstring__ \ - (parents(1, :))); \ - (__ga_doubles2concatenated_bitstring__ \ - (parents(2, :)))]; - %% crossover scattered - tmp = concatenated_parents(1, :); - for i = 1:length (tmp) - if (rand () < 0.5) - tmp(1, i) = concatenated_parents(2, i); - endif - endfor - concatenated_xoverKids = tmp; + ## example + ## p1 = [varA varB varC varD] + ## p2 = [var1 var2 var3 var4] + ## b = [1 1 0 1] + ## child1 = [varA varB var3 varD] + p1 = parents (1, 1:nvars); + p2 = parents (2, 1:nvars); + b = fix (rand (1, nvars) + + 0.5 * ones (1, nvars)); + child1 = b .* p1 + (ones (1, nvars) - b) .* p2; - xoverKids = __ga_concatenated_bitstring2doubles__ (concatenated_xoverKids); -endfunction \ No newline at end of file + xoverKids = child1; +endfunction + +%!test +%! parents = [0 4.3 51 -6; 3 -34 5 64.212]; +%! options = gaoptimset (); +%! nvars = 4; +%! FitnessFcn = @rastriginsfcn; +%! unused = false; +%! thisPopulation = false; ## this parameter is unused in the current implementation +%! xoverKids = crossoverscattered (parents, options, nvars, FitnessFcn, unused, thisPopulation); +%! assert (size (xoverKids), [1, nvars]); \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/gacreationuniform.m =================================================================== --- trunk/octave-forge/main/ga/inst/gacreationuniform.m 2008-08-05 21:14:13 UTC (rev 5223) +++ trunk/octave-forge/main/ga/inst/gacreationuniform.m 2008-08-07 07:34:34 UTC (rev 5224) @@ -40,7 +40,7 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 4.2.8 +## Version: 4.3 function Population = gacreationuniform (GenomeLength, FitnessFcn, options) [nr, nc] = size (options.PopInitRange); @@ -73,5 +73,4 @@ %! FitnessFcn = @rastriginsfcn; %! options = gaoptimset (); %! Population = gacreationuniform (GenomeLength, FitnessFcn, options); -%! [nr, nc] = size (Population); -%! assert (((nr == options.PopulationSize) && (nc == GenomeLength)), true); \ No newline at end of file +%! assert (size (Population), [options.PopulationSize, GenomeLength]); \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |