130 likes | 332 Views
CS 601 Final Project. Spencer White Kristine Perry. Objectives:. Experiment with a genetic algorithm to see if it can find a better solution than the random walk algorithm to the “Time flies like an arrow” generation problem.
E N D
CS 601 Final Project Spencer White Kristine Perry
Objectives: • Experiment with a genetic algorithm to see if it can find a better solution than the random walk algorithm to the “Time flies like an arrow” generation problem. • Cache the costs of already computed constraints to increase runtime performance
Cache Already Computed Costs: • Modified “build_nodefeat_query” because it provided numerical values to use in the hash function • Check to see if the desired query is already in the database. • If so, then look up the cost of the desired query in the hash table. • If not, create a character string representation of the query and call “my_grepper_count.” Store the result in the hash table and return. • Each constraint processing function now calls “build_nodefeat_query” instead of “my_grepper_count”
Results: • Time spent evaluating the cost of one sentence without caching: 44.3 seconds • Time spent running the rest of the iterations of the algorithm with caching: 12.2 seconds
Genetic Algorithms • Create a grammar • Generate an initial population of genotypes • Evaluate the fitness function on every new phenotype • Sort the population of genotypes by their merit • Create a certain number of children based on the fitness of the parents • Fill up the rest of the population from the previous generation selected based on their fitness. • Repeat from step 3 until a solution is found.
Hygiene Showers daily Showers weekly Takes a yearly bath (whether he needs it or not) Arrival Time Shows up early Shows up on time Shows up half an hour late Fails to show up at all because he was too busy working on a CS 470 project Behavior Brings flowers Opens doors Recites Shakespeare Laughs like Erkle Proposes on the first date Appearance Looks like Viggo Mortensen Looks like Orlando Bloom Looks like Gollum Charm Roguish smile of Harrison Ford Rasping breath of Darth Vader Quirky mannerisms of Yoda Conversation Talks about General Conference Talks about CS 470 Talks about his mission Discusses current politics Goes on for hours about his pet rock Doesn’t say anything the entire evening Dating Example
Dating Example Generate an initial population of genotypes: Parent: 1 3 1 2 2 5 Showers daily Shows up half an hour late Brings flowers Looks like Orlando Bloom Rasping breath of Darth Vader Goes on for hours about his pet rock Parent: 3 1 5 3 1 2 Takes a yearly bath Shows up early Proposes on the first day Looks like Gollum Roguish smile of Harrison Ford Talks about CS 470
Dating Example Evaluate the fitness function on every new phenotype Parent: 1 3 1 2 2 5 Showers daily Shows up half an hour late Brings flowers Looks like Orlando Bloom Rasping breath of Darth Vader Goes on for hours about his pet rock Parent: 3 1 5 3 1 2 Takes a yearly bath Shows up early Proposes on the first day Looks like Gollum Roguish smile of Harrison Ford Talks about CS 470 Child: 1 3 1 2 | 1 2 Showers daily Shows up half an hour late Brings flowers Looks like Orlando Bloom Roguish Smile of Harrison Ford Talks about CS 470 Consult the Database: Shall we keep this child?
Dating Example Evaluate the fitness function on every new phenotype Parent: 1 3 1 1 2 5 Showers daily Shows up half an hour late Brings flowers Looks like Orlando Bloom Rasping breath of Darth Vader Goes on for hours about his pet rock Parent: 3 1 5 3 1 2 Takes a yearly bath Shows up early Proposes on the first day Looks like Gollum Roguish smile of Harrison Ford Talks about CS 470 Child: 3 1 5 3 | 2 5 Takes a yearly bath Shows up early Proposes on the first date Looks like Gollum Rasping breath of Darth Vader Goes on for hours about his pet rock Consult the Database: Shall we keep this child?
Results of Random Walk Running with 10 tries 20 flips Output: “{time an} {flies .} like arrow" Run Time: 8 minutes 48.31 seconds
Results of Genetic Algorithm Output: “Like an arrow flies time” Run Time: 56.5 seconds
Questions? Time spent getting random walk lab to recompile: 1 hour 30 minutes Time spent porting code to C++: 1 hour Amount of memory used on Dr. Geary’s machine due to core dumps: 2 gigabytes Time spent coding up a hash table: 2 hours Time spent chatting with other TA’s while pretending to code this project in the TA cubicles: 3 hours Time spent modifying code to cache queries: 1 hour Time spent debugging segmentation faults: Does anyone really want to know? Time spent surfing the web for pictures for this presentation: 2 hours Number of hits google produces when searching the image database for “timeflies”: 429 Special thanks to David Hubbard for C to C++ translation expertise Number of zombie processes still running on Dr. Geary’s machine: Can anyone say “night of the living dead”? Number of logins to Dr. Geary’s machine for this project: approximately 30 Random facts from database queries