$30 off During Our Annual Pro Sale. View Details »

Monkeys in the Machine

Monkeys in the Machine

Can a million monkeys given a million typewriters produce the collected works of Shakespeare? Considering the ethical concerns of forcing monkeys to write, paired with the sheer mess of that many mammals in one location, we might never know. Or will we?

Thanks to the wonders of modern computing, it's possible to _simulate_ monkeys emulating the Bard. Leveraging techniques like genetic algorithms, we can build a system that approximates a monkey armed with a typewriter. Digitally.

It's a fun exercise to prove a thought experiment, but also a powerful technical approach to leverage machine learning and rudimentary AI in various places. Together, we'll breed digital monkeys and show both how they can be used to answer the aforementioned Shakespearean question as well as produce generative results to more _practical_ problems.

Eric Mann

March 17, 2020
Tweet

More Decks by Eric Mann

Other Decks in Technology

Transcript

  1. 1
    Monkeys in the Machine
    Eric Mann

    View Slide

  2. 2
    Hello.
    Eric Mann
    Director of Engineering, Vacasa

    View Slide

  3. 3
    Concevons qu'on ait dressé un million de singes à frapper au hasard sur les
    touches d'une machine à écrire et que […] ces singes dactylographes travaillent
    avec ardeur dix heures par jour avec un million de machines à écrire de types
    variés. […] Au bout d'un an, [leurs] volumes se trouveraient renfermer la copie
    exacte des livres de toute nature et de toutes langues conservés dans les plus
    riches bibliothèques du monde.
    — Émile Borel

    View Slide

  4. 4
    Let us imagine that a million monkeys have been trained to strike at random on
    the keys of a typewriter and that […] these typing monkeys work hard ten hours
    a day with a million typewriters of various types. […] At the end of a year, [their]
    volumes would find themselves containing the exact copy of books of all kinds
    and all languages kept in the richest libraries in the world.
    — Émile Borel (via Google Translate)

    View Slide

  5. 5

    View Slide

  6. 6
    CREATE
    POPULATION
    EVALUATE
    FITNESS
    MUTATE REPRODUCE
    Randomly-initialized strings can eventually converge to meet a target string over
    several iterations of a random optimization algorithm over a large set of candidates.
    Evaluate how close each
    candidate is to the optimum
    Evaluate Fitness
    Initialize a collection of
    pseudrandom candidates
    Create Population
    Create a new candidate for
    the next generation
    Reproduce
    Mutate the new candidate so
    we can further optimize
    Mutate
    Genetic Algorithms

    View Slide

  7. 7
    Image by GeeksforGeeks

    View Slide

  8. 8
    PHP Demo

    View Slide

  9. 9
    Genetic Algorithms
    In Review
    1
    We created a collection of entirely random strings, all the same length as our target text.
    Initialize Population
    2
    We measured the distance of each string from the target text.
    Evaluate Fitness
    3
    We used our “high fitness” members to create a new, somewhat less random child generation
    Reproduce
    4
    We mutated some children to introduce randomness and prevent local maxima.
    Mutate

    View Slide

  10. 10
    The Traveling Salesman Problem
    Salesman must travel to all cities once before returning home.
    The distance between each city is given and is assumed to be the
    same in either direction.
    OBJECTIVE - Minimize the total distance traveled on the trip.

    View Slide

  11. 11
    Wikimedia Commons

    View Slide

  12. 12
    Genetic Algorithms
    Traveling Salesman
    1
    Create a “population” of randomly-ordered strings representing a route.
    Initialize Population
    2
    Measure the total distance traveled while traversing each route.
    Evaluate Fitness
    3
    We used our “high fitness” members to create a new, somewhat less random child generation
    Reproduce
    4
    Mutate by swapping the order of two cities in the route.
    Mutate

    View Slide

  13. 13
    PHP Demo

    View Slide

  14. 14
    Wikimedia Commons

    View Slide

  15. 15
    Ant Colony Optimization
    Traveling Salesman
    1
    Drop an “ant” at a random city.
    Random Starting Point
    2
    The ant visits each city in turn at random, weighted by the attractiveness of each destination.
    “Attractiveness”-based Route
    3
    An ant deposits pheromone on each edge it travels, with an amount inversely proportional to
    the total distance travelled in its route.
    Calculate Pheromone Trail
    4
    The total pheromone for the next iteration is part left over from the first and part added to by
    the ants - repeat all steps until we converge.
    Evaporate and Repeat

    View Slide

  16. 16
    PHP Demo

    View Slide

  17. 17
    Ant Colony Optimization
    Traveling Salesman
    Vehicle Routing
    Job Ordering
    “Knapsack Problem”
    Nanoelectronics Design
    Image Processing
    Antenna Optimization
    Network Routing
    Protein Folding

    View Slide

  18. 18
    Questions?

    View Slide

  19. 19
    Thank You!
    [email protected] | 503.925.6266

    View Slide