سؤال

I'm trying to make an application to calculate a daily route to visit my clients. I can solve whole way by using Genetic Algorithms so far. But I need to limit solution by distance. When I just "cut" the solution path at some point, it becomes a bad solution. Is there a special algorithm for this instance? I'm trying to find and fit one but no luck.

Someone used to do this can give me a recommendetion? I can use vb.NET, c#, php or JAVA.

Thanks.

هل كانت مفيدة؟

المحلول

If you're limiting the distance traveled, then I'm assuming that you're okay with not visiting ALL of your clients every day. If you need to visit ALL of your clients AND you have a maximum distance you want to travel, then all you can do is keep running your TSP algorithm until it (hopefully) produces a solution you're happy with.

If you only want to visit clients within a certain distance of the starting point, then determine the Euclidean distance of each point from the starting point, and filter out those that are too far away. Then run your TSP algorithm on the remaining points.

I'm assuming you instead want to be able to visit as many clients as possible by traveling a maximum distance d. I recommend using a Hill-climbing approach. Start with a valid solution (e.g. just use a greedy approach of taking the next closest unvisited client and stop when the total distance is d), and then randomly modify n nodes in the solution (this could mean reordering them, or this could mean swapping a node for one that isn't currently in the solution; use a sensible heuristic here, you don't want to swap a node for a node that's on the other side of the map, one possible approach is to use a weighted algorithm that favors swaps with closer nodes over more distant nodes) and test to see if the new solution is valid + better than the previous solution. You can always force the new solution to be valid by stripping off the last few clients from the trip.

نصائح أخرى

Maybe you can adjust the TSP or VRP example in OptaPlanner (open source, java) to do your bidding? There's a video that shows how to customize/tailor the constraints to your specific case.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top