1 ## Copyright (C) 2008, 2010 Luca Favatella <slackydeb@gmail.com>
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
16 ## Author: Luca Favatella <slackydeb@gmail.com>
19 function Scores = __ga_scores__ (problem, Population)
20 [nrP ncP] = size (Population);
21 switch problem.options.Vectorized
22 case "on" ## using vectorized evaluation
23 switch problem.options.UseParallel
25 warning ("'Vectorized' option is 'on': ignoring 'UseParallel' option, even if it is 'always'");
29 warning ("'Vectorized' option is 'on': ignoring invalid 'UseParallel' option value (it should be 'always' or 'never')");
31 Scores = (problem.fitnessfcn (Population))(1:nrP, 1);
32 case "off" ## not using vectorized evaluation
33 switch problem.options.UseParallel
34 case "always" ## using parallel evaluation
35 error ("TODO: implement parallel evaluation of objective function");
36 case "never" ## using serial evaluation (i.e. loop)
39 tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP));
41 Scores = tmp(1:nrP, 1);
43 error ("'UseParallel' option must be 'always' or 'never'");
46 error ("'Vectorized' option must be 'on' or 'off'");