]> Creatis software - CreaPhase.git/blob - octave_packages/ga-0.10.0/gacreationuniform.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / ga-0.10.0 / gacreationuniform.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 ## -*- texinfo -*-
17 ## @deftypefn{Function File} {@var{Population} =} gacreationuniform (@var{GenomeLength}, @var{FitnessFcn}, @var{options})
18 ## Create a random initial population with a uniform distribution.
19 ##
20 ## @strong{Inputs}
21 ## @table @var
22 ## @item GenomeLength
23 ## The number of indipendent variables for the fitness function.
24 ## @item FitnessFcn
25 ## The fitness function.
26 ## @item options
27 ## The options structure.
28 ## @end table
29 ##
30 ## @strong{Outputs}
31 ## @table @var
32 ## @item Population
33 ## The initial population for the genetic algorithm.
34 ## @end table
35 ##
36 ## @seealso{ga, gaoptimset}
37 ## @end deftypefn
38
39 ## Author: Luca Favatella <slackydeb@gmail.com>
40 ## Version: 4.9
41
42 function Population = gacreationuniform (GenomeLength, FitnessFcn, options)
43   [LB(1, 1:GenomeLength) UB(1, 1:GenomeLength)] = \
44       __ga_popinitrange__ (options.PopInitRange, GenomeLength);
45
46   ## pseudocode
47   ##
48   ## Population = Delta * RandomPopulationBetween0And1 + Offset
49   Population(1:options.PopulationSize, 1:GenomeLength) = \
50       ((ones (options.PopulationSize, 1) * (UB - LB)) .* \
51        rand (options.PopulationSize, GenomeLength)) + \
52       (ones (options.PopulationSize, 1) * LB);
53 endfunction
54
55
56 ## number of input arguments
57 # TODO
58
59 ## number of output arguments
60 # TODO
61
62 ## type of arguments
63 # TODO
64
65 # TODO