Brute Force
Apply the brute force approach to solve TSP.
We'll cover the following...
Brute force in coding is a method of problem-solving that involves systematically trying every possible combination of inputs until the correct solution is found. It’s often used in cryptography and password cracking, where the goal is to guess a password or key by trying every possible combination of characters. We’ll use it to solve TSP. It’s not the most efficient solution, but it’s easy to understand and, therefore, a good start.
How many stores should we dare take? Let’s be cautious and start with five stores.
Distance matrix
For these stores, we create a distance matrix.
A distance matrix is a matrix where the value at row i and column j is the distance between node i and node j. This matrix contains the distances between all pairs of nodes. Please note that the direction is not important in this case, as the distance from StoreB (row 1) to StoreA (column 0) and vice versa from StoreA (row 0) to StoreB (column 1) is ...