úÎUÊSÇ     'Universe of entities. ,Scored generation (population and archive). A possibly scored entity. =Type class for entities that represent a candidate solution. Five parameters: + data structure representing an entity (e)  score type (s), e.g. Double : data used to score an entity, e.g. a list of numbers (d) 6 some kind of pool used to generate random entities,  e.g. a Hoogle database (p)  monad to operate in (m) AMinimal implementation includes genRandom, crossover, mutation,  and either score', score or scorePop. #Generate a random entity. [required] $pool for generating random entities  random seed random entity ECrossover operator: combine two entities into a new entity. [required]  entity pool crossover parameter  random seed  first entity second entity  entity resulting from crossover @Mutation operator: mutate an entity into a new entity. [required]  entity pool mutation parameter  random seed entity to mutate mutated entity :Score an entity (lower is better), pure version. [optional] 1Overridden if score or scorePop are implemented. dataset for scoring entities entity to score  entity score =Score an entity (lower is better), monadic version. [optional] #Default implementation hoists score' into monad, ' overriden if scorePop is implemented. dataset for scoring entities entity to score  entity score 0Score an entire population of entites. [optional] )Default implementation returns Nothing, $ and triggers indivual of entities. dataset to score entities universe of known entities  population of entities to score scores for population entities @Determines whether a score indicates a perfect entity. [optional] -Default implementation returns always False. scored entity (whether or not scored entity is perfect %Configuration for genetic algorithm. population size 'size of archive (best entities so far) (maximum number of generations to evolve ;fraction of entities generated by crossover (tip: >= 0.80) 1fraction of entities generated by mutation (tip: <= 0.20) Aparameter for crossover (semantics depend on crossover operator) ?parameter for mutation (semantics depend on mutation operator) enable/)disable built-in checkpointing mechanism $rescore archive in each generation? (Currify a list of elements into tuples. list list of tuples 3Take and drop elements of a list in a single pass. number of elements to take/drop list ,result: taken list element and rest of list )Initialize: generate initial population. $pool for generating random entities population size  random seed initialized population &Binary tournament selection operator. set of entities  random seed selected entity 'Apply crossover to obtain new entites. crossover parameter number of entities  random seed pool for combining entities  entities &Apply mutation to obtain new entites. mutation parameter number of entities  random seed pool for mutating entities  entities Score a list of entities. dataset for scoring entities universe of known entities set of entities to score -Function to perform a single evolution step: & score all entities in the population - combine with best entities so far (archive)  sort by fitness & create new population using crossover/ mutation - retain best scoring entities in the archive pool for crossover/ mutation dataset for scoring entities # of cm a entities c/ m parameters rescore archive in each step? known entities current generation seed for next generation "renewed universe, next generation !-Evolution: evaluate generation and continue. configuration for GA known entities current generation #function that evolves a generation gen indicies and seeds evolved generation "#Generate file name for checkpoint. 'configuration for generation algorithm !generation index and random seed path of checkpoint file # Checkpoint a single generation. configuraton for GA generation index random seed for generation current generation writes to file $>Evolution: evaluate generation, (maybe) checkpoint, continue. configuration for GA universe of known entities current generation #function that evolves a generation gen indicies and seeds evolved generation % Initialize. random generator configuration for GA $pool for generating random entities initialization result Do the evolution! random generator configuration for GA random entities pool #dataset required to score entities best entities & Try to restore from checkpoint. CFirst checkpoint for which a checkpoint file is found is restored. configuration for GA  gen indices/seeds restored generation (if any) ,Do the evolution (supports checkpointing). +Requires support for liftIO in monad used. random generator configuration for GA random entities pool #dataset required to score entities best entities Random search. 7Useful to compare with results from genetic algorithm. random generator number of random entities random entity pool scoring dataset  best ents     '       !"#$%&'(GA-0.2GAEntity genRandom crossovermutationscore'scorescorePop isPerfectGAConfig getPopSizegetArchiveSizegetMaxGenerationsgetCrossoverRategetMutationRategetCrossoverParamgetMutationParamgetWithCheckpointinggetRescoreArchiveevolve evolveVerbose randomSearchUniverse Generation ScoredEntitycurrify takeAndDropinitPoptournamentSelectionperformCrossoverperformMutationscoreAll evolutionStep evolution chkptFileName checkpointGenevolutionChkptinitGArestoreFromChkpt