In Part 1 of this multi-part coding challenge, I introduce the classic computer science problem of the Traveling Salesperson (TSP) and discuss the pitfalls with a brute force solution. In Part 2, I discuss Lexicographic Ordering and demonstrate one algorithm to iterate over all the permutations of an array. In Part 3, I apply this algorithm to a brute-force solution of the TSP problem. Every single route permutation is checked one by one. In Part 4, I attempt to create a solution to the TSP problem with a genetic algorithm, and then I add a “crossover” algorithm in Part 5. Code: thecodingtrain.com/challenges...
p5.js Web Editor Sketches:
🕹️ Part 1: Traveling Salesperson (TSP): editor.p5js.org/codingtrain/s...
🕹️ Part 2: Lexicographic Order: editor.p5js.org/codingtrain/s...
🕹️ Part 3: TSP with Lexicographic Order: editor.p5js.org/codingtrain/s...
🕹️ Part 4: TSP with Genetic Algorithm: editor.p5js.org/codingtrain/s...
🕹️ Part 5: TSP with Genetic Algorithm and Crossover: editor.p5js.org/codingtrain/s...
Other Parts of this Challenge:
📺 Part 1: Traveling Salesperson (TSP): • Coding Challenge #35.1...
📺 Part 2: Lexicographic Order: • Coding Challenge #35.2...
📺 Part 4: TSP with Genetic Algorithm: • Coding Challenge #35.4...
📺 Part 5: TSP with Genetic Algorithm and Crossover: • Coding Challenge #35.5...
🎥 Previous video: • Coding Challenge #34: ...
🎥 Next video: • Coding Challenge #36: ...
🎥 All videos: • Coding Challenges
References:
🌐 Traveling Salesman on Wikipedia: en.wikipedia.org/wiki/Travell...
🗨️ Permutation Algorithm Using Lexicographic Ordering: www.quora.com/How-would-you-e...
📝 Array on MDN: developer.mozilla.org/en/docs...
📝 Array.includes() on MDN: developer.mozilla.org/en/docs...
📝 Array.reverse() on MDN: developer.mozilla.org/en/docs...
📝 ES6 Sets on MDN: developer.mozilla.org/en/docs...
💾 The Nature of Code Part 2: github.com/shiffman/NOC-S17-2...
📕 The Nature of Code: natureofcode.com/
Videos:
🎥 Improved Pool Selection: • 9.8: Genetic Algorithm...
🎥 Genetic Algorithm Playlist: • 9: Genetic Algorithms ...
🔴 Live Stream Archive #57: • Live Stream #57 - Trav...
Related Coding Challenges:
🚂 #29 Smart Rockets in p5.js: • Coding Challenge #29: ...
🚂 #51 A* Pathfinding Algorithm: • A* Pathfinding Algorit...
🚂 #69 Evolutionary Steering Behaviors: • Coding Challenge #69: ...
🚂 #70 Nearest Neighbors Recommendation Engine: • Coding Challenge #70: ...
Timestamps:
00:00 Introducing Part 3
01:26 Code! Bringing code from the lexical order challenge
03:19 Drawing the numeric order below the path
04:30 Generating the next order each time through draw()
05:07 Using the generated lexical order
08:24 Copying the best order ever
10:48 Drawing the best order ever
13:04 Drawing the current and best permutation separately
15:22 Displaying the progress
18:15 Trying different numbers of cities
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/guides/pas...
🚩 Suggest Topics: github.com/CodingTrain/Sugges...
💡 GitHub: github.com/CodingTrain
💬 Discord: / discord
💖 Membership: kzitem.infojoin
🛒 Store: standard.tv/codingtrain
🖋️ Twitter: / thecodingtrain
📸 Instagram: / the.coding.train
🎥 Coding Challenges: • Coding Challenges
🎥 Intro to Programming: • Start learning here!
🔗 p5.js: p5js.org
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
#travelingsalesperson #permutation #lexicographicordering #natureofcode #geneticalgorithm #evolution #bruteforce #factorial #arrays #p5js
Негізгі бет Coding Challenge #35.3: Traveling Salesperson with Lexicographic Order
Пікірлер: 75