{
  "id": 200531,
  "title": "2nd place solution write-up,Team \"Under a penny\", ebouteillon part 🔥",
  "url": "/competitions/conways-reverse-game-of-life-2020/writeups/under-a-penny-2nd-place-solution-write-up-team-und",
  "author_name": "",
  "post_date": "2020-12-01T06:57:35.373Z",
  "votes": 10,
  "comment_count": 3,
  "views": 0,
  "content": "<p>First, I would like to thank my teammates <a href=\"https://www.kaggle.com/knstqq\" target=\"_blank\">@knstqq</a> , <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> , <a href=\"https://www.kaggle.com/robertjohncannell\" target=\"_blank\">@robertjohncannell</a> (alphabetical order) for their ideas and work. It was really amazing to work with you guys!</p>\n<p>During this competition, I tried a lot of different approaches. Here are those giving best results:</p>\n<h1>Genetic algorithm using pytorch 🔥</h1>\n<p>I looked up existing Kaggle notebooks using Genetic Algorithm, but none of them were using a GPU accelerator (sorry if I am wrong and missed one). So I implemented one.</p>\n<p>Implementing this genetic algorithm from scratch using pytorch was hard but I learned a lot in the process about genetic algorithm (first purpose), but also on pytorch and how to optimize using NVIDIA Nsight.</p>\n<p>This solution performed very well during this competition as the below notebook alone scores in the top-10 leaderboard. This new approach helped improving final solution of our team \"Under a Penny\".</p>\n<p>Notebook with GA on GPU : <a href=\"https://www.kaggle.com/ebouteillon/top-10-with-first-genetic-algorithm-on-gpu\" target=\"_blank\">Top 10 with First Genetic Algorithm on GPU! 🔥</a> (version 1 runs 9 hours and scores 0.0450)</p>\n<h1>Kissat SAT solver for perfect solution</h1>\n<p>Kaggle's Conway's Reverse Game of Life 2020 can be viewed as a boolean satisfiability problem. I used the kissat SAT solver, which won first place in the main track of the SAT Competition 2020 and first place on unsatisfiable instances.</p>\n<p>The tricky part might be to turn the problem into an efficient CNF form, but it was pretty easy in fact using sympy.</p>\n<p>Following notebook solves 9532 puzzles (delta=1) in 25 minutes: <a href=\"https://www.kaggle.com/ebouteillon/perfect-solve-of-puzzles-using-a-sat-solver\" target=\"_blank\">Perfect Solve of Puzzles using a SAT solver</a></p>\n<p>The drawback of this approach is, it may takes a loooong time for solving some puzzle and bigger the delta, the harder.</p>\n<h1>Google OR-tools constraints solver</h1>\n<p>It is also possible to express the problem as a constraints problem. You will find an iterative approach using OR-tool in section \"Notebooks Prize attempt\"  below.</p>\n<p>The iterative approach consists in solving the puzzle with delta = 1, then solve again this solution with delta=1 until we did it delta times. It is much faster than solving the problem end-to-end, but it does not always find a solution.</p>\n<h1>Notebooks Prize attempt</h1>\n<p>In this competition there is a \"Notebooks Prize\":</p>\n<blockquote>\n  <p>Highest scoring Kaggle Notebook (as determined by Leaderboard submission score). To be eligible for this prize, the Notebook must do the entirety of its computation within the Notebook.</p>\n</blockquote>\n<p>My solution for this was to use the genetic algorithm running on 1-GPU + 1-CPU (pytorch uses a CPU at 100% even if all the work is on GPU) and an iterative solution using OR-tool on 1-CPU.<br>\nThe drawback of this approach is: we only have 2 hours and 2 CPU for a GPU notebook versus 9 hours and 4 CPU for CPU notebooks.</p>\n<p>2 hours score: : 0.05353 <a href=\"https://www.kaggle.com/ebouteillon/ga-on-gpu-or-tools-on-cpu2\" target=\"_blank\">GA on GPU + OR-tools on CPU2</a><br>\n9 hours score: : 0.0433 (cannot submit due to code limit)</p>\n<h1>Solution ensembling</h1>\n<p>Ensembling of solutions was pretty easy. We compute the score for each solution found for a puzzle and then we take the solution scoring the lowest.</p>\n<h1>Team-up</h1>\n<p>Teaming with <a href=\"https://www.kaggle.com/knstqq\" target=\"_blank\">@knstqq</a> , <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> , <a href=\"https://www.kaggle.com/robertjohncannell\" target=\"_blank\">@robertjohncannell</a> was a great experience, all keeping the motivation in the team and their solutions to this problem are really amazing. In the end, merging together really is the secret ingredient to get to this position.</p>\n<h1>Final notes</h1>\n<p>Team name comes when the team was only <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> and I .We had the objective to get under the score .01 what we called \"a penny\".</p>\n<p>Thanks for reading. 😄</p>\n<p>My teammates write-ups:</p>\n<ul>\n<li><a href=\"https://www.kaggle.com/c/conways-reverse-game-of-life-2020/discussion/200539\" target=\"_blank\">write-up of </a><a href=\"https://www.kaggle.com/knstqq\" target=\"_blank\">@knstqq</a></li>\n<li>write-up of <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> : TBD</li>\n<li>write-up of <a href=\"https://www.kaggle.com/robertjohncannell\" target=\"_blank\">@robertjohncannell</a> : TBD</li>\n</ul>",
  "messages": [
    {
      "id": "1097084",
      "postDate": "12/01/2020 00:24:26",
      "content": "<p>First, I would like to thank my teammates <a href=\"https://www.kaggle.com/knstqq\" target=\"_blank\">@knstqq</a> , <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> , <a href=\"https://www.kaggle.com/robertjohncannell\" target=\"_blank\">@robertjohncannell</a> (alphabetical order) for their ideas and work. It was really amazing to work with you guys!</p>\n<p>During this competition, I tried a lot of different approaches. Here are those giving best results:</p>\n<h1>Genetic algorithm using pytorch 🔥</h1>\n<p>I looked up existing Kaggle notebooks using Genetic Algorithm, but none of them were using a GPU accelerator (sorry if I am wrong and missed one). So I implemented one.</p>\n<p>Implementing this genetic algorithm from scratch using pytorch was hard but I learned a lot in the process about genetic algorithm (first purpose), but also on pytorch and how to optimize using NVIDIA Nsight.</p>\n<p>This solution performed very well during this competition as the below notebook alone scores in the top-10 leaderboard. This new approach helped improving final solution of our team \"Under a Penny\".</p>\n<p>Notebook with GA on GPU : <a href=\"https://www.kaggle.com/ebouteillon/top-10-with-first-genetic-algorithm-on-gpu\" target=\"_blank\">Top 10 with First Genetic Algorithm on GPU! 🔥</a> (version 1 runs 9 hours and scores 0.0450)</p>\n<h1>Kissat SAT solver for perfect solution</h1>\n<p>Kaggle's Conway's Reverse Game of Life 2020 can be viewed as a boolean satisfiability problem. I used the kissat SAT solver, which won first place in the main track of the SAT Competition 2020 and first place on unsatisfiable instances.</p>\n<p>The tricky part might be to turn the problem into an efficient CNF form, but it was pretty easy in fact using sympy.</p>\n<p>Following notebook solves 9532 puzzles (delta=1) in 25 minutes: <a href=\"https://www.kaggle.com/ebouteillon/perfect-solve-of-puzzles-using-a-sat-solver\" target=\"_blank\">Perfect Solve of Puzzles using a SAT solver</a></p>\n<p>The drawback of this approach is, it may takes a loooong time for solving some puzzle and bigger the delta, the harder.</p>\n<h1>Google OR-tools constraints solver</h1>\n<p>It is also possible to express the problem as a constraints problem. You will find an iterative approach using OR-tool in section \"Notebooks Prize attempt\"  below.</p>\n<p>The iterative approach consists in solving the puzzle with delta = 1, then solve again this solution with delta=1 until we did it delta times. It is much faster than solving the problem end-to-end, but it does not always find a solution.</p>\n<h1>Notebooks Prize attempt</h1>\n<p>In this competition there is a \"Notebooks Prize\":</p>\n<blockquote>\n  <p>Highest scoring Kaggle Notebook (as determined by Leaderboard submission score). To be eligible for this prize, the Notebook must do the entirety of its computation within the Notebook.</p>\n</blockquote>\n<p>My solution for this was to use the genetic algorithm running on 1-GPU + 1-CPU (pytorch uses a CPU at 100% even if all the work is on GPU) and an iterative solution using OR-tool on 1-CPU.<br>\nThe drawback of this approach is: we only have 2 hours and 2 CPU for a GPU notebook versus 9 hours and 4 CPU for CPU notebooks.</p>\n<p>2 hours score: : 0.05353 <a href=\"https://www.kaggle.com/ebouteillon/ga-on-gpu-or-tools-on-cpu2\" target=\"_blank\">GA on GPU + OR-tools on CPU2</a><br>\n9 hours score: : 0.0433 (cannot submit due to code limit)</p>\n<h1>Solution ensembling</h1>\n<p>Ensembling of solutions was pretty easy. We compute the score for each solution found for a puzzle and then we take the solution scoring the lowest.</p>\n<h1>Team-up</h1>\n<p>Teaming with <a href=\"https://www.kaggle.com/knstqq\" target=\"_blank\">@knstqq</a> , <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> , <a href=\"https://www.kaggle.com/robertjohncannell\" target=\"_blank\">@robertjohncannell</a> was a great experience, all keeping the motivation in the team and their solutions to this problem are really amazing. In the end, merging together really is the secret ingredient to get to this position.</p>\n<h1>Final notes</h1>\n<p>Team name comes when the team was only <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> and I .We had the objective to get under the score .01 what we called \"a penny\".</p>\n<p>Thanks for reading. 😄</p>\n<p>My teammates write-ups:</p>\n<ul>\n<li><a href=\"https://www.kaggle.com/c/conways-reverse-game-of-life-2020/discussion/200539\" target=\"_blank\">write-up of </a><a href=\"https://www.kaggle.com/knstqq\" target=\"_blank\">@knstqq</a></li>\n<li>write-up of <a href=\"https://www.kaggle.com/maximim\" target=\"_blank\">@maximim</a> : TBD</li>\n<li>write-up of <a href=\"https://www.kaggle.com/robertjohncannell\" target=\"_blank\">@robertjohncannell</a> : TBD</li>\n</ul>",
      "rawMarkdown": "First, I would like to thank my teammates @knstqq , @maximim , @robertjohncannell (alphabetical order) for their ideas and work. It was really amazing to work with you guys!\n\n\nDuring this competition, I tried a lot of different approaches. Here are those giving best results:\n\n\n# Genetic algorithm using pytorch 🔥\n\nI looked up existing Kaggle notebooks using Genetic Algorithm, but none of them were using a GPU accelerator (sorry if I am wrong and missed one). So I implemented one.\n\nImplementing this genetic algorithm from scratch using pytorch was hard but I learned a lot in the process about genetic algorithm (first purpose), but also on pytorch and how to optimize using NVIDIA Nsight.\n\nThis solution performed very well during this competition as the below notebook alone scores in the top-10 leaderboard. This new approach helped improving final solution of our team \"Under a Penny\".\n\nNotebook with GA on GPU : [Top 10 with First Genetic Algorithm on GPU! 🔥](https://www.kaggle.com/ebouteillon/top-10-with-first-genetic-algorithm-on-gpu) (version 1 runs 9 hours and scores 0.0450)\n\n\n# Kissat SAT solver for perfect solution\n\nKaggle's Conway's Reverse Game of Life 2020 can be viewed as a boolean satisfiability problem. I used the kissat SAT solver, which won first place in the main track of the SAT Competition 2020 and first place on unsatisfiable instances.\n\nThe tricky part might be to turn the problem into an efficient CNF form, but it was pretty easy in fact using sympy.\n\nFollowing notebook solves 9532 puzzles (delta=1) in 25 minutes: [Perfect Solve of Puzzles using a SAT solver](https://www.kaggle.com/ebouteillon/perfect-solve-of-puzzles-using-a-sat-solver)\n\nThe drawback of this approach is, it may takes a loooong time for solving some puzzle and bigger the delta, the harder.\n\n\n# Google OR-tools constraints solver\n\nIt is also possible to express the problem as a constraints problem. You will find an iterative approach using OR-tool in section \"Notebooks Prize attempt\"  below.\n\nThe iterative approach consists in solving the puzzle with delta = 1, then solve again this solution with delta=1 until we did it delta times. It is much faster than solving the problem end-to-end, but it does not always find a solution.\n\n\n# Notebooks Prize attempt\n\nIn this competition there is a \"Notebooks Prize\":\n\n> Highest scoring Kaggle Notebook (as determined by Leaderboard submission score). To be eligible for this prize, the Notebook must do the entirety of its computation within the Notebook.\n\nMy solution for this was to use the genetic algorithm running on 1-GPU + 1-CPU (pytorch uses a CPU at 100% even if all the work is on GPU) and an iterative solution using OR-tool on 1-CPU.\nThe drawback of this approach is: we only have 2 hours and 2 CPU for a GPU notebook versus 9 hours and 4 CPU for CPU notebooks.\n\n2 hours score: : 0.05353 [GA on GPU + OR-tools on CPU2](https://www.kaggle.com/ebouteillon/ga-on-gpu-or-tools-on-cpu2)\n9 hours score: : 0.0433 (cannot submit due to code limit)\n\n\n# Solution ensembling\n\nEnsembling of solutions was pretty easy. We compute the score for each solution found for a puzzle and then we take the solution scoring the lowest.\n\n\n\n# Team-up\n\nTeaming with @knstqq , @maximim , @robertjohncannell was a great experience, all keeping the motivation in the team and their solutions to this problem are really amazing. In the end, merging together really is the secret ingredient to get to this position.\n\n\n# Final notes\n\nTeam name comes when the team was only @maximim and I .We had the objective to get under the score .01 what we called \"a penny\".\n\nThanks for reading. 😄\n\nMy teammates write-ups:\n - [write-up of @knstqq](https://www.kaggle.com/c/conways-reverse-game-of-life-2020/discussion/200539)\n - write-up of @maximim : TBD\n - write-up of @robertjohncannell : TBD",
      "votes": null
    },
    {
      "id": "1097606",
      "postDate": "12/01/2020 06:00:53",
      "content": "<blockquote>\n  <p>9 hours score: : 0.433 (cannot submit due to code limit)<br>\n  0.0433 may be?</p>\n</blockquote>",
      "rawMarkdown": ">  9 hours score: : 0.433 (cannot submit due to code limit)\n0.0433 may be?",
      "votes": null
    },
    {
      "id": "1097652",
      "postDate": "12/01/2020 06:57:57",
      "content": "<p>Thanks. Fixed.</p>",
      "rawMarkdown": "Thanks. Fixed.",
      "votes": null
    },
    {
      "id": "1116181",
      "postDate": "12/16/2020 23:45:50",
      "content": "<p>Hi,<br>\nYou can have a look to my blog post in \"Towards Data Science\" where I explain the Genetic Algorithm solution:<br>\n<a href=\"https://towardsdatascience.com/reverse-arrow-of-time-with-genetic-algorithm-and-gpu-1871a7b4fff8\" target=\"_blank\">https://towardsdatascience.com/reverse-arrow-of-time-with-genetic-algorithm-and-gpu-1871a7b4fff8</a></p>",
      "rawMarkdown": "Hi,\nYou can have a look to my blog post in \"Towards Data Science\" where I explain the Genetic Algorithm solution:\nhttps://towardsdatascience.com/reverse-arrow-of-time-with-genetic-algorithm-and-gpu-1871a7b4fff8",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1097606,
      "author_name": "knstqq",
      "author_url": "",
      "post_date": "12/01/2020 06:00:53",
      "content": "<blockquote>\n  <p>9 hours score: : 0.433 (cannot submit due to code limit)<br>\n  0.0433 may be?</p>\n</blockquote>",
      "votes": null,
      "replies": [
        {
          "id": 1097652,
          "author_name": "ebouteillon",
          "author_url": "",
          "post_date": "12/01/2020 06:57:57",
          "content": "<p>Thanks. Fixed.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1116181,
      "author_name": "ebouteillon",
      "author_url": "",
      "post_date": "12/16/2020 23:45:50",
      "content": "<p>Hi,<br>\nYou can have a look to my blog post in \"Towards Data Science\" where I explain the Genetic Algorithm solution:<br>\n<a href=\"https://towardsdatascience.com/reverse-arrow-of-time-with-genetic-algorithm-and-gpu-1871a7b4fff8\" target=\"_blank\">https://towardsdatascience.com/reverse-arrow-of-time-with-genetic-algorithm-and-gpu-1871a7b4fff8</a></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1097084": "First, I would like to thank my teammates @knstqq , @maximim , @robertjohncannell (alphabetical order) for their ideas and work. It was really amazing to work with you guys!\n\n\nDuring this competition, I tried a lot of different approaches. Here are those giving best results:\n\n\n# Genetic algorithm using pytorch 🔥\n\nI looked up existing Kaggle notebooks using Genetic Algorithm, but none of them were using a GPU accelerator (sorry if I am wrong and missed one). So I implemented one.\n\nImplementing this genetic algorithm from scratch using pytorch was hard but I learned a lot in the process about genetic algorithm (first purpose), but also on pytorch and how to optimize using NVIDIA Nsight.\n\nThis solution performed very well during this competition as the below notebook alone scores in the top-10 leaderboard. This new approach helped improving final solution of our team \"Under a Penny\".\n\nNotebook with GA on GPU : [Top 10 with First Genetic Algorithm on GPU! 🔥](https://www.kaggle.com/ebouteillon/top-10-with-first-genetic-algorithm-on-gpu) (version 1 runs 9 hours and scores 0.0450)\n\n\n# Kissat SAT solver for perfect solution\n\nKaggle's Conway's Reverse Game of Life 2020 can be viewed as a boolean satisfiability problem. I used the kissat SAT solver, which won first place in the main track of the SAT Competition 2020 and first place on unsatisfiable instances.\n\nThe tricky part might be to turn the problem into an efficient CNF form, but it was pretty easy in fact using sympy.\n\nFollowing notebook solves 9532 puzzles (delta=1) in 25 minutes: [Perfect Solve of Puzzles using a SAT solver](https://www.kaggle.com/ebouteillon/perfect-solve-of-puzzles-using-a-sat-solver)\n\nThe drawback of this approach is, it may takes a loooong time for solving some puzzle and bigger the delta, the harder.\n\n\n# Google OR-tools constraints solver\n\nIt is also possible to express the problem as a constraints problem. You will find an iterative approach using OR-tool in section \"Notebooks Prize attempt\"  below.\n\nThe iterative approach consists in solving the puzzle with delta = 1, then solve again this solution with delta=1 until we did it delta times. It is much faster than solving the problem end-to-end, but it does not always find a solution.\n\n\n# Notebooks Prize attempt\n\nIn this competition there is a \"Notebooks Prize\":\n\n> Highest scoring Kaggle Notebook (as determined by Leaderboard submission score). To be eligible for this prize, the Notebook must do the entirety of its computation within the Notebook.\n\nMy solution for this was to use the genetic algorithm running on 1-GPU + 1-CPU (pytorch uses a CPU at 100% even if all the work is on GPU) and an iterative solution using OR-tool on 1-CPU.\nThe drawback of this approach is: we only have 2 hours and 2 CPU for a GPU notebook versus 9 hours and 4 CPU for CPU notebooks.\n\n2 hours score: : 0.05353 [GA on GPU + OR-tools on CPU2](https://www.kaggle.com/ebouteillon/ga-on-gpu-or-tools-on-cpu2)\n9 hours score: : 0.0433 (cannot submit due to code limit)\n\n\n# Solution ensembling\n\nEnsembling of solutions was pretty easy. We compute the score for each solution found for a puzzle and then we take the solution scoring the lowest.\n\n\n\n# Team-up\n\nTeaming with @knstqq , @maximim , @robertjohncannell was a great experience, all keeping the motivation in the team and their solutions to this problem are really amazing. In the end, merging together really is the secret ingredient to get to this position.\n\n\n# Final notes\n\nTeam name comes when the team was only @maximim and I .We had the objective to get under the score .01 what we called \"a penny\".\n\nThanks for reading. 😄\n\nMy teammates write-ups:\n - [write-up of @knstqq](https://www.kaggle.com/c/conways-reverse-game-of-life-2020/discussion/200539)\n - write-up of @maximim : TBD\n - write-up of @robertjohncannell : TBD",
    "1097606": ">  9 hours score: : 0.433 (cannot submit due to code limit)\n0.0433 may be?",
    "1097652": "Thanks. Fixed.",
    "1116181": "Hi,\nYou can have a look to my blog post in \"Towards Data Science\" where I explain the Genetic Algorithm solution:\nhttps://towardsdatascience.com/reverse-arrow-of-time-with-genetic-algorithm-and-gpu-1871a7b4fff8"
  },
  "source": "existing_discussion",
  "complete": true,
  "competition_id": 22122,
  "competition_slug": "conways-reverse-game-of-life-2020",
  "team_id": 5469906,
  "solution_url": "/competitions/conways-reverse-game-of-life-2020/writeups/under-a-penny-2nd-place-solution-write-up-team-und"
}