(self, genome, seed=None, interactiveMode=True)
Initializator of GSimpleGA
Initializator of GSimpleGA
Initializator of GSimpleGA
def __init__(self, genome, seed=None, interactiveMode=True):
        """ Initializator of GSimpleGA """
        if seed:
            random.seed(seed)

        if type(interactiveMode) != BooleanType:
            Util.raiseException("Interactive Mode option must be True or False", TypeError)

        if not isinstance(genome, GenomeBase):
            Util.raiseException("The genome must be a GenomeBase subclass", TypeError)

        self.internalPop = GPopulation(genome)
        self.nGenerations = Consts.CDefGAGenerations
        self.pMutation = Consts.CDefGAMutationRate
        self.pCrossover = Consts.CDefGACrossoverRate
        self.nElitismReplacement = Consts.CDefGAElitismReplacement
        self.setPopulationSize(Consts.CDefGAPopulationSize)
        self.minimax = Consts.minimaxType["maximize"]
        self.elitism = True

        # Adapters
        self.dbAdapter = None
        self.migrationAdapter = None

        self.time_init = None
        self.max_time = None
        self.interactiveMode = interactiveMode
        self.interactiveGen = -1
        self.GPMode = False

        self.selector = FunctionSlot("Selector")
        self.stepCallback = FunctionSlot("Generation Step Callback")
        self.terminationCriteria = FunctionSlot("Termination Criteria")
        self.selector.set(Consts.CDefGASelector)
        self.allSlots = (self.selector, self.stepCallback, self.terminationCriteria)

        self.internalParams = {}

        self.currentGeneration = 0

        # GP Testing
        for classes in Consts.CDefGPGenomes:
            if isinstance(self.internalPop.oneSelfGenome, classes):
                self.setGPMode(True)
                break

        logging.debug("A GA Engine was created, nGenerations=%d", self.nGenerations)
def __init__ ( self , genome , seed = None , interactiveMode = True ) : if seed : random . seed ( seed ) if type ( interactiveMode ) != BooleanType : Util . raiseException ( "Interactive Mode option must be True or False" , TypeError ) if not isinstance ( genome , GenomeBase ) : Util . raiseException ( "The genome must be a GenomeBase subclass" , TypeError ) self . internalPop = GPopulation ( genome ) self . nGenerations = Consts . CDefGAGenerations self . pMutation = Consts . CDefGAMutationRate self . pCrossover = Consts . CDefGACrossoverRate self . nElitismReplacement = Consts . CDefGAElitismReplacement self . setPopulationSize ( Consts . CDefGAPopulationSize ) self . minimax = Consts . minimaxType [ "maximize" ] self . elitism = True # Adapters self . dbAdapter = None self . migrationAdapter = None self . time_init = None self . max_time = None self . interactiveMode = interactiveMode self . interactiveGen = - 1 self . GPMode = False self . selector = FunctionSlot ( "Selector" ) self . stepCallback = FunctionSlot ( "Generation Step Callback" ) self . terminationCriteria = FunctionSlot ( "Termination Criteria" ) self . selector . set ( Consts . CDefGASelector ) self . allSlots = ( self . selector , self . stepCallback , self . terminationCriteria ) self . internalParams = { } self . currentGeneration = 0 # GP Testing for classes in Consts . CDefGPGenomes : if isinstance ( self . internalPop . oneSelfGenome , classes ) : self . setGPMode ( True ) break logging . debug ( "A GA Engine was created, nGenerations=%d" , self . nGenerations )