|
From: <sla...@us...> - 2008-12-08 23:33:59
|
Revision: 5484
http://octave.svn.sourceforge.net/octave/?rev=5484&view=rev
Author: slackydeb
Date: 2008-12-08 23:33:48 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
Get tests of the ga function less verbose and add TODO comments to them.
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2008-12-08 21:22:17 UTC (rev 5483)
+++ trunk/octave-forge/main/ga/inst/ga.m 2008-12-08 23:33:48 UTC (rev 5484)
@@ -71,7 +71,7 @@
## @end deftypefn
## Author: Luca Favatella <sla...@gm...>
-## Version: 5.19.2
+## Version: 5.19.3
function [x fval exitflag output population scores] = \
ga (fitnessfcn_or_problem,
@@ -114,12 +114,14 @@
endif
endfunction
+
%!# nvars == 2
%!# min != zeros (1, nvars)
+%!# TODO: get this test working with tol = 1e-6
%!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-6)
+%! 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)
%!# nvars == 1
@@ -135,12 +137,15 @@
%!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3)
-%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000))), zeros (1, 2), 1e-6)
+%!# TODO: get this test working with tol = 1e-6
+%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000))), zeros (1, 2), 1e-4)
-%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))), zeros (1, 2), 1e-6)
+%!# TODO: get this test working with tol = 1e-6
+%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))), zeros (1, 2), 1e-4)
%!# nvars == 4
%!# min == zeros (1, nvars)
-%!xtest assert (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))), zeros (1, 4), 1e-6)
\ No newline at end of file
+%!# TODO: get this test working with tol = 1e-3
+%!xtest assert (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))), zeros (1, 4), 1e-2)
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2010-02-16 02:42:12
|
Revision: 6906
http://octave.svn.sourceforge.net/octave/?rev=6906&view=rev
Author: slackydeb
Date: 2010-02-16 02:42:06 +0000 (Tue, 16 Feb 2010)
Log Message:
-----------
Tests semplification and style fixes.
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2010-02-16 02:33:56 UTC (rev 6905)
+++ trunk/octave-forge/main/ga/inst/ga.m 2010-02-16 02:42:06 UTC (rev 6906)
@@ -71,7 +71,7 @@
## @end deftypefn
## Author: Luca Favatella <sla...@gm...>
-## Version: 5.21
+## Version: 5.21.1
function [x fval exitflag output population scores] = \
ga (fitnessfcn_or_problem,
@@ -115,8 +115,7 @@
endfunction
-%!# nvars == 2
-%!# min != zeros (1, nvars)
+## nvars == 2 and min != zeros (1, nvars)
%!# TODO: get this test working with tol = 1e-6
%!xtest
@@ -124,16 +123,14 @@
%! 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)
-%!# nvars == 1
-%!# min == zeros (1, nvars)
+## nvars == 1 and min == zeros (1, nvars)
%!test assert (ga (@(x) x ** 2, 1), 0, 1e-3)
%!test assert (ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1), 0, 1e-3)
-%!# nvars == 2
-%!# min == zeros (1, nvars)
+## nvars == 2 and min == zeros (1, nvars)
%!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3)
@@ -144,27 +141,26 @@
%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))), zeros (1, 2), 1e-4)
-%!# nvars == 4
-%!# min == zeros (1, nvars)
+## nvars == 4 and min == zeros (1, nvars)
%!# TODO: get this test working with tol = 1e-3
%!xtest assert (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))), zeros (1, 4), 1e-2)
-%!# InitialPopulation and InitialScores options
+## InitialPopulation and InitialScores options
-%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "PopulationSize", 3)));
+%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "PopulationSize", 3)));
-%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialScores", [0; 0; 0])));
+%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialScores", [0; 0; 0])));
-%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0], "InitialScores", [0; 0; 0])));
+%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0], "InitialScores", [0; 0; 0])));
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0])));
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0])));
-%!# Vectorized and UseParallel options
+## Vectorized and UseParallel options
%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Vectorized", "bad value")));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2010-02-16 02:56:39
|
Revision: 6907
http://octave.svn.sourceforge.net/octave/?rev=6907&view=rev
Author: slackydeb
Date: 2010-02-16 02:56:32 +0000 (Tue, 16 Feb 2010)
Log Message:
-----------
Test that 'Vectorized' option speeds up execution.
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2010-02-16 02:42:06 UTC (rev 6906)
+++ trunk/octave-forge/main/ga/inst/ga.m 2010-02-16 02:56:32 UTC (rev 6907)
@@ -170,5 +170,16 @@
%!xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always")));
- #TODO: test that Vectorized speeds up execution
+%!test ## Vectorized option speeds up execution
+%!
+%! 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);
+
#TODO: test that UseParallel speeds up execution
\ No newline at end of file
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:22:42
|
Revision: 9892
http://octave.svn.sourceforge.net/octave/?rev=9892&view=rev
Author: slackydeb
Date: 2012-03-15 02:22:36 +0000 (Thu, 15 Mar 2012)
Log Message:
-----------
ga: analyze the test suite of the ga function
Preliminary action in order to solve bug #3287917 (Debian
bug #622929).
http://sourceforge.net/tracker/?func=detail&aid=3287917&group_id=2888&atid=102888
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=622929
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-14 22:54:39 UTC (rev 9891)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-15 02:22:36 UTC (rev 9892)
@@ -117,6 +117,8 @@
## nvars == 2 and min != zeros (1, nvars)
+## TODO: Move this code into a future demo, as it shows that ga
+## optimizes also functions whose minimum is not in zero
%!# TODO: get this test working with tol = 1e-6
%!xtest
%! min = [-1, 2];
@@ -132,17 +134,23 @@
## nvars == 2 and min == zeros (1, nvars)
+## TODO: Move this code into a future demo, as it shows that ga
+## optimizes also functions with nvars > 0
%!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3)
+## TODO: Convert this test into a test on type of arguments
%!# TODO: get this test working with tol = 1e-6
%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000))), zeros (1, 2), 1e-4)
+## TODO: This test is like the previous one ("PopulationSize" vs.
+## "Generations"): remove it?
%!# TODO: get this test working with tol = 1e-6
%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))), zeros (1, 2), 1e-4)
## nvars == 4 and min == zeros (1, nvars)
+## TODO: Convert this test into a test on type of arguments
%!# TODO: get this test working with tol = 1e-3
%!xtest assert (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))), zeros (1, 4), 1e-2)
@@ -166,6 +174,7 @@
%!xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always")));
+## TODO: move to demo as this is really a xtest
%!test ## Vectorized option speeds up execution
%!
%! tic ();
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:49:21
|
Revision: 9902
http://octave.svn.sourceforge.net/octave/?rev=9902&view=rev
Author: slackydeb
Date: 2012-03-15 02:49:14 +0000 (Thu, 15 Mar 2012)
Log Message:
-----------
ga: avoid printing test output
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-15 02:27:43 UTC (rev 9901)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-15 02:49:14 UTC (rev 9902)
@@ -119,9 +119,9 @@
## type of arguments
-%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)))
+%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)));
-%!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 ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200)))
+%!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 ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200)));
## nvars == 1 and min == zeros (1, nvars)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-17 02:55:15
|
Revision: 9929
http://octave.svn.sourceforge.net/octave/?rev=9929&view=rev
Author: slackydeb
Date: 2012-03-17 02:55:09 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
ga: add unit tests for ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-16 22:29:17 UTC (rev 9928)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-17 02:55:09 UTC (rev 9929)
@@ -1,4 +1,4 @@
-## Copyright (C) 2008, 2010 Luca Favatella <sla...@gm...>
+## Copyright (C) 2008, 2010, 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
@@ -71,7 +71,7 @@
## @end deftypefn
## Author: Luca Favatella <sla...@gm...>
-## Version: 6.0.0
+## Version: 6.0.1
function [x fval exitflag output population scores] = \
ga (fitnessfcn_or_problem,
@@ -116,9 +116,39 @@
## number of arguments
+%!shared f, nvars
+%! f = @rastriginsfcn;
+%! nvars = 2;
+%!error x = ga ()
+%!error x = ga (f)
+%!error x = ga (f, nvars, [])
+%!error x = ga (f, nvars, [], [], [])
+%!error x = ga (f, nvars, [], [], [], [], [])
+%!error x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset (), [])
## type of arguments
+# TODO
+%!shared f, nvars
+%! f = @rastriginsfcn;
+%! nvars = 2;
+#%!function [C, Ceq] = nonlcon (x)
+#%! C = [];
+#%! Ceq = [];
+#%!endfunction
+%!test x = ga (f, nvars);
+%!test x = ga (f, nvars, [], []);
+%!test x = ga (f, nvars, ones (3, nvars), ones (3, 1));
+%!test x = ga (f, nvars, [], [], [], []);
+%!test x = ga (f, nvars, [], [], ones (4, nvars), ones (4, 1));
+%!test x = ga (f, nvars, [], [], [], [], [], []);
+%!test x = ga (f, nvars, [], [], [], [], - Inf (1, nvars), Inf (1, nvars));
+%!test x = ga (f, nvars, [], [], [], [], - ones (1, nvars), ones (1, nvars));
+%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []]);
+#%!test x = ga (f, nvars, [], [], [], [], [], [], @nonlcon);
+%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset ());
+
+
%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)));
%!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 ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200)));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-18 22:27:50
|
Revision: 9953
http://octave.svn.sourceforge.net/octave/?rev=9953&view=rev
Author: slackydeb
Date: 2012-03-18 22:27:44 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
ga: enable unit test for ga
Define test function without using "endfunction" in order to
support Octave 3.4.
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-18 22:20:41 UTC (rev 9952)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-18 22:27:44 UTC (rev 9953)
@@ -132,10 +132,9 @@
%!shared f, nvars
%! f = @rastriginsfcn;
%! nvars = 2;
-#%!function [C, Ceq] = nonlcon (x)
-#%! C = [];
-#%! Ceq = [];
-#%!endfunction
+%!function [C, Ceq] = nonlcon (x)
+%! C = [];
+%! Ceq = [];
%!test x = ga (f, nvars);
%!test x = ga (f, nvars, [], []);
%!test x = ga (f, nvars, ones (3, nvars), ones (3, 1));
@@ -145,7 +144,7 @@
%!test x = ga (f, nvars, [], [], [], [], - Inf (1, nvars), Inf (1, nvars));
%!test x = ga (f, nvars, [], [], [], [], - ones (1, nvars), ones (1, nvars));
%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []]);
-#%!test x = ga (f, nvars, [], [], [], [], [], [], @nonlcon);
+%!test x = ga (f, nvars, [], [], [], [], [], [], @nonlcon);
%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset ());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-19 00:33:41
|
Revision: 9955
http://octave.svn.sourceforge.net/octave/?rev=9955&view=rev
Author: slackydeb
Date: 2012-03-19 00:33:34 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
ga: add TODO comment
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-18 22:53:36 UTC (rev 9954)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:33:34 UTC (rev 9955)
@@ -125,6 +125,7 @@
%!error x = ga (f, nvars, [], [], [])
%!error x = ga (f, nvars, [], [], [], [], [])
%!error x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset (), [])
+# TODO: test number of output arguments
## type of arguments
# TODO
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-19 00:33:53
|
Revision: 9956
http://octave.svn.sourceforge.net/octave/?rev=9956&view=rev
Author: slackydeb
Date: 2012-03-19 00:33:47 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
ga: add comments to ga unit tests
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:33:34 UTC (rev 9955)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:33:47 UTC (rev 9956)
@@ -130,6 +130,7 @@
## type of arguments
# TODO
+## flawless execution with right arguments
%!shared f, nvars
%! f = @rastriginsfcn;
%! nvars = 2;
@@ -147,6 +148,7 @@
%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []]);
%!test x = ga (f, nvars, [], [], [], [], [], [], @nonlcon);
%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset ());
+# TODO: %!test x = ga (problem);
%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-19 00:34:05
|
Revision: 9957
http://octave.svn.sourceforge.net/octave/?rev=9957&view=rev
Author: slackydeb
Date: 2012-03-19 00:33:59 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
ga: add unit test for ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:33:47 UTC (rev 9956)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:33:59 UTC (rev 9957)
@@ -129,6 +129,7 @@
## type of arguments
# TODO
+# TODO: test that each field in the user-specified "problem" structure is checked
## flawless execution with right arguments
%!shared f, nvars
@@ -148,7 +149,11 @@
%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []]);
%!test x = ga (f, nvars, [], [], [], [], [], [], @nonlcon);
%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset ());
-# TODO: %!test x = ga (problem);
+%!test # TODO: convert to error after implementing private ga-specific createOptimProblem. All fields in the user-specified structure should be checked
+%! problem = struct ("fitnessfcn", @rastriginsfcn,
+%! "nvars", 2,
+%! "options", gaoptimset ());
+%! x = ga (problem);
%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-19 00:54:06
|
Revision: 9961
http://octave.svn.sourceforge.net/octave/?rev=9961&view=rev
Author: slackydeb
Date: 2012-03-19 00:54:00 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
ga: polish unit tests of ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:41:01 UTC (rev 9960)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:54:00 UTC (rev 9961)
@@ -157,6 +157,7 @@
%! "options", gaoptimset ());
%! x = ga (problem);
+# TODO: structure/add tests below
%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)));
@@ -187,4 +188,4 @@
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "Vectorized", "on")));
-%!xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always")));
+%!#xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always"))); TODO
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-19 00:54:19
|
Revision: 9962
http://octave.svn.sourceforge.net/octave/?rev=9962&view=rev
Author: slackydeb
Date: 2012-03-19 00:54:13 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
ga: reduce number of generations in a test of ga
The high number of generations does not look strictly needed.
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:54:00 UTC (rev 9961)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-19 00:54:13 UTC (rev 9962)
@@ -159,7 +159,7 @@
# TODO: structure/add tests below
-%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000)));
+%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 200)));
%!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 ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200)));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:58:04
|
Revision: 10010
http://octave.svn.sourceforge.net/octave/?rev=10010&view=rev
Author: slackydeb
Date: 2012-03-23 01:57:58 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: organize unit tests related to options in ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:46 UTC (rev 10009)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:58 UTC (rev 10010)
@@ -168,13 +168,72 @@
%! nvars = 3;
%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars);
+## flawless execution with any supported optimization parameter
+## different from the default value
+%!shared f, nvars
+%! f = @rastriginsfcn;
+%! nvars = 2;
+%!function [C, Ceq] = nonlcon (x)
+%! C = [];
+%! Ceq = [];
+%!test
+%! options = gaoptimset ();
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("CreationFcn", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("CrossoverFcn", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("CrossoverFraction", 0.6);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("EliteCount", 5);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("FitnessLimit", 1e-7);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("FitnessScalingFcn", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("Generations", 200);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("InitialPopulation", rand (4, nvars));
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("InitialScores", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("MutationFcn", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("PopInitRange", [-2; 2]);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("PopulationSize", 200);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("SelectionFcn", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#test
+%!# options = gaoptimset ("TimeLimit", TODO);
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#xtest
+%!# options = gaoptimset ("UseParallel", "always");
+%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test
+%! options = gaoptimset ("Vectorized", "on");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+
+
# TODO: structure/add tests below
-%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 200)));
+%!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 ()));
-%!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 ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200)));
-
## nvars == 1 and min == zeros (1, nvars)
%!test assert (ga (@(x) x ** 2, 1), 0, 1e-3);
@@ -193,10 +252,3 @@
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0])));
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0])));
-
-
-## Vectorized and UseParallel options
-
-%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "Vectorized", "on")));
-
-%!#xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always"))); TODO
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:58:30
|
Revision: 10012
http://octave.svn.sourceforge.net/octave/?rev=10012&view=rev
Author: slackydeb
Date: 2012-03-23 01:58:24 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: structure unit tests in ga about conflicting options
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:11 UTC (rev 10011)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:24 UTC (rev 10012)
@@ -228,6 +228,27 @@
%! options = gaoptimset ("Vectorized", "on");
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+## error with conflicting optimization parameters
+%!shared f, nvars
+%! f = @rastriginsfcn;
+%! nvars = 2;
+%!function [C, Ceq] = nonlcon (x)
+%! C = [];
+%! Ceq = [];
+%!error # The number of individuals in the initial population cannot be greater of the population size
+%! ps = 3;
+%! bad_options = gaoptimset ("PopulationSize", ps,
+%! "InitialPopulation", zeros (ps + 1, nvars));
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!error # Initial scores cannot be specified without specifying the initial population too
+%! bad_options = gaoptimset ("InitialScores", zeros (3, 1));
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!error # The number of initial scores specified cannot be greater of the number of individuals in the initial population
+%! ip = 3;
+%! bad_options = gaoptimset ("InitialPopulation", zeros (ip, nvars),
+%! "InitialScores", zeros (ip + 1, 1));
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+# TODO
# TODO: structure/add tests below
@@ -243,12 +264,6 @@
## InitialPopulation and InitialScores options
-%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "PopulationSize", 3)));
-
-%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialScores", [0; 0; 0])));
-
-%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0], "InitialScores", [0; 0; 0])));
-
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0])));
%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0])));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:58:42
|
Revision: 10013
http://octave.svn.sourceforge.net/octave/?rev=10013&view=rev
Author: slackydeb
Date: 2012-03-23 01:58:36 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: simplify unit tests in ga removing unuseful option
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:24 UTC (rev 10012)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:36 UTC (rev 10013)
@@ -264,6 +264,6 @@
## InitialPopulation and InitialScores options
-%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0])));
+%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0])));
-%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0])));
+%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0])));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:57:39
|
Revision: 10008
http://octave.svn.sourceforge.net/octave/?rev=10008&view=rev
Author: slackydeb
Date: 2012-03-23 01:57:33 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: test number of nvars in ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-22 22:38:34 UTC (rev 10007)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:33 UTC (rev 10008)
@@ -157,6 +157,17 @@
%! "options", gaoptimset ());
%! x = ga (problem);
+## number of nvars
+%!test
+%! nvars = 1;
+%! x = ga (@(x) x(1, 1) ** 2, nvars);
+%!test
+%! nvars = 2;
+%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2), nvars);
+%!test
+%! nvars = 3;
+%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars);
+
# TODO: structure/add tests below
%!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 200)));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:57:52
|
Revision: 10009
http://octave.svn.sourceforge.net/octave/?rev=10009&view=rev
Author: slackydeb
Date: 2012-03-23 01:57:46 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: improve comment in ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:33 UTC (rev 10008)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:46 UTC (rev 10009)
@@ -157,7 +157,7 @@
%! "options", gaoptimset ());
%! x = ga (problem);
-## number of nvars
+## flawless execution with any nvars
%!test
%! nvars = 1;
%! x = ga (@(x) x(1, 1) ** 2, nvars);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:58:17
|
Revision: 10011
http://octave.svn.sourceforge.net/octave/?rev=10011&view=rev
Author: slackydeb
Date: 2012-03-23 01:58:11 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: enable unit tests even if only with standard values
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:57:58 UTC (rev 10010)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:11 UTC (rev 10011)
@@ -177,14 +177,14 @@
%! C = [];
%! Ceq = [];
%!test
-%! options = gaoptimset ();
+%! default_options = gaoptimset ();
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, default_options);
+%!test # TODO: use non-default value
+%! options = gaoptimset ("CreationFcn", @gacreationuniform);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("CreationFcn", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("CrossoverFcn", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test # TODO: use non-default value
+%! options = gaoptimset ("CrossoverFcn", @crossoverscattered);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("CrossoverFraction", 0.6);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
@@ -194,34 +194,34 @@
%!test
%! options = gaoptimset ("FitnessLimit", 1e-7);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("FitnessScalingFcn", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test # TODO: use non-default value
+%! options = gaoptimset ("FitnessScalingFcn", @fitscalingrank);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("Generations", 200);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("InitialPopulation", rand (4, nvars));
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("InitialScores", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("MutationFcn", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test # TODO: use non-default value
+%! options = gaoptimset ("InitialScores", []);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test # TODO: use non-default value
+%! options = gaoptimset ("MutationFcn", {@mutationgaussian, 1, 1});
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("PopInitRange", [-2; 2]);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("PopulationSize", 200);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("SelectionFcn", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#test
-%!# options = gaoptimset ("TimeLimit", TODO);
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#xtest
+%!test # TODO: use non-default value
+%! options = gaoptimset ("SelectionFcn", @selectionstochunif);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!test # TODO: use non-default value
+%! options = gaoptimset ("TimeLimit", Inf);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!#xtest # TODO
%!# options = gaoptimset ("UseParallel", "always");
%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:58:54
|
Revision: 10014
http://octave.svn.sourceforge.net/octave/?rev=10014&view=rev
Author: slackydeb
Date: 2012-03-23 01:58:48 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: add TODO comment in ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:36 UTC (rev 10013)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:48 UTC (rev 10014)
@@ -255,6 +255,7 @@
%!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: convert to simple xtests
## nvars == 1 and min == zeros (1, nvars)
%!test assert (ga (@(x) x ** 2, 1), 0, 1e-3);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:59:06
|
Revision: 10015
http://octave.svn.sourceforge.net/octave/?rev=10015&view=rev
Author: slackydeb
Date: 2012-03-23 01:59:00 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: use random value in unit test
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:58:48 UTC (rev 10014)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:00 UTC (rev 10015)
@@ -186,7 +186,7 @@
%! options = gaoptimset ("CrossoverFcn", @crossoverscattered);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
-%! options = gaoptimset ("CrossoverFraction", 0.6);
+%! options = gaoptimset ("CrossoverFraction", rand);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("EliteCount", 5);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:59:19
|
Revision: 10016
http://octave.svn.sourceforge.net/octave/?rev=10016&view=rev
Author: slackydeb
Date: 2012-03-23 01:59:13 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: add TODO comment in ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:00 UTC (rev 10015)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:13 UTC (rev 10016)
@@ -229,6 +229,7 @@
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
## error with conflicting optimization parameters
+# TODO: Elite count cannot be greater than the population size
%!shared f, nvars
%! f = @rastriginsfcn;
%! nvars = 2;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:59:32
|
Revision: 10017
http://octave.svn.sourceforge.net/octave/?rev=10017&view=rev
Author: slackydeb
Date: 2012-03-23 01:59:26 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: improve unit tests
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:13 UTC (rev 10016)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:26 UTC (rev 10017)
@@ -170,14 +170,14 @@
## flawless execution with any supported optimization parameter
## different from the default value
-%!shared f, nvars
+%!shared f, nvars, default_options
%! f = @rastriginsfcn;
%! nvars = 2;
+%! default_options = gaoptimset ();
%!function [C, Ceq] = nonlcon (x)
%! C = [];
%! Ceq = [];
%!test
-%! default_options = gaoptimset ();
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, default_options);
%!test # TODO: use non-default value
%! options = gaoptimset ("CreationFcn", @gacreationuniform);
@@ -189,7 +189,8 @@
%! options = gaoptimset ("CrossoverFraction", rand);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
-%! options = gaoptimset ("EliteCount", 5);
+%! ps = getfield (default_options, "PopulationSize");
+%! options = gaoptimset ("EliteCount", randi ([0, ps]));
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("FitnessLimit", 1e-7);
@@ -198,15 +199,50 @@
%! options = gaoptimset ("FitnessScalingFcn", @fitscalingrank);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
-%! options = gaoptimset ("Generations", 200);
+%! g = getfield (default_options, "Generations");
+%! options = gaoptimset ("Generations", g + 1);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
-%! options = gaoptimset ("InitialPopulation", rand (4, nvars));
-%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%! ps = getfield (default_options, "PopulationSize");
+%! ## Initial population can be partial
+%! options_w_full_ip = \
+%! gaoptimset ("InitialPopulation", rand (ps, nvars));
+%! partial_ip = randi ([0, ps - 1]);
+%! options_w_partial_ip = \
+%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars));
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options_w_full_ip);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options_w_partial_ip);
+%!test
+%! ps = getfield (default_options, "PopulationSize");
+%! ## Initial scores needs initial population
+%!
+%! options_w_full_ip_full_is = \
+%! gaoptimset ("InitialPopulation", rand (ps, nvars),
+%! "InitialScores", rand (ps, 1 ));
+%! partial_ip = randi ([2, ps - 1]);
+%! options_w_partial_ip_full_is = \
+%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars),
+%! "InitialScores", rand (partial_ip, 1 ));
+%!
+%! ## Initial scores can be partial
+%! partial_is_when_full_ip = randi ([1, ps - 1]);
+%! partial_is_when_partial_ip = randi ([1, partial_ip - 1]);
+%! options_w_full_ip_partial_is = \
+%! gaoptimset ("InitialPopulation", rand (ps, nvars),
+%! "InitialScores", rand (partial_is_when_full_ip, 1 ));
+%! options_w_partial_ip_partial_is = \
+%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars),
+%! "InitialScores", rand (partial_is_when_partial_ip, 1 ));
+%!
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon,
+%! options_w_full_ip_full_is);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon,
+%! options_w_partial_ip_full_is);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon,
+%! options_w_full_ip_partial_is);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon,
+%! options_w_partial_ip_partial_is);
%!test # TODO: use non-default value
-%! options = gaoptimset ("InitialScores", []);
-%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!test # TODO: use non-default value
%! options = gaoptimset ("MutationFcn", {@mutationgaussian, 1, 1});
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
@@ -262,10 +298,3 @@
%!test assert (ga (@(x) x ** 2, 1), 0, 1e-3);
%!test assert (ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1), 0, 1e-3);
-
-
-## InitialPopulation and InitialScores options
-
-%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0])));
-
-%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0])));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sla...@us...> - 2012-03-23 01:59:44
|
Revision: 10018
http://octave.svn.sourceforge.net/octave/?rev=10018&view=rev
Author: slackydeb
Date: 2012-03-23 01:59:38 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
ga: add unit test in ga
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:26 UTC (rev 10017)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-23 01:59:38 UTC (rev 10018)
@@ -265,13 +265,17 @@
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
## error with conflicting optimization parameters
-# TODO: Elite count cannot be greater than the population size
%!shared f, nvars
%! f = @rastriginsfcn;
%! nvars = 2;
%!function [C, Ceq] = nonlcon (x)
%! C = [];
%! Ceq = [];
+%!error # Elite count cannot be greater than the population size
+%! ps = 3;
+%! bad_options = gaoptimset ("PopulationSize", ps,
+%! "EliteCount", ps + 1);
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
%!error # The number of individuals in the initial population cannot be greater of the population size
%! ps = 3;
%! bad_options = gaoptimset ("PopulationSize", ps,
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:32:31
|
Revision: 10025
http://octave.svn.sourceforge.net/octave/?rev=10025&view=rev
Author: slackydeb
Date: 2012-03-24 16:32:25 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
ga: remove TODO comment in ga
It looks like there are no more conflicting optimization parameters to
consider at the moment.
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:31:18 UTC (rev 10024)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:32:25 UTC (rev 10025)
@@ -289,7 +289,6 @@
%! bad_options = gaoptimset ("InitialPopulation", zeros (ip, nvars),
%! "InitialScores", zeros (ip + 1, 1));
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
-# TODO
# TODO: structure/add tests below
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:33:08
|
Revision: 10028
http://octave.svn.sourceforge.net/octave/?rev=10028&view=rev
Author: slackydeb
Date: 2012-03-24 16:33:02 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
ga: test parallel and vectorized evaluation of finessfcn
Modified Paths:
--------------
trunk/octave-forge/main/ga/inst/ga.m
Modified: trunk/octave-forge/main/ga/inst/ga.m
===================================================================
--- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:32:50 UTC (rev 10027)
+++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:02 UTC (rev 10028)
@@ -257,14 +257,14 @@
%!test # TODO: use non-default value
%! options = gaoptimset ("TimeLimit", Inf);
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#xtest # TODO
-%!# options = gaoptimset ("UseParallel", "always");
-%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!error # TODO: this should become test
+%! options = gaoptimset ("UseParallel", "always");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
%!test
%! options = gaoptimset ("Vectorized", "on");
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-## error with conflicting optimization parameters
+## error with conflicting optimization parameters: population size et al.
%!shared f, nvars
%! f = @rastriginsfcn;
%! nvars = 2;
@@ -290,6 +290,51 @@
%! "InitialScores", zeros (ip + 1, 1));
%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+## error with conflicting optimization parameters: parallel and
+## vectorized evaluation of objective function
+%!shared f, nvars
+%! f = @rastriginsfcn;
+%! nvars = 2;
+%!function [C, Ceq] = nonlcon (x)
+%! C = [];
+%! Ceq = [];
+%!test
+%! options = gaoptimset ("UseParallel", "never",
+%! "Vectorized", "off");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!error # TODO: this should become test
+%! options = gaoptimset ("UseParallel", "always",
+%! "Vectorized", "off");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!error
+%! bad_options = gaoptimset ("UseParallel", "garbage",
+%! "Vectorized", "off");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!test
+%! options = gaoptimset ("UseParallel", "never",
+%! "Vectorized", "on");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
+%!warning
+%! bad_options = gaoptimset ("UseParallel", "always",
+%! "Vectorized", "on");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!warning
+%! bad_options = gaoptimset ("UseParallel", "garbage",
+%! "Vectorized", "on");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!error
+%! bad_options = gaoptimset ("UseParallel", "never",
+%! "Vectorized", "garbage");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!error
+%! bad_options = gaoptimset ("UseParallel", "always",
+%! "Vectorized", "garbage");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+%!error
+%! bad_options = gaoptimset ("UseParallel", "garbage",
+%! "Vectorized", "garbage");
+%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options);
+
# TODO: structure/add tests below
%!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 ()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|