Hi all, I am actually working on one C++ program to solve a travelling salesman problem.
Here's the brief introduction on what the program intends to achieve.
1. The program reads a text file, stores the variable and computes the distance.
2. The program starts from a point, known as Depot, and ends in Depot as well.
3. There are 2 types of points/city in the text file, point and parcel, where the program should always visit point first before visiting parcel.
4. If there are more points than parcel, you don't need to visit all of the points.
5. The program should keep track of what point it visited, so that you can generate a text file of points u visited.
6. Brute force is allowed.
The text file for reading contains information like this:
1 2 3 4 5 6
|
Depot 265 143
Parcel1 253 278
Point2 439 148
Parcel3 458 304
Point4 609 230
Parcel5 597 101
|
What I know:
I know that we need to use Pythagoras theorem to solve the distance, that is not an issue, as it is relatively easy to solve.
I also know that we should store the points visited into a temp array before storing and printing it.
We should also have a mechanism that validate the type of points before visiting it.
My Issue:
But I am having trouble trying to save the information from the text file for interpretation. I know that we cannot store string and int values in an array, and it seems the same for matrix as well.
I am also unsure of how to create a validation for point visiting, do I use Boolean value?