Module selection
[hide private]
[frames] | no frames]

Module selection

source code

selection

Contains methods to select individuals from a population. So far fittest selection and tournament selection are supported.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Author: by Mehdi Khoury

Version: 1.20

Copyright: (c) 2009 Mehdi Khoury under the mit license http://www.opensource.org/licenses/mit-license.html

Contact: mehdi.khoury at gmail.com

Functions [hide private]
 
GetDBKeysAndFitness(dbname, tablename)
the list of fitnesses with associated unique ids obtained from the database.
source code
 
SelectFileFittest(pop_file)
Select the fittest individual from a file
source code
 
SelectDBOneFittest(db_list)
Select fittest individual
source code
 
SelectDBSeveralFittest(n, db_list)
Select n fittest individual
source code
 
TournamentSelectFileOne(size, pop_file, prob_selection_fittest)
Select one individual from a file using Tournament selection appropriate and fast when using a small population (<=1000)
source code
 
TournamentSelectDBOne(size, prob_selection, db_list)
Select one individual from a database using Tournament selection
source code
 
TournamentSelectDBSeveral(nb_outputs, size, prob_selection, db_list)
Select one individual from a database using Tournament selection
source code
Variables [hide private]
  __package__ = None
Function Details [hide private]

GetDBKeysAndFitness(dbname, tablename)

source code 

Function: GetDBKeysAndFitness

the list of fitnesses with associated unique ids obtained from the database. A lengthy operation. Should be only called once and used as an argument for the tournament or fitness selection functions.

Parameters:
  • dbname - path to database e.g. r'D:d_work\pythongp\pySTGP_0.51\src\pop_db'
  • tablename - name of the databse table

    returns: the list of fitnesses with associated unique ids obtained from the database

SelectFileFittest(pop_file)

source code 

Function: SelectFileFittest

Select the fittest individual from a file

Parameters:
  • pop_file - population file

    returns: the reference of one selected individual with

SelectDBOneFittest(db_list)

source code 

Function: SelectDBOneFittest

Select fittest individual

Parameters:
  • db_list - the ordered list of fitnesses with associated unique ids obtained from the database

    returns: the reference of the one fittest individual

SelectDBSeveralFittest(n, db_list)

source code 

Function: SelectDBSeveralFittest

Select n fittest individual

Parameters:
  • n - the number of fittest individuals
  • db_list - the ordered list of fitnesses with associated unique ids obtained from the database
Returns:
the reference of the one fittest individual

TournamentSelectFileOne(size, pop_file, prob_selection_fittest)

source code 

Function: SelectFileOne

Select one individual from a file using Tournament selection appropriate and fast when using a small population (<=1000)

Parameters:
  • size - number of individual choosen at random from the population
  • pop_file - population file
  • prob_selection_fittest - prob of selecting the fittest of the group
Returns:
the reference of one selected individual with prob of choosing fittest=p prob of choosing second fittest= p*(1-p) prob of choosing third fittest= p*((1-p)^2)...

TournamentSelectDBOne(size, prob_selection, db_list)

source code 

Function: SelectDBOne

Select one individual from a database using Tournament selection

Parameters:
  • size - number of individual choosen at random from the population
  • prob_selection - prob of selecting the fittest of the group
  • db_list - the list of fitnesses with associated unique ids obtained from the database
Returns:
the reference of one selected individual with prob of choosing fittest=p prob of choosing second fittest= p*(1-p) prob of choosing third fittest= p*((1-p)^2)...

TournamentSelectDBSeveral(nb_outputs, size, prob_selection, db_list)

source code 

Function: SelectDBSeveral

Select one individual from a database using Tournament selection

Parameters:
  • nb_outputs - repeat the tournament selection nb_outputs times, to return a list nb_outputs selected individuals
  • size - number of individual choosen at random from the population
  • prob_selection - prob of selecting the fittest of the group
  • db_list - the list of fitnesses with associated unique ids obtained from the database
Returns:
return a list nb_outputs of references of individuals selected by tournament