Genetic Programming - PretentiousPoet/pretentious-poet GitHub Wiki

Genetic Programming in Pretentious Poet

For Pretentious Poet, we designed our own genetic programming system from the ground up. This document serves as a full explanation for how our system is designed and implemented.

To see a general overview, see our Hack UMass 2016 slideshow.

Scoring Function

Our scoring function is used to score a generated poem. Programmatically understanding the semantics of arbitrary text is a challenge, and this is especially so in the case of poetry. As such, we had to create a hand crafted heuristic to quantify the quality of poetry.

Our function is based on several overarching ideas of what makes for a good poem. A good poem has high relevance to the given picture, and as such there must be a high density of words in the poem that are synonyms of the image classification tags. Additionally, a good poem is neither too long or too short, and as such we have a desired length and penalize the poems based on their distance from the desired length.

The final scoring function is as follows:

Scoring Function Equation

Poem Breeding

Central to the concept of genetic programming is the ability to breed objects together. In our case, our choice to represent our poems as a tree data structure allows for easy modification of large atomic units of our poem. For our implementation, we considered stanzas to be atomic units, and thus breeding consists of grafting large subtrees from one poem onto another.

Our particular implementation creates twenty pools of 128 poems each. Each pool has the highest value poem bred either asexually (the child is a direct mutation of the parent) or sexually (the child is a product of a combination of its parents tree structure).