]> Creatis software - CreaPhase.git/blob - octave_packages/ga-0.10.0/__ga_problem_private_state__.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / ga-0.10.0 / __ga_problem_private_state__.m
1 ## Copyright (C) 2008 Luca Favatella <slackydeb@gmail.com>
2 ##
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.
7 ##
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.
12 ##
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/>.
15
16 ## Author: Luca Favatella <slackydeb@gmail.com>
17 ## Version: 1.1.1
18
19 function private_state = __ga_problem_private_state__ (options)
20   private_state.ReproductionCount.elite = options.EliteCount;
21   private_state.ReproductionCount.crossover = \
22       fix (options.CrossoverFraction *
23            (options.PopulationSize - options.EliteCount));
24   private_state.ReproductionCount.mutation = \
25       options.PopulationSize - \
26       (private_state.ReproductionCount.elite +
27        private_state.ReproductionCount.crossover);
28   assert (private_state.ReproductionCount.elite +
29           private_state.ReproductionCount.crossover +
30           private_state.ReproductionCount.mutation,
31           options.PopulationSize); ## DEBUG
32
33   private_state.parentsCount.crossover = \
34       2 * private_state.ReproductionCount.crossover;
35   private_state.parentsCount.mutation = \
36       1 * private_state.ReproductionCount.mutation;
37   private_state.nParents = \
38       private_state.parentsCount.crossover + \
39       private_state.parentsCount.mutation;
40
41   private_state.parentsSelection.crossover = \
42       1:private_state.parentsCount.crossover;
43   private_state.parentsSelection.mutation = \
44       private_state.parentsCount.crossover + \
45       (1:private_state.parentsCount.mutation);
46   assert (length (private_state.parentsSelection.crossover) +
47           length (private_state.parentsSelection.mutation),
48           private_state.nParents); ## DEBUG
49 endfunction