Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.GA.Mutation.General.SafeFitnessMutation Class Reference

List of all members.

Public Member Functions

def __init__
def mutate

Private Attributes

 _mutation
 _accept_less_percent
 _accept_less_rand

Detailed Description

Perform mutations, but do not allow decreases in organism fitness.

This doesn't actually do any mutation work, but just checks that
newly create organisms do not have lower fitnesses. 

Definition at line 9 of file General.py.


Constructor & Destructor Documentation

def Bio.GA.Mutation.General.SafeFitnessMutation.__init__ (   self,
  actual_mutation,
  accept_less = 0.0 
)
Initialize to do safe mutations

Arguments:

o actual_mutation - A Mutation class which actually implements
mutation. functionality.

o accept_less - A probability to accept mutations which
generate lower fitness. This allows you to accept some
crossovers which reduce fitness, but not all of them.

Definition at line 15 of file General.py.

00015 
00016     def __init__(self, actual_mutation, accept_less = 0.0):
00017         """Initialize to do safe mutations
00018 
00019         Arguments:
00020 
00021         o actual_mutation - A Mutation class which actually implements
00022         mutation. functionality.
00023 
00024         o accept_less - A probability to accept mutations which
00025         generate lower fitness. This allows you to accept some
00026         crossovers which reduce fitness, but not all of them.
00027         """
00028         self._mutation = actual_mutation
00029         self._accept_less_percent = accept_less
00030         self._accept_less_rand = random.Random()

Here is the caller graph for this function:


Member Function Documentation

Perform safe mutation of the specified organism.

Definition at line 31 of file General.py.

00031 
00032     def mutate(self, org):
00033         """Perform safe mutation of the specified organism.
00034         """
00035         new_org = self._mutation.mutate(org)
00036         new_org.recalculate_fitness()
00037 
00038         if org.fitness > new_org.fitness:
00039             accept_less_chance = self._accept_less_rand.random()
00040             if accept_less_chance <= self._accept_less_percent:
00041                 return new_org
00042             else:
00043                 return org
00044         else:
00045             return new_org

Member Data Documentation

Definition at line 28 of file General.py.

Definition at line 29 of file General.py.

Definition at line 27 of file General.py.


The documentation for this class was generated from the following file: