From: <sla...@us...> - 2008-08-03 16:19:35
|
Revision: 5210 http://octave.svn.sourceforge.net/octave/?rev=5210&view=rev Author: slackydeb Date: 2008-08-03 16:19:44 +0000 (Sun, 03 Aug 2008) Log Message: ----------- removed gaoptimget function because it is almost unuseful and too difficult to mantain; modified all code not to use the removed function; bump version because of these changes Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/__ga_problem__.m trunk/octave-forge/main/ga/inst/__ga_stop__.m trunk/octave-forge/main/ga/inst/gacreationuniform.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2008-08-03 15:00:59 UTC (rev 5209) +++ trunk/octave-forge/main/ga/DESCRIPTION 2008-08-03 16:19:44 UTC (rev 5210) @@ -1,5 +1,5 @@ Name: ga -Version: 0.2.1 +Version: 0.3 Date: 2008-07-23 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Modified: trunk/octave-forge/main/ga/inst/__ga_problem__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_problem__.m 2008-08-03 15:00:59 UTC (rev 5209) +++ trunk/octave-forge/main/ga/inst/__ga_problem__.m 2008-08-03 16:19:44 UTC (rev 5210) @@ -17,13 +17,13 @@ ## 02110-1301, USA. ## Author: Luca Favatella <sla...@gm...> -## Version: 3.2 +## Version: 4.0 function x = __ga_problem__ (problem) individui_migliori = []; - popolazione = (gaoptimget (problem.options, 'CreationFcn')) (problem.nvars, problem.fitnessfcn, problem.options); + popolazione = problem.options.CreationFcn (problem.nvars, problem.fitnessfcn, problem.options); %% in this while, generation is fixed generazione = 1; @@ -32,39 +32,33 @@ %% doing this initialization here to make the variable %% popolazione_futura visible at the end of the next while - popolazione_futura = zeros (gaoptimget (problem.options, - 'PopulationSize'), + popolazione_futura = zeros (problem.options.PopulationSize, problem.nvars); %% elitist selection - for i = 1:(gaoptimget (problem.options, 'EliteCount')) + for i = 1:problem.options.EliteCount popolazione_futura(i, :) = (__ga_sort_ascend_population__ (problem.fitnessfcn, popolazione))(i, :); endfor %% in this while the individual of the new generation is fixed - for i = (1 + (gaoptimget (problem.options, - 'EliteCount'))):(gaoptimget (problem.options, - 'PopulationSize')) + for i = (1 + problem.options.EliteCount):problem.options.PopulationSize %% stochastically choosing the genetic operator to apply aux_operatore = rand (); %% crossover - if (aux_operatore < gaoptimget (problem.options, - 'CrossoverFraction')) - index_parents = (gaoptimget (problem.options, - 'SelectionFcn')) (problem.fitnessfcn, - popolazione); - parents = [popolazione(index_parents(1), :); + if (aux_operatore < problem.options.CrossoverFraction) + index_parents = problem.options.SelectionFcn (problem.fitnessfcn, + popolazione); + parents = [popolazione(index_parents(1), :); popolazione(index_parents(2), :)]; - popolazione_futura(i, :) = gaoptimget (problem.options, 'CrossoverFcn') (parents); + popolazione_futura(i, :) = problem.options.CrossoverFcn (parents); - %% mutation + %% mutation else - index_parent = (gaoptimget (problem.options, - 'SelectionFcn')) (problem.fitnessfcn, - popolazione); - popolazione_futura(i, :) = (gaoptimget (problem.options, 'MutationFcn')) (popolazione(index_parent(1), :)); + index_parent = problem.options.SelectionFcn (problem.fitnessfcn, + popolazione); + popolazione_futura(i, :) = problem.options.MutationFcn (popolazione(index_parent(1), :)); endif endfor Modified: trunk/octave-forge/main/ga/inst/__ga_stop__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_stop__.m 2008-08-03 15:00:59 UTC (rev 5209) +++ trunk/octave-forge/main/ga/inst/__ga_stop__.m 2008-08-03 16:19:44 UTC (rev 5210) @@ -17,15 +17,14 @@ ## 02110-1301, USA. ## Author: Luca Favatella <sla...@gm...> -## Version: 3.2 +## Version: 4.0 %% return true if the stop condition is reached, false otherwise function retval = __ga_stop__ (problem, popolazione, generazione) - __ga_stop_aux1__ = (generazione >= gaoptimget (problem.options, - 'Generations')); + __ga_stop_aux1__ = (generazione >= problem.options.Generations); %% in doc Matlab <= and not < is supposed - __ga_stop_aux2__ = (problem.fitnessfcn ((__ga_sort_ascend_population__ (problem.fitnessfcn, popolazione))(1, :)) <= gaoptimget (problem.options, 'FitnessLimit')); + __ga_stop_aux2__ = (problem.fitnessfcn ((__ga_sort_ascend_population__ (problem.fitnessfcn, popolazione))(1, :)) <= problem.options.FitnessLimit); retval = (__ga_stop_aux1__ || __ga_stop_aux2__); endfunction \ 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-03 15:00:59 UTC (rev 5209) +++ trunk/octave-forge/main/ga/inst/gacreationuniform.m 2008-08-03 16:19:44 UTC (rev 5210) @@ -40,15 +40,15 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 3.2 +## Version: 4.0 function Population = gacreationuniform (GenomeLength, FitnessFcn, options) %% aux variables - tmp_aux = gaoptimget (options, 'PopInitRange'); + tmp_aux = options.PopInitRange; lb = min (tmp_aux(1, 1), tmp_aux(2, 1)); ub = max (tmp_aux(1, 1), tmp_aux(2, 1)); - n_rows_aux = gaoptimget (options, 'PopulationSize'); + n_rows_aux = options.PopulationSize; Population = ((ub - lb) * rand (n_rows_aux, GenomeLength)) + (lb * ones (n_rows_aux, GenomeLength)); endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |