Reputation: 23
I am working on a problem involving pathfinding in a weighted graph where I need to travel from a start node to an end node while considering a mix of necessary and optional waypoint nodes. The key aspects of the problem are that there exists necessary waypoints (nodes that must be visited on any valid path from the start to the end node) and optional waypoints. These optional waypoints are not strictly necessary in a valid path, but I would prefer to visit as many of them as possible. There is also a maximum cost constraint.
My goal is to find a valid path, if one exists, that satisfies the following criteria:
A
B
[W1, W2]
[O1, O2, O3]
C
Given this setup, I want to:
A -> ... -> B
that visits W1
and W2
within the cost C
.[O1, O2, O3]
that can be included without exceeding the cost C
.Any guidance on how to approach or optimize for these requirements would be highly appreciated!
Upvotes: 1
Views: 70
Reputation: 20596
You say you have solved the problem of including mandatory way points. Now you want to add optional waypoints. So move an optional waypoint from the optional to the mandatory list and solve. Repeat until you cannot find an optional waypoint that can be added without exceeding the cost constraint.
You comment: "I don’t see a way to find the specific 7 waypoints without checking all"
This called searching a solution space. If you want to guarantee that the absolute optimum will always be found, then you need to do an exhaustive search through the space. If you can accept an approximate solution that is often close to the perfect answer, but runs a lot faster, there are a lot of algorithms to choose from. For example, hill climbing ( AKA greedy ), simulated annealing, low rez then hi rez locally and quite a few more. That list should be enough to keep you googling for a while :-)
Upvotes: 0