From: <sla...@us...> - 2008-08-07 22:12:13
|
Revision: 5229 http://octave.svn.sourceforge.net/octave/?rev=5229&view=rev Author: slackydeb Date: 2008-08-07 22:12:22 +0000 (Thu, 07 Aug 2008) Log Message: ----------- improve mutationscattered Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/__ga_problem__.m trunk/octave-forge/main/ga/inst/mutationgaussian.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2008-08-07 13:21:13 UTC (rev 5228) +++ trunk/octave-forge/main/ga/DESCRIPTION 2008-08-07 22:12:22 UTC (rev 5229) @@ -1,6 +1,6 @@ Name: ga -Version: 0.5.1 -Date: 2008-08-07 +Version: 0.5.2 +Date: 2008-08-08 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Title: Genetic Algorithm and Direct Search Modified: trunk/octave-forge/main/ga/inst/__ga_problem__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_problem__.m 2008-08-07 13:21:13 UTC (rev 5228) +++ trunk/octave-forge/main/ga/inst/__ga_problem__.m 2008-08-07 22:12:22 UTC (rev 5229) @@ -17,14 +17,14 @@ ## 02110-1301, USA. ## Author: Luca Favatella <sla...@gm...> -## Version: 4.3 +## Version: 4.4 function [x fval exitflag output population scores] = __ga_problem__ (problem) individui_migliori = []; popolazione = __ga_set_initial_population__ (problem); %% in this while, generation is fixed - generazione = 1; + generazione = 1; ## TODO initial generation should be 0 (for state structure) individui_migliori(generazione, :) = (__ga_sort_ascend_population__ (problem.fitnessfcn, popolazione))(1, :); while (! __ga_stop__ (problem, popolazione, generazione)) @@ -63,12 +63,26 @@ index_parent = problem.options.SelectionFcn (problem.fitnessfcn, popolazione); parent = popolazione(index_parent(1), :); + ## start preparing state structure + state.Population = popolazione; + #state.Score + state.Generation = generazione; + #state.StartTime + #state.StopFlag + #state.Selection + #state.Expectation + #state.Best + #state.LastImprovement + #state.LastImprovementTime + #state.NonlinIneq + #state.NonlinEq + ## end preparing state structure popolazione_futura(i, :) = \ #TODO parent -> parents problem.options.MutationFcn{1, 1} (parent, problem.options, problem.nvars, problem.fitnessfcn, - false, #TODO false -> state + state, false, #TODO false -> thisScore popolazione); endif Modified: trunk/octave-forge/main/ga/inst/mutationgaussian.m =================================================================== --- trunk/octave-forge/main/ga/inst/mutationgaussian.m 2008-08-07 13:21:13 UTC (rev 5228) +++ trunk/octave-forge/main/ga/inst/mutationgaussian.m 2008-08-07 22:12:22 UTC (rev 5229) @@ -24,13 +24,33 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 0.1 +## Version: 0.2.3 function mutationChildren = \ mutationgaussian (parents, options, nvars, FitnessFcn, state, thisScore, thisPopulation) + [nr, nc] = size (options.PopInitRange); + + if ((nr != 2) + ((nc != 1) && (nc != nvars))) + error ("'PopInitRange' must be 2-by-1 or 2-by-nvars"); + endif + + ## obtain a 2-by-nvars LocalPopInitRange + LocalPopInitRange = options.PopInitRange; + if (nc == 1) + LocalPopInitRange = LocalPopInitRange * ones (1, nvars); + endif + + LB = LocalPopInitRange(1, 1:nvars); + UB = LocalPopInitRange(2, 1:nvars); + + ## mutationgaussian p1 = parents(1, 1:nvars); - - mutationChildren = p1 + randn (1, nvars); + Scale = options.MutationFcn{1, 2}; + initial_std = Scale * (UB - LB); + Shrink = options.MutationFcn{1, 3}; + current_std = initial_std * (1 - Shrink * (state.Generation / options.Generations)); ## TODO consider all generations recursively, not only one + mutationChildren = p1 + current_std .* randn (1, nvars); 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. |