From: <sla...@us...> - 2008-08-03 20:22:19
|
Revision: 5212 http://octave.svn.sourceforge.net/octave/?rev=5212&view=rev Author: slackydeb Date: 2008-08-03 20:22:28 +0000 (Sun, 03 Aug 2008) Log Message: ----------- rewrote the ga function to be simpler; more fields added to the problem structure in the function ga Modified Paths: -------------- trunk/octave-forge/main/ga/DESCRIPTION trunk/octave-forge/main/ga/inst/ga.m trunk/octave-forge/main/ga/inst/gaoptimset.m Modified: trunk/octave-forge/main/ga/DESCRIPTION =================================================================== --- trunk/octave-forge/main/ga/DESCRIPTION 2008-08-03 19:04:01 UTC (rev 5211) +++ trunk/octave-forge/main/ga/DESCRIPTION 2008-08-03 20:22:28 UTC (rev 5212) @@ -1,5 +1,5 @@ Name: ga -Version: 0.4 +Version: 0.4.2 Date: 2008-08-03 Author: Luca Favatella <sla...@gm...> Maintainer: Luca Favatella <sla...@gm...> Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2008-08-03 19:04:01 UTC (rev 5211) +++ trunk/octave-forge/main/ga/inst/ga.m 2008-08-03 20:22:28 UTC (rev 5212) @@ -44,52 +44,45 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 5.0 +## Version: 5.5 -function [x fval exitflag output population scores] = ga (varargin) +function [x, fval, exitflag, output, population, scores] = \ + ga (fitnessfcn_or_problem, + nvars, + A = [], b = [], + Aeq = [], beq = [], + LB = [], UB = [], + nonlcon = [], + options = gaoptimset) if ((nargout > 6) || - (length (varargin) < 1) || - (length (varargin) == 3) || - (length (varargin) == 5) || - (length (varargin) == 7) || - (length (varargin) > 10)) + (nargin < 1) || + (nargin == 3) || + (nargin == 5) || + (nargin == 7) || + (nargin > 10)) print_usage (); else ## retrieve problem structure - if (length (varargin) == 1) - problem = varargin{1}; - else ## length (varargin) >= 2 - - ## set default options field - problem.options = gaoptimset; - - ## set fields specified - problem.fitnessfcn = varargin{1}; - problem.nvars = varargin{2}; - if (length (varargin) >= 4) - problem.Aineq = varargin{3}; - problem.Bineq = varargin{4}; - if (length (varargin) >= 6) - problem.Aeq = varargin{5}; - problem.Beq = varargin{6}; - if (length (varargin) >= 8) - problem.lb = varargin{7}; - problem.ub = varargin{8}; - if (length (varargin) >= 9) - problem.nonlcon = varargin{9}; - - ## if a custom options field is specified, overwrite the - ## default one - if (length (varargin) == 10) - problem.options = varargin{10}; - endif - endif - endif - endif - endif + if (nargin == 1) + problem = fitnessfcn_or_problem; + else + problem.fitnessfcn = fitnessfcn_or_problem; + problem.nvars = nvars; + problem.Aineq = A; + problem.Bineq = b; + problem.Aeq = Aeq; + problem.Beq = beq; + problem.lb = LB; + problem.ub = UB; + problem.nonlcon = nonlcon; + problem.randstate = rand ("state"); + problem.randnstate = randn ("state"); + problem.solver = "ga"; + problem.options = options; endif + ## call the function that manages the problem structure [x fval exitflag output population scores] = __ga_problem__ (problem); endif endfunction Modified: trunk/octave-forge/main/ga/inst/gaoptimset.m =================================================================== --- trunk/octave-forge/main/ga/inst/gaoptimset.m 2008-08-03 19:04:01 UTC (rev 5211) +++ trunk/octave-forge/main/ga/inst/gaoptimset.m 2008-08-03 20:22:28 UTC (rev 5212) @@ -53,7 +53,7 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 3.4 +## Version: 3.6 function options = gaoptimset (varargin) if (nargout != 1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |