From: <sla...@us...> - 2012-03-24 16:34:19
|
Revision: 10033 http://octave.svn.sourceforge.net/octave/?rev=10033&view=rev Author: slackydeb Date: 2012-03-24 16:34:10 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: fix failing unit test A non-vectorized objective function must not work when vectorization is required. Modified Paths: -------------- trunk/octave-forge/main/ga/inst/__ga_scores__.m Modified: trunk/octave-forge/main/ga/inst/__ga_scores__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:33:56 UTC (rev 10032) +++ trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:34:10 UTC (rev 10033) @@ -14,9 +14,10 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 5.6 +## Version: 5.7 function Scores = __ga_scores__ (problem, Population) + [nrP ncP] = size (Population); switch problem.options.Vectorized case "on" ## using vectorized evaluation switch problem.options.UseParallel @@ -27,13 +28,12 @@ otherwise warning ("'Vectorized' option is 'on': ignoring invalid 'UseParallel' option value (it should be 'always' or 'never')"); endswitch - Scores = problem.fitnessfcn (Population); + Scores = (problem.fitnessfcn (Population))(1:nrP, 1); case "off" ## not using vectorized evaluation switch problem.options.UseParallel case "always" ## using parallel evaluation error ("TODO: implement parallel evaluation of objective function"); case "never" ## using serial evaluation (i.e. loop) - [nrP ncP] = size (Population); tmp = zeros (nrP, 1); for index = 1:nrP tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |