What optimization do these kind of apps use?

  • foggy@lemmy.world
    link
    fedilink
    arrow-up
    21
    ·
    edit-2
    1 day ago

    First: for anyone curious who doesn’t know what we’re talking about here, this YouTube video is by far the best at explaining what P vs NP is. This problem will explain what NP-Hard is, and more.


    Traveling salesman doesn’t apply to Uber eats.

    Just because it’s routing doent mean it’s traveling salesman.

    Traveling salesman, and P vs NP is about the difficulty rapidly growing out of scope as the problem size increases.

    For delivery, there are exactly 2 nodes. Pickup, delivery. This problem is beyond solved, it’s childs play.

    Uber eats would fail to give you the best route to hit every taco bell in America the fastest. That’s traveling salesman. It’s traveling salesman because it’s be already out of scope to simply say “find me the best route to hit 1 McDonald’s in every Continental us state.” Even 48 nodes is insane.

    Edit: to answer what kind of algorithms these applications use? They’re really simple greedy heuristics. Not complex at all.

    For example, a greedy strategy for the travelling salesman problem (which is of high computational complexity) is the following heuristic: “At each step of the journey, visit the nearest unvisited city.” This heuristic does not intend to find the best solution, but it terminates in a reasonable number of steps.

    • Azzu@lemm.ee
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      1 day ago

      But isn’t “pick up multiple orders at a restaurant, then figuring out in which order to deliver them to minimize time spent delivering” the traveling salesman problem? I thought that’s what the post referred to.

      • foggy@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        19 hours ago

        That’s not really how Uber eats or similar apps work. Drivers are very rarely on more than 1 delivery at a time.

        And again, until our problem size grows to a point where we cannot solve it in polynomial time, it is in P by definition.

        Traveling salesman starts to evade computational time at around 20 to 30 nodes.

        So because of this, as I said before, it employs a greedy heuristic to make light work on decent guesses for the problem, knowing the problem size will never get out of scope, so doing so is relatively safe.

        You’re right that in theory multiple deliveries look like a tiny version of TSP, but in practice it’s nowhere near the scale that makes TSP an NP problem.

      • ℕ𝕖𝕞𝕠@slrpnk.net
        link
        fedilink
        arrow-up
        10
        ·
        1 day ago

        Finding the best route is NP-complete. Finding a route is trivial. Finding a pretty good route is good enough for their purposes.

        Also keep in mind they’re not to much trying up find the best route between static stops as trying to minimize time between pickup and dropoff for a list of (origin, destination) pairs, constrained by staggered start times for the pickup origins. It’s fundamentally a different problem.

  • solrize@lemmy.world
    link
    fedilink
    arrow-up
    22
    ·
    1 day ago

    Actual difficult instances of TSP are pretty rare, and for something like Uber Eats, it’s fine if your route is 2% worse than the mathematical optimum. Traffic fluctuations probably matter more than having the shortest route.

    There are many good heuristics for TSP that might not give you the optimal solution, but that will generally come pretty close. The Wikipedia article probably describes some of these.

  • Danitos@reddthat.com
    link
    fedilink
    arrow-up
    5
    ·
    1 day ago

    Algorithms that find approximate solutions to Traveling Businessman Problem are handful (some just use Markov Chains, a rather easy topic). Finding the exact solution is a hell lot harder.

    If your solution has an estimated error margin of 2% or less, it works just fine for basically any practical purpose.

  • ImplyingImplications@lemmy.ca
    link
    fedilink
    arrow-up
    6
    ·
    1 day ago

    NP just means the algorithm to find the solution takes longer to run than verifying a solution is correct. If verifying the solution is easy then shouldn’t there be a way to find the solution easily? That’s the P=NP problem. NP-Hard does not mean the problem is hard.