From: <sla...@us...> - 2008-08-16 18:14:10
|
Revision: 5245 http://octave.svn.sourceforge.net/octave/?rev=5245&view=rev Author: slackydeb Date: 2008-08-16 18:14:17 +0000 (Sat, 16 Aug 2008) Log Message: ----------- integrate most debug asserts as matrix indices or tests; clean and modularize code; little performance improvement in __ga_problem__ function; little fixes Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/__ga_crossoverfcn__.m trunk/octave-forge/main/ga/inst/__ga_initial_population__.m trunk/octave-forge/main/ga/inst/__ga_mutationfcn__.m trunk/octave-forge/main/ga/inst/__ga_problem__.m trunk/octave-forge/main/ga/inst/__ga_problem_private_state__.m trunk/octave-forge/main/ga/inst/__ga_problem_state_selection__.m trunk/octave-forge/main/ga/inst/__ga_scores__.m trunk/octave-forge/main/ga/inst/__ga_selectionfcn__.m trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m trunk/octave-forge/main/ga/inst/crossoverscattered.m trunk/octave-forge/main/ga/inst/fitscalingrank.m trunk/octave-forge/main/ga/inst/ga.m trunk/octave-forge/main/ga/inst/gacreationuniform.m trunk/octave-forge/main/ga/inst/gaoptimset.m trunk/octave-forge/main/ga/inst/mutationgaussian.m Added Paths: ----------- trunk/octave-forge/main/ga/inst/__ga_popinitrange__.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/DESCRIPTION 2008-08-16 18:14:17 UTC (rev 5245) @@ -1,5 +1,5 @@ Name: ga -Version: 0.9.1 +Version: 0.9.2 Date: 2008-08-16 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Modified: trunk/octave-forge/main/ga/inst/__ga_crossoverfcn__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_crossoverfcn__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_crossoverfcn__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,22 +14,20 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.2 +## Version: 1.3.3 function xoverKids = __ga_crossoverfcn__ (parents, options, nvars, FitnessFcn, unused, thisPopulation) ## preconditions - [nr_parents nc_parents] = size (parents); - assert (nr_parents, 1); ## DEBUG - assert (rem (nc_parents, 2), 0); ## DEBUG - assert (columns (thisPopulation), nvars); ## DEBUG + nc_parents = columns (parents); + if (rem (nc_parents, 2) != 0) + error ("'parents' must have an even number of columns"); + endif - xoverKids = options.CrossoverFcn (parents, options, nvars, FitnessFcn, - unused, - thisPopulation); - - ## postconditions - assert (size (xoverKids), [(nc_parents / 2) nvars]); ## DEBUG + xoverKids(1:(nc_parents / 2), 1:nvars) = options.CrossoverFcn \ + (parents(1, 1:nc_parents), options, nvars, FitnessFcn, + unused, + thisPopulation(:, 1:nvars)); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/__ga_initial_population__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_initial_population__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_initial_population__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -21,38 +21,37 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 3.2 +## Version: 3.2.4 #TODO consider PopulationSize as a #vector for multiple subpopolations function Population = \ __ga_initial_population__ (GenomeLength, FitnessFcn, options) - [nr nc] = size (options.InitialPopulation); - if ((nr == 0) || (nc == 0)) + [nrInitialPopulation ncInitialPopulation] = size (options.InitialPopulation); + + if (isempty (options.InitialPopulation)) Population(1:options.PopulationSize, 1:GenomeLength) = \ options.CreationFcn (GenomeLength, FitnessFcn, options); - elseif (nc == GenomeLength) + elseif (ncInitialPopulation == GenomeLength) ## nrInitialPopulation > 0 + if (nrInitialPopulation < options.PopulationSize) - ## nr > 0 - if (nr < options.PopulationSize) - ## create a complete new population, and then select only needed ## individuals (creating only a partial population is difficult) CreatedPopulation(1:options.PopulationSize, 1:GenomeLength) = \ options.CreationFcn (GenomeLength, FitnessFcn, options); + Population(1:options.PopulationSize, 1:GenomeLength) = vertcat \ + (options.InitialPopulation(1:nr, 1:GenomeLength), + CreatedPopulation(1:(options.PopulationSize - nrInitialPopulation), + 1:GenomeLength)); + elseif (nrInitialPopulation == options.PopulationSize) Population(1:options.PopulationSize, 1:GenomeLength) = \ - vertcat (options.InitialPopulation(1:nr, 1:GenomeLength), - CreatedPopulation(1:(options.PopulationSize - nr), - 1:GenomeLength)); - elseif (nr == options.PopulationSize) - Population(1:options.PopulationSize, 1:GenomeLength) = \ options.InitialPopulation; - else ## nr > options.PopulationSize + else ## nrInitialPopulation > options.PopulationSize error ("nonempty 'InitialPopulation' must have no more than \ 'PopulationSize' rows"); endif - else ## (nc != 0) && (nc != GenomeLength) + else ## (ncInitialPopulation != 0) && (ncInitialPopulation != GenomeLength) error ("nonempty 'InitialPopulation' must have 'GenomeLength' \ columns"); endif Modified: trunk/octave-forge/main/ga/inst/__ga_mutationfcn__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_mutationfcn__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_mutationfcn__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,21 +14,12 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.2.1 +## Version: 1.3 function mutationChildren = \ __ga_mutationfcn__ (parents, options, nvars, FitnessFcn, state, thisScore, thisPopulation) - - ## preconditions - #TODO move controls on - #options.PopInitRange in a more general - #function - [nrPopInitRange, ncPopInitRange] = size (options.PopInitRange); - assert (nrPopInitRange, 2); ## DEBUG - assert ((ncPopInitRange == 1) || (ncPopInitRange == nvars)); ## DEBUG - mutationChildren(1:(columns (parents)), 1:nvars) = \ options.MutationFcn{1, 1} (parents(1, :), options, nvars, FitnessFcn, state, thisScore, Added: trunk/octave-forge/main/ga/inst/__ga_popinitrange__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_popinitrange__.m (rev 0) +++ trunk/octave-forge/main/ga/inst/__ga_popinitrange__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -0,0 +1,28 @@ +## Copyright (C) 2008 Luca Favatella <sla...@gm...> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see <http://www.gnu.org/licenses/>. + +## Author: Luca Favatella <sla...@gm...> +## Version: 2.1 + +function [LB UB] = __ga_popinitrange__ (PopInitRange, nvars) + switch (columns (PopInitRange)) + case 1 + tmpPIR(1:2, 1:nvars) = PopInitRange(1:2, 1) * ones (1, nvars); + case nvars + tmpPIR(1:2, 1:nvars) = PopInitRange(1:2, 1:nvars); + endswitch + LB(1, 1:nvars) = tmpPIR(1, 1:nvars); + UB(1, 1:nvars) = tmpPIR(2, 1:nvars); +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/__ga_problem__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_problem__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_problem__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 5.8 +## Version: 5.9 function [x fval exitflag output population scores] = __ga_problem__ (problem) @@ -25,7 +25,7 @@ output = struct ("randstate", rand ("state"), "randnstate", randn ("state")); - ## start "instructions not to be executed at each generation" + ## instructions not to be executed at each generation state.Population(1:problem.options.PopulationSize, 1:problem.nvars) = \ __ga_initial_population__ (problem.nvars, problem.fitnessfcn, @@ -34,13 +34,12 @@ private_state = __ga_problem_private_state__ (problem.options); state.Selection = __ga_problem_state_selection__ (private_state, problem.options); - ## end "instructions not to be executed at each generation" - ## start "instructions to be executed at each generation" + ## instructions to be executed at each generation state = __ga_problem_update_state_at_each_generation__ (state, problem, private_state); - ## end "instructions to be executed at each generation" + NextPopulation = zeros (problem.options.PopulationSize, problem.nvars); while (! __ga_stop__ (problem, state)) ## fix a generation ## elite @@ -50,8 +49,6 @@ state.Population \ (IndexSortedScores(1:private_state.ReproductionCount.elite, 1), 1:problem.nvars); - assert (size (NextPopulation), - [private_state.ReproductionCount.elite, problem.nvars]); ## DEBUG endif ## selection for crossover and mutation @@ -66,10 +63,6 @@ problem.options, problem.nvars, problem.fitnessfcn, false, ## unused state.Population); - tmp = \ - private_state.ReproductionCount.elite + \ - private_state.ReproductionCount.crossover; - assert (size (NextPopulation), [tmp, problem.nvars]); ## DEBUG endif ## mutation @@ -80,14 +73,11 @@ problem.options, problem.nvars, problem.fitnessfcn, state, state.Score, state.Population); - assert (size (NextPopulation), - [problem.options.PopulationSize, problem.nvars]); ## DEBUG endif ## update state structure state.Population(1:problem.options.PopulationSize, 1:problem.nvars) = NextPopulation; - clear -v NextPopulation; state.Generation++; state = __ga_problem_update_state_at_each_generation__ (state, problem, private_state); Modified: trunk/octave-forge/main/ga/inst/__ga_problem_private_state__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_problem_private_state__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_problem_private_state__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,10 +14,9 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.1 +## Version: 1.1.1 function private_state = __ga_problem_private_state__ (options) - #start private_state private_state.ReproductionCount.elite = options.EliteCount; private_state.ReproductionCount.crossover = \ fix (options.CrossoverFraction * Modified: trunk/octave-forge/main/ga/inst/__ga_problem_state_selection__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_problem_state_selection__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_problem_state_selection__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.1 +## Version: 1.1.1 function Selection = __ga_problem_state_selection__ (private_state, options) Selection.elite = 1:private_state.ReproductionCount.elite; @@ -25,8 +25,8 @@ private_state.ReproductionCount.elite + \ private_state.ReproductionCount.crossover + \ (1:private_state.ReproductionCount.mutation); - assert (length (Selection.elite) + - length (Selection.crossover) + - length (Selection.mutation), - options.PopulationSize); ##DEBUG + #assert (length (Selection.elite) + + # length (Selection.crossover) + + # length (Selection.mutation), + # options.PopulationSize); ##DEBUG endfunction \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/__ga_scores__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_scores__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_scores__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,18 +14,18 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 5.3 +## Version: 5.3.1 function Scores = __ga_scores__ (fitnessfcn, Population, InitialScores = []) [nrPopulation ncPopulation] = size (Population); [nrInitialScores ncInitialScores] = size (InitialScores); #assert ((ncInitialScores == 0) || (ncInitialScores == 1)); ## DEBUG #assert (nrInitialScores <= nrPopulation); ## DEBUG - if (nrInitialScores > 0) - Scores(1:nrInitialScores, 1) = InitialScores(1:nrInitialScores, 1); + if (! isempty (InitialScores)) + Scores(1:nrInitialScores, 1) = InitialScores; endif for index = (nrInitialScores + 1):nrPopulation Scores(index, 1) = fitnessfcn (Population(index, 1:ncPopulation)); endfor - #assert (size (Scores), [nrPopulation 1]); ## DEBUG + Scores(1:nrPopulation, 1) = Scores; endfunction \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/__ga_selectionfcn__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_selectionfcn__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__ga_selectionfcn__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,15 +14,9 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.1 +## Version: 1.2 function parents = __ga_selectionfcn__ (expectation, nParents, options) - - ## preconditions - assert (rows (expectation), 1); ## DEBUG - - parents = options.SelectionFcn (expectation, nParents, options); - - ## postconditions - assert (size (parents), [1 nParents]); ## DEBUG + parents(1, 1:nParents) = \ + options.SelectionFcn (expectation(1, :), nParents, options); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.2 +## Version: 1.2.1 function default_options = __gaoptimset_default_options__ () default_options.CreationFcn = @gacreationuniform; @@ -42,7 +42,7 @@ #default_options.PlotInterval = 1; default_options.PopInitRange = [0; 1]; default_options.PopulationSize = 20; - default_options.PopulationType = "doubleVector"; + #default_options.PopulationType = "doubleVector"; default_options.SelectionFcn = @selectionstochunif; #default_options.StallGenLimit = 50; #default_options.StallTimeLimit = Inf; Modified: trunk/octave-forge/main/ga/inst/crossoverscattered.m =================================================================== --- trunk/octave-forge/main/ga/inst/crossoverscattered.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/crossoverscattered.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,18 +14,18 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 6.3 +## Version: 6.3.1 function xoverKids = crossoverscattered (parents, options, nvars, FitnessFcn, unused, thisPopulation) - nc_parents = columns (parents); ## simplified example (nvars == 4) ## p1 = [varA varB varC varD] ## p2 = [var1 var2 var3 var4] ## b = [1 1 0 1] ## child1 = [varA varB var3 varD] + nc_parents = columns (parents); n_children = nc_parents / 2; p1(1:n_children, 1:nvars) = \ thisPopulation(parents(1, 1:n_children), 1:nvars); Modified: trunk/octave-forge/main/ga/inst/fitscalingrank.m =================================================================== --- trunk/octave-forge/main/ga/inst/fitscalingrank.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/fitscalingrank.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,27 +14,30 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.2 +## Version: 1.3.2 function expectation = fitscalingrank (scores, nParents) - [nr nc] = size (scores); - #assert (nc, 1); ## DEBUG - r(1, 1:nr) = ranks (scores); + nr_scores = rows (scores); + r(1, 1:nr_scores) = ranks (scores(1:nr_scores, 1)); #TODO #ranks ([7,2,2]) == [3.0,1.5,1.5] #is [3,1,2] (or [3,2,1]) useful? - expectation_wo_nParents(1, 1:nr) = arrayfun (@(n) 1 / sqrt (n), r); - expectation(1, 1:nr) = \ + expectation_wo_nParents(1, 1:nr_scores) = arrayfun (@(n) 1 / sqrt (n), r); + expectation(1, 1:nr_scores) = \ (nParents / sum (expectation_wo_nParents)) * \ expectation_wo_nParents; - #assert (sum (expectation), nParents, 1e-9); ## DEBUG +endfunction - ## start DEBUG - #[trash index_min_scores] = min (scores); - #[trash index_max_expectation] = max (expectation); - #assert (index_min_scores, index_max_expectation); - #[trash index_max_scores] = max (scores); - #[trash index_min_expectation] = min (expectation); - #assert (index_max_scores, index_min_expectation); - ## end DEBUG -endfunction \ No newline at end of file +%!shared scores, nParents, expectation +%! scores = rand (20, 1); +%! nParents = 32; +%! expectation = fitscalingrank (scores, nParents); +%!assert (sum (expectation), nParents, 1e-9); +%!test +%! [trash index_min_scores] = min (scores); +%! [trash index_max_expectation] = max (expectation); +%! assert (index_min_scores, index_max_expectation); +%!test +%! [trash index_max_scores] = max (scores); +%! [trash index_min_expectation] = min (expectation); +%! assert (index_max_scores, index_min_expectation); \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/ga.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -71,7 +71,7 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 5.19.1 +## Version: 5.19.2 function [x fval exitflag output population scores] = \ ga (fitnessfcn_or_problem, @@ -90,7 +90,7 @@ print_usage (); else - ## retrieve problem structure + ## retrieve the problem structure if (nargin == 1) problem = fitnessfcn_or_problem; else Modified: trunk/octave-forge/main/ga/inst/gacreationuniform.m =================================================================== --- trunk/octave-forge/main/ga/inst/gacreationuniform.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/gacreationuniform.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -37,23 +37,12 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 4.7.2 +## Version: 4.9 function Population = gacreationuniform (GenomeLength, FitnessFcn, options) + [LB(1, 1:GenomeLength) UB(1, 1:GenomeLength)] = \ + __ga_popinitrange__ (options.PopInitRange, GenomeLength); - ## obtain a 2-by-GenomeLength LocalPopInitRange - switch (columns (options.PopInitRange)) - case 1 - LocalPopInitRange(1:2, 1:GenomeLength) = \ - options.PopInitRange(1:2, 1) * ones (1, GenomeLength); - case GenomeLength - LocalPopInitRange(1:2, 1:GenomeLength) = \ - options.PopInitRange(1:2, 1:GenomeLength); - endswitch - - LB(1, 1:GenomeLength) = LocalPopInitRange(1, 1:GenomeLength); - UB(1, 1:GenomeLength) = LocalPopInitRange(2, 1:GenomeLength); - ## pseudocode ## ## Population = Delta * RandomPopulationBetween0And1 + Offset Modified: trunk/octave-forge/main/ga/inst/gaoptimset.m =================================================================== --- trunk/octave-forge/main/ga/inst/gaoptimset.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/gaoptimset.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -47,7 +47,6 @@ ## @item MutationFcn ## @item PopInitRange ## @item PopulationSize -## @item PopulationType ## @item SelectionFcn ## @item TimeLimit ## @end table @@ -56,7 +55,7 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 4.4 +## Version: 4.4.1 function options = gaoptimset (varargin) if ((nargout != 1) || Modified: trunk/octave-forge/main/ga/inst/mutationgaussian.m =================================================================== --- trunk/octave-forge/main/ga/inst/mutationgaussian.m 2008-08-15 22:47:24 UTC (rev 5244) +++ trunk/octave-forge/main/ga/inst/mutationgaussian.m 2008-08-16 18:14:17 UTC (rev 5245) @@ -14,23 +14,15 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 1.5 +## Version: 1.7.1 function mutationChildren = \ mutationgaussian (parents, options, nvars, FitnessFcn, state, thisScore, thisPopulation) - nc_parents = columns (parents); - ncPopInitRange = columns (options.PopInitRange); + [LB(1, 1:nvars) UB(1, 1:nvars)] = \ + __ga_popinitrange__ (options.PopInitRange, nvars); - ## obtain a 2-by-nvars LocalPopInitRange - LocalPopInitRange = options.PopInitRange; - if (ncPopInitRange == 1) - LocalPopInitRange(1:2, 1:nvars) = LocalPopInitRange * ones (1, nvars); - endif - LB(1, 1:nvars) = LocalPopInitRange(1, 1:nvars); - UB(1, 1:nvars) = LocalPopInitRange(2, 1:nvars); - ## start mutationgaussian logic Scale = options.MutationFcn{1, 2}; #assert (size (Scale), [1 1]); ## DEBUG @@ -45,6 +37,7 @@ tmp_std(1, 1:nvars) = (1 - Shrink * (k / options.Generations)) * tmp_std; endfor current_std(1, 1:nvars) = tmp_std; + nc_parents = columns (parents); expanded_current_std(1:nc_parents, 1:nvars) = \ ones (nc_parents, 1) * current_std; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2008-08-21 10:59:08
|
Revision: 5251 http://octave.svn.sourceforge.net/octave/?rev=5251&view=rev Author: slackydeb Date: 2008-08-21 10:59:18 +0000 (Thu, 21 Aug 2008) Log Message: ----------- fix a bug in __ga_initial_population__ when an InitialPopulation is specified, thanks to Thomas Weber (see http://lists.alioth.debian.org/pipermail/pkg-octave-devel/2008-August/004787.html) Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/__ga_initial_population__.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2008-08-20 14:51:38 UTC (rev 5250) +++ trunk/octave-forge/main/ga/DESCRIPTION 2008-08-21 10:59:18 UTC (rev 5251) @@ -1,6 +1,6 @@ Name: ga -Version: 0.9.2 -Date: 2008-08-16 +Version: 0.9.3 +Date: 2008-08-21 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm and Direct Search Modified: trunk/octave-forge/main/ga/inst/__ga_initial_population__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_initial_population__.m 2008-08-20 14:51:38 UTC (rev 5250) +++ trunk/octave-forge/main/ga/inst/__ga_initial_population__.m 2008-08-21 10:59:18 UTC (rev 5251) @@ -21,7 +21,7 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 3.2.4 +## Version: 3.2.5 #TODO consider PopulationSize as a #vector for multiple subpopolations @@ -41,7 +41,7 @@ CreatedPopulation(1:options.PopulationSize, 1:GenomeLength) = \ options.CreationFcn (GenomeLength, FitnessFcn, options); Population(1:options.PopulationSize, 1:GenomeLength) = vertcat \ - (options.InitialPopulation(1:nr, 1:GenomeLength), + (options.InitialPopulation(1:nrInitialPopulation, 1:GenomeLength), CreatedPopulation(1:(options.PopulationSize - nrInitialPopulation), 1:GenomeLength)); elseif (nrInitialPopulation == options.PopulationSize) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2009-04-09 20:43:32
|
Revision: 5683 http://octave.svn.sourceforge.net/octave/?rev=5683&view=rev Author: slackydeb Date: 2009-04-09 20:43:29 +0000 (Thu, 09 Apr 2009) Log Message: ----------- little cleanup; remove crossoversinglepoint function because difficult to mantain and not useful Modified Paths: -------------- trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m trunk/octave-forge/main/ga/inst/crossoverscattered.m Removed Paths: ------------- trunk/octave-forge/main/ga/doc/old_stuff/crossoversinglepoint.m Deleted: trunk/octave-forge/main/ga/doc/old_stuff/crossoversinglepoint.m =================================================================== --- trunk/octave-forge/main/ga/doc/old_stuff/crossoversinglepoint.m 2009-04-09 20:21:21 UTC (rev 5682) +++ trunk/octave-forge/main/ga/doc/old_stuff/crossoversinglepoint.m 2009-04-09 20:43:29 UTC (rev 5683) @@ -1,57 +0,0 @@ -## Copyright (C) 2008 Luca Favatella <sla...@gm...> -## -## -## This program is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn{Function File} {@var{xoverKids} =} crossoversinglepoint (@var{parents}, @var{options}, @var{nvars}, @var{FitnessFcn}, @var{unused}, @var{thisPopulation}) -## Combine two individuals, or parents, to form a crossover child. -## -## @seealso{ga, gaoptimset} -## @end deftypefn - -## Author: Luca Favatella <sla...@gm...> -## Version: 5.1.2 - -function xoverKids = \ - crossoversinglepoint (parents, - options, nvars, FitnessFcn, unused, - thisPopulation) - - ## example (nvars == 4) - ## p1 = [varA varB varC varD] - ## p2 = [var1 var2 var3 var4] - ## n = 1 ## integer between 1 and nvars - ## child1 = [varA var2 var3 var4] - p1 = parents(1, 1:nvars); - p2 = parents(2, 1:nvars); - n = randint (1, 1, [1, nvars]); - child1 = horzcat (p1(1, 1:n), - p2(1, n+1:nvars)); - - xoverKids = child1; -endfunction - -%!shared nvars, xoverKids -%! parents = [3.2 -34 51 64.21; 3.2 -34 51 64.21]; -%! options = gaoptimset (); -%! nvars = 4; -%! FitnessFcn = false; ## this parameter is unused in the current implementation -%! 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]); -%!assert (xoverKids(1, 1:nvars), [3.2 -34 51 64.21]); \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m 2009-04-09 20:21:21 UTC (rev 5682) +++ trunk/octave-forge/main/ga/inst/__gaoptimset_default_options__.m 2009-04-09 20:43:29 UTC (rev 5683) @@ -1,4 +1,4 @@ -## Copyright (C) 2008 Luca Favatella <sla...@gm...> +## Copyright (C) 2008, 2009 Luca Favatella <sla...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by Modified: trunk/octave-forge/main/ga/inst/crossoverscattered.m =================================================================== --- trunk/octave-forge/main/ga/inst/crossoverscattered.m 2009-04-09 20:21:21 UTC (rev 5682) +++ trunk/octave-forge/main/ga/inst/crossoverscattered.m 2009-04-09 20:43:29 UTC (rev 5683) @@ -1,4 +1,4 @@ -## Copyright (C) 2008 Luca Favatella <sla...@gm...> +## Copyright (C) 2008, 2009 Luca Favatella <sla...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 6.3.1 +## Version: 6.3.2 function xoverKids = crossoverscattered (parents, options, nvars, FitnessFcn, unused, @@ -24,7 +24,7 @@ ## p1 = [varA varB varC varD] ## p2 = [var1 var2 var3 var4] ## b = [1 1 0 1] - ## child1 = [varA varB var3 varD] + ## child = [varA varB var3 varD] nc_parents = columns (parents); n_children = nc_parents / 2; p1(1:n_children, 1:nvars) = \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2009-05-11 23:25:46
|
Revision: 5805 http://octave.svn.sourceforge.net/octave/?rev=5805&view=rev Author: slackydeb Date: 2009-05-11 23:25:32 +0000 (Mon, 11 May 2009) Log Message: ----------- Improve doc/examples from user feedback. Bump version. Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/doc/README Added Paths: ----------- trunk/octave-forge/main/ga/doc/EXAMPLES Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2009-05-11 13:31:54 UTC (rev 5804) +++ trunk/octave-forge/main/ga/DESCRIPTION 2009-05-11 23:25:32 UTC (rev 5805) @@ -1,6 +1,6 @@ Name: ga -Version: 0.9.6 -Date: 2009-04-09 +Version: 0.9.7 +Date: 2009-05-12 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm and Direct Search Added: trunk/octave-forge/main/ga/doc/EXAMPLES =================================================================== --- trunk/octave-forge/main/ga/doc/EXAMPLES (rev 0) +++ trunk/octave-forge/main/ga/doc/EXAMPLES 2009-05-11 23:25:32 UTC (rev 5805) @@ -0,0 +1,35 @@ +All examples in this file should be copied from ga.m. + +If you add in this file an example not coming from ga.m, please mark +it as "NOT COPIED FROM ga.m". + + + +######## + +min = [-1, 2]; +ga (struct ("fitnessfcn", @(x) rastriginsfcn (x - min), "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200))) + +######## + +ga (@(x) x ** 2, 1) + +######## + +ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1) + +######## + +ga (@rastriginsfcn, 2) + +######## + +ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000))) + +######## + +ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))) + +######## + +ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200))) \ No newline at end of file Modified: trunk/octave-forge/main/ga/doc/README =================================================================== --- trunk/octave-forge/main/ga/doc/README 2009-05-11 13:31:54 UTC (rev 5804) +++ trunk/octave-forge/main/ga/doc/README 2009-05-11 23:25:32 UTC (rev 5805) @@ -1,6 +1,6 @@ STATUS (BY EXAMPLES) -see tests of the ga function +See tests of the ga function or the EXAMPLES file. TODO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2011-07-28 23:05:02
|
Revision: 8420 http://octave.svn.sourceforge.net/octave/?rev=8420&view=rev Author: slackydeb Date: 2011-07-28 23:04:56 +0000 (Thu, 28 Jul 2011) Log Message: ----------- Remove dependency on the communications package, substituting 'randint' with 'randi' introduced in octave 3.4.0. Bump version number. TODO: test this version of the package. Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/crossoverscattered.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2011-07-28 08:26:27 UTC (rev 8419) +++ trunk/octave-forge/main/ga/DESCRIPTION 2011-07-28 23:04:56 UTC (rev 8420) @@ -1,12 +1,12 @@ Name: ga -Version: 0.9.8 -Date: 2010-06-24 +Version: 0.9.9 +Date: 2011-07-29 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm and Direct Search Description: Genetic optimization code Categories: Optimization -Depends: octave (>= 2.9.7), communications (>= 1.0.0) +Depends: octave (>= 3.4.0) Autoload: yes License: GPL version 2 or later Url: http://octave.sf.net Modified: trunk/octave-forge/main/ga/inst/crossoverscattered.m =================================================================== --- trunk/octave-forge/main/ga/inst/crossoverscattered.m 2011-07-28 08:26:27 UTC (rev 8419) +++ trunk/octave-forge/main/ga/inst/crossoverscattered.m 2011-07-28 23:04:56 UTC (rev 8420) @@ -1,4 +1,4 @@ -## Copyright (C) 2008, 2009 Luca Favatella <sla...@gm...> +## Copyright (C) 2008, 2009, 2011 Luca Favatella <sla...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 6.3.2 +## Version: 7.0 function xoverKids = crossoverscattered (parents, options, nvars, FitnessFcn, unused, @@ -31,7 +31,7 @@ thisPopulation(parents(1, 1:n_children), 1:nvars); p2(1:n_children, 1:nvars) = \ thisPopulation(parents(1, n_children + (1:n_children)), 1:nvars); - b(1:n_children, 1:nvars) = randint (n_children, nvars); + b(1:n_children, 1:nvars) = randi (1, n_children, nvars); ## TODO: test randi xoverKids(1:n_children, 1:nvars) = \ b .* p1 + (ones (n_children, nvars) - b) .* p2; -endfunction \ No newline at end of file +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-13 01:00:01
|
Revision: 9841 http://octave.svn.sourceforge.net/octave/?rev=9841&view=rev Author: slackydeb Date: 2012-03-13 00:59:55 +0000 (Tue, 13 Mar 2012) Log Message: ----------- ga: update news and description files Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/doc/NEWS Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2012-03-13 00:40:30 UTC (rev 9840) +++ trunk/octave-forge/main/ga/DESCRIPTION 2012-03-13 00:59:55 UTC (rev 9841) @@ -1,6 +1,6 @@ Name: ga Version: 0.9.9 -Date: 2011-07-29 +Date: 2012-03-13 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm and Direct Search Modified: trunk/octave-forge/main/ga/doc/NEWS =================================================================== --- trunk/octave-forge/main/ga/doc/NEWS 2012-03-13 00:40:30 UTC (rev 9840) +++ trunk/octave-forge/main/ga/doc/NEWS 2012-03-13 00:59:55 UTC (rev 9841) @@ -0,0 +1,10 @@ +Summary of important user-visible changes for releases of the ga package + +=============================================================================== +ga-0.9.9 Release Date: 2012-xx-yy Release Manager: Luca Favatella +=============================================================================== + +** Remove dependency on the "communications" package and require + Octave version 3.4.0 (or better). The "communications" package was + used only for its "randint" function; now the "randi" function, + introduced on Octave 3.4.0, is used instead. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-15 02:24:31
|
Revision: 9900 http://octave.svn.sourceforge.net/octave/?rev=9900&view=rev Author: slackydeb Date: 2012-03-15 02:24:25 +0000 (Thu, 15 Mar 2012) Log Message: ----------- ga: update NEWS and INDEX Modified Paths: -------------- trunk/octave-forge/main/ga/INDEX trunk/octave-forge/main/ga/NEWS Modified: trunk/octave-forge/main/ga/INDEX =================================================================== --- trunk/octave-forge/main/ga/INDEX 2012-03-15 02:24:13 UTC (rev 9899) +++ trunk/octave-forge/main/ga/INDEX 2012-03-15 02:24:25 UTC (rev 9900) @@ -19,4 +19,7 @@ mutationgaussian Utility - rastriginsfcn \ No newline at end of file + rastriginsfcn + +Miscellaneous + test_ga Modified: trunk/octave-forge/main/ga/NEWS =================================================================== --- trunk/octave-forge/main/ga/NEWS 2012-03-15 02:24:13 UTC (rev 9899) +++ trunk/octave-forge/main/ga/NEWS 2012-03-15 02:24:25 UTC (rev 9900) @@ -8,3 +8,11 @@ Octave version 3.4.0 (or better). The "communications" package was used only for its "randint" function; now the "randi" function, introduced on Octave 3.4.0, is used instead. + +** Reorganize the unit test suite. All available tests can be + executed by running "test_ga". Fix bug #3287917 (Debian bug + #622929). + +** Rename the package from "Genetic Algorithm and Direct Search" to + "Genetic Algorithm" as only the Genetic Algorithm is implemented. + Direct Search will not be implemented in the foreseeable future. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-20 02:03:44
|
Revision: 9973 http://octave.svn.sourceforge.net/octave/?rev=9973&view=rev Author: slackydeb Date: 2012-03-20 02:03:37 +0000 (Tue, 20 Mar 2012) Log Message: ----------- ga: add devel folder Thanks to Carn?\195?\171 Draug for clarification on package dirs structure. Reference: http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/devel/INFO?revision=7804&view=markup Added Paths: ----------- trunk/octave-forge/main/ga/devel/ trunk/octave-forge/main/ga/devel/INFO Added: trunk/octave-forge/main/ga/devel/INFO =================================================================== --- trunk/octave-forge/main/ga/devel/INFO (rev 0) +++ trunk/octave-forge/main/ga/devel/INFO 2012-03-20 02:03:37 UTC (rev 9973) @@ -0,0 +1,3 @@ +The folder "devel" and its content is ignored by "pkg install". The +folder is intended for draft code and other stuff which is not +suitable for "normal" users. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-21 18:58:49
|
Revision: 9995 http://octave.svn.sourceforge.net/octave/?rev=9995&view=rev Author: slackydeb Date: 2012-03-21 18:58:42 +0000 (Wed, 21 Mar 2012) Log Message: ----------- ga: move demo_ga to devel/ Added Paths: ----------- trunk/octave-forge/main/ga/devel/demo_ga.m Removed Paths: ------------- trunk/octave-forge/main/ga/inst/demo_ga.m Copied: trunk/octave-forge/main/ga/devel/demo_ga.m (from rev 9974, trunk/octave-forge/main/ga/inst/demo_ga.m) =================================================================== --- trunk/octave-forge/main/ga/devel/demo_ga.m (rev 0) +++ trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-21 18:58:42 UTC (rev 9995) @@ -0,0 +1,62 @@ +## Copyright (C) 2012 Luca Favatella <sla...@gm...> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Script File} {} demo_ga +## Run a demo of the genetic algorithm package. The current +## implementation is only a placeholder. +## @end deftypefn + +## Author: Luca Favatella <sla...@gm...> +## Created: March 2012 +## Version: 0.0.4 + +demo demo_ga + + +%!demo +%! % TODO + + +## This code is a simple example of the usage of ga + # TODO: convert to demo +# %!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3) + + +## This code shows that ga optimizes also functions whose minimum is not +## in zero + # TODO: convert to demo +# %!xtest +# %! min = [-1, 2]; +# %! assert (ga (struct ("fitnessfcn", @(x) rastriginsfcn (x - min), "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200))), min, 1e-5) + + +## This code shows that the "Vectorize" option usually speeds up execution + # TODO: convert to demo +# %!test +# %! +# %! tic (); +# %! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200))); +# %! elapsed_time = toc (); +# %! +# %! tic (); +# %! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200, "Vectorized", "on"))); +# %! elapsed_time_with_vectorized = toc (); +# %! +# %! assert (elapsed_time > elapsed_time_with_vectorized); + +## The "UseParallel" option should speed up execution + # TODO: write demo (after implementing + # UseParallel) - low priority Deleted: trunk/octave-forge/main/ga/inst/demo_ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/demo_ga.m 2012-03-21 16:35:49 UTC (rev 9994) +++ trunk/octave-forge/main/ga/inst/demo_ga.m 2012-03-21 18:58:42 UTC (rev 9995) @@ -1,62 +0,0 @@ -## Copyright (C) 2012 Luca Favatella <sla...@gm...> -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Script File} {} demo_ga -## Run a demo of the genetic algorithm package. The current -## implementation is only a placeholder. -## @end deftypefn - -## Author: Luca Favatella <sla...@gm...> -## Created: March 2012 -## Version: 0.0.4 - -demo demo_ga - - -%!demo -%! % TODO - - -## This code is a simple example of the usage of ga - # TODO: convert to demo -# %!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3) - - -## This code shows that ga optimizes also functions whose minimum is not -## in zero - # TODO: convert to demo -# %!xtest -# %! min = [-1, 2]; -# %! assert (ga (struct ("fitnessfcn", @(x) rastriginsfcn (x - min), "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200))), min, 1e-5) - - -## This code shows that the "Vectorize" option usually speeds up execution - # TODO: convert to demo -# %!test -# %! -# %! tic (); -# %! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200))); -# %! elapsed_time = toc (); -# %! -# %! tic (); -# %! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200, "Vectorized", "on"))); -# %! elapsed_time_with_vectorized = toc (); -# %! -# %! assert (elapsed_time > elapsed_time_with_vectorized); - -## The "UseParallel" option should speed up execution - # TODO: write demo (after implementing - # UseParallel) - low priority This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:35:17
|
Revision: 10037 http://octave.svn.sourceforge.net/octave/?rev=10037&view=rev Author: slackydeb Date: 2012-03-24 16:35:11 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: move xtests to demo_ga Modified Paths: -------------- trunk/octave-forge/main/ga/devel/demo_ga.m trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/devel/demo_ga.m =================================================================== --- trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-24 16:34:53 UTC (rev 10036) +++ trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-24 16:35:11 UTC (rev 10037) @@ -65,3 +65,73 @@ ## This code shows a more complex objective function # TODO: convert to demo # %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); + + +## TODO: these should probably become tests (test, not xtest) using a deterministic sequence of random number +## +## simple optimization result checks. Failures here could happen because +## of non-determinism in the result but if one of these tests always +## fails for you, plese consider dropping an email to the octave-forge +## mailing list <oct...@li...>. +# %!function f = ff (min) +# %! f = @(x) sum ((x(:, 1:(columns (min))) - repmat (min, +# %! rows (x), 1)) .** 2, 2); +# %!function [C, Ceq] = nonlcon (x) +# %! C = []; +# %! Ceq = []; +# %!function r = rand_porcelain (interval_min, interval_max, nvars) +# %! assert (interval_min < interval_max); +# %! r = interval_min + ((interval_max - interval_min) * rand (1, nvars)); +# %!function t = tol (nvars) +# %! t = repelems (0.15, [1; nvars]); +# %!xtest +# %! nvars = 1; +# %! minimum = zeros (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 2; +# %! minimum = zeros (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 3; +# %! minimum = zeros (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 1; +# %! minimum = ones (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 2; +# %! minimum = ones (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 3; +# %! minimum = ones (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 1; +# %! interval_min = -10; +# %! interval_max = 10; +# %! minimum = - rand_porcelain (interval_min, interval_max, nvars); +# %! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +# %! "CrossoverFraction", 0.2); +# %! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +# %! assert (x, minimum, 4 .* tol (nvars)); +# %!xtest +# %! nvars = 2; +# %! interval_min = -10; +# %! interval_max = 10; +# %! minimum = - rand_porcelain (interval_min, interval_max, nvars); +# %! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +# %! "CrossoverFraction", 0.2); +# %! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +# %! assert (x, minimum, 4 .* tol (nvars)); +# %!xtest +# %! nvars = 3; +# %! interval_min = -10; +# %! interval_max = 10; +# %! minimum = - rand_porcelain (interval_min, interval_max, nvars); +# %! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +# %! "CrossoverFraction", 0.2); +# %! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +# %! assert (x, minimum, 4 .* tol (nvars)); Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:34:53 UTC (rev 10036) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:35:11 UTC (rev 10037) @@ -370,71 +370,3 @@ %! bad_options = gaoptimset ("UseParallel", "garbage", %! "Vectorized", "garbage"); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); - - -## simple optimization result checks. Failures here could happen because -## of non-determinism in the result but if one of these tests always -## fails for you, plese consider dropping an email to the octave-forge -## mailing list <oct...@li...>. -%!function f = ff (min) -%! f = @(x) sum ((x(:, 1:(columns (min))) - repmat (min, -%! rows (x), 1)) .** 2, 2); -%!function [C, Ceq] = nonlcon (x) -%! C = []; -%! Ceq = []; -%!function r = rand_porcelain (interval_min, interval_max, nvars) -%! assert (interval_min < interval_max); -%! r = interval_min + ((interval_max - interval_min) * rand (1, nvars)); -%!function t = tol (nvars) -%! t = repelems (0.15, [1; nvars]); -%!xtest -%! nvars = 1; -%! minimum = zeros (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 2; -%! minimum = zeros (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 3; -%! minimum = zeros (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 1; -%! minimum = ones (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 2; -%! minimum = ones (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 3; -%! minimum = ones (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 1; -%! interval_min = -10; -%! interval_max = 10; -%! minimum = - rand_porcelain (interval_min, interval_max, nvars); -%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], -%! "CrossoverFraction", 0.2); -%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); -%! assert (x, minimum, 4 .* tol (nvars)); -%!xtest -%! nvars = 2; -%! interval_min = -10; -%! interval_max = 10; -%! minimum = - rand_porcelain (interval_min, interval_max, nvars); -%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], -%! "CrossoverFraction", 0.2); -%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); -%! assert (x, minimum, 4 .* tol (nvars)); -%!xtest -%! nvars = 3; -%! interval_min = -10; -%! interval_max = 10; -%! minimum = - rand_porcelain (interval_min, interval_max, nvars); -%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], -%! "CrossoverFraction", 0.2); -%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); -%! assert (x, minimum, 4 .* tol (nvars)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-04-05 23:56:23
|
Revision: 10161 http://octave.svn.sourceforge.net/octave/?rev=10161&view=rev Author: slackydeb Date: 2012-04-05 23:56:17 +0000 (Thu, 05 Apr 2012) Log Message: ----------- ga: bump version number There are enough changes to bump the second version number. Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/NEWS Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2012-04-05 23:55:58 UTC (rev 10160) +++ trunk/octave-forge/main/ga/DESCRIPTION 2012-04-05 23:56:17 UTC (rev 10161) @@ -1,6 +1,6 @@ Name: ga -Version: 0.9.9 -Date: 2012-03-15 +Version: 0.10.0 +Date: 2012-04-06 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm Modified: trunk/octave-forge/main/ga/NEWS =================================================================== --- trunk/octave-forge/main/ga/NEWS 2012-04-05 23:55:58 UTC (rev 10160) +++ trunk/octave-forge/main/ga/NEWS 2012-04-05 23:56:17 UTC (rev 10161) @@ -1,7 +1,7 @@ Summary of important user-visible changes for releases of the ga package =============================================================================== -ga-0.9.9 Release Date: 2012-xx-yy Release Manager: Luca Favatella +ga-0.10.0 Release Date: 2012-04-06 Release Manager: Luca Favatella =============================================================================== ** Remove dependency on the "communications" package and require This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |