A* Search: How Your Map Applications Find Shortest Routes

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 117

  • @Masterhitman935
    @Masterhitman935 6 месяцев назад +144

    He is alive!!!

  • @benharris8382
    @benharris8382 6 месяцев назад +149

    babe wake up new reducible video just dropped

  • @СизоненкоДмитро
    @СизоненкоДмитро 6 месяцев назад +50

    Well done! Future generations of students will be grateful to you. When I was learning this algorithm there were no such well done, visually explained lessons!

  • @giacomotazzari2060
    @giacomotazzari2060 6 месяцев назад +23

    Great video! I studied A* a while ago, and this was really helpful to refresh my knowledge

  • @Magnasium038
    @Magnasium038 6 месяцев назад +9

    Nice! I had learnt how A* works earlier, but found the choice of adding the two costs random as I didn't understand the rationale. This presentation of A* as an intermediate between greedy and uniform cost search makes the rationale clear now!

  • @multiarray2320
    @multiarray2320 6 месяцев назад +9

    i legit thought you dont come back. great to see a video of you again :)

  • @spaanse
    @spaanse 6 месяцев назад +14

    Today's mapping applications go even further, using an idea called contraction hierarchies.
    An analogy for this:
    Suppose you need to find a route from New York to Los Angeles.
    As a human you do not look at individual streets first, but look at which states you are likely to pass through.
    Then for those states you look at which counties you are likely to pass through.
    And finally how you can cross those counties with roads.
    The implementation for this contains three parts: figuring out good boundaries, computing the distances for crossing these regions, and combining these into the a route.
    The first two can be precomputed, so only the final step needs to be calculated on the fly which can be done within milliseconds.

  • @Mabeeck
    @Mabeeck 6 месяцев назад +4

    Glad to see that the channel is still in use :)

  • @forever_stay6793
    @forever_stay6793 6 месяцев назад +2

    Wow what perfect timing! I'm doing a research project this summer that involves routing algorithms. I've only learned about Dijkstra's algorithm in class, so I was confused when I first started reading papers that mentioned A*. Thank you for the great explanation!

  • @de_michael1222
    @de_michael1222 6 месяцев назад +2

    He's back!! You're my favourite algorithmics channel, greetings from europe

  • @srivatsajoshi4028
    @srivatsajoshi4028 6 месяцев назад +4

    I'm so excited reducible is posting again

  • @xaceffulgent
    @xaceffulgent 6 месяцев назад +3

    Thank you so much! And Welcome back!

  • @cariyaputta
    @cariyaputta 6 месяцев назад +2

    My man is back. What a time to be alive.

  • @shauryatomer1058
    @shauryatomer1058 5 месяцев назад

    Damn dude, until now A* just seemed like magic to me. This video changes that magic to logical understanding. Thanks for dropping this gem best video on A* I have seen so far

  • @ai_outline
    @ai_outline 5 месяцев назад +1

    This channel is pure gold. Please never stop ❤️

  • @justaharmlesspotato885
    @justaharmlesspotato885 5 месяцев назад

    YEY you are back!!! So happy! Please never leave us again

  • @kripposoft
    @kripposoft 6 месяцев назад +1

    Please keep making videos! They're very well presented and interesting!

  • @Thorum0
    @Thorum0 6 месяцев назад +2

    Very good video, actually first time I actually understand how the a* heuristic works, thanks!

  • @purerandomness4208
    @purerandomness4208 6 месяцев назад +1

    The best A* Algorithm explanation I have ever seen.

  • @Gary_E_Anderson
    @Gary_E_Anderson 4 месяца назад

    You are masterful in your approach to breaking down complex topics which people can then use to springboard into now meaningful follow-on research. I would love to see you do a deep dive like this on video encoding, specifically macroblock encoding. Maybe start with h264/5, Mpeg-2, and/or AV1. : )

  • @pra.
    @pra. 6 месяцев назад

    That was simpler than I thought, also you have some of the best visualizations of algorithms out there

  • @niccoboa
    @niccoboa 6 месяцев назад +33

    It's 3am here, let's go straight to A*

    • @sirk3v
      @sirk3v 6 месяцев назад

      same time zone haha

  • @azxu3419
    @azxu3419 6 месяцев назад

    Reducible keep making great videos!! I miss you so much

  • @crockgaming5958
    @crockgaming5958 6 месяцев назад +9

    Ooh bro finally you got some free time i am very happy 😂

  • @badpriestess_
    @badpriestess_ 5 месяцев назад

    oh my god i have always wondered about this. im so ready for this video

  • @0000kk
    @0000kk 6 месяцев назад +1

    Needed this last semester

  • @Masterhitman935
    @Masterhitman935 6 месяцев назад

    Thank you for providing a very illuminating approach to measuring and optimization of cost of travel between nodes.

  • @katanagamer6963
    @katanagamer6963 2 месяца назад +1

    Wow..... Thank You for the video....... Really loved the way you explained the topic... :)

  • @ba8e
    @ba8e 6 месяцев назад +2

    This was awesome! Beautiful presentation.

  • @davidhicks8290
    @davidhicks8290 6 месяцев назад

    It ends right when I was getting excited! Explain a good heuristic, please!!!
    Glad to see you back!

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад +1

      The explanation I had gotten before was that you can get a heuristic by solving a relaxed version of a problem.
      For the example of driving a car between places in a city, the Euclidean distance works as a heuristic, it is a relaxed version of the problem in that it removes the constraint of having to travel along the roads.
      For the example of finding the exit in a square maze, the Manhattan distance works as a heuristic, it removes the constraint of the walls whilst still having you move along the grid.
      If you have a puzzle where you can only move one thing at a time, and the solved state has everything in a specific position, a simple heuristic would be the number of things that are out of place, a better heuristic would be the sum of the distances of every object's current location to goal location.

    • @davidhicks8290
      @davidhicks8290 6 месяцев назад

      Thank you for the comment!
      What about a mapping problem, but every node only has the distance between its connecting nodes. This would get rid of the Euclidean distance because there's no coordinates associated with the nodes. Do you know of a heuristic for that problem?

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад

      @@davidhicks8290 If all you are given is a graph, and you are tasked with doing a single search for a shortest path from one node to another node and do it as fast as possible once you're given the graph, I don't think there is any heuristic you can come up with that'll help.
      If you are given a graph, and you're told that you can do some precomputation in preparation to answer a query in the future, or you have to handle a batch of queries, then you can algorithmically analyze the graph somewhat and come up with some heuristic that could be useful overall.
      A (possibly dumb but maybe it could be useful) idea is that you can try embedding the graph into a 2D, 3D, actually any nD space, and apply forces on nodes to try to separate them as much as possible whilst always making sure their Euclidean distance is less than their actual distance between neighboring nodes. Based on this embedding, you use the Euclidean distance as the heuristic.
      Another idea I have is that you can try partitioning the graph into subgraphs. The partitioning could be done in any way, as long as every node in the original graph is part of some graph in the partition. From thereon, you can notice how the subgraphs connect to each other, look at the minimum distance from any subgraph to a different subgraph, and you'll declare that is the actual distance. So your subgraphs will end up connecting to each other with weights as a new kinda meta-graph. The heuristic now becomes the distance in this meta-graph, where you can't distinguish a node from the subgraph it belongs to. Partitioning your starting graph in different ways would lead to effectively better or worse heuristics, if you partition the graph into a small subgraphs the heuristic is likely to be more accurate but also more costly to compute, conversely bigger subgraphs would make for a less accurate but easier to compute heuristic. How cleverly you partition would also be a factor, probably putting nodes with high centrality in different subgraphs would likely help, making subgraphs where the nodes in them are not connected in the original graph probably wouldn't help.
      Anyways, all that being said, I don't know what is actually used in practice for A* on graphs where the only thing you know is distance between connecting nodes. Generally for A* you come up with the heuristic by learning/analyzing the problem domain, you generally want to find the shortest path from one node to another in a graph because you're trying to solve a problem, e.g. solve a puzzle, find the cheapest configuration for something, minimize latency, etc... If you know nothing about the graph you're given, I think the only way you can come up with a heuristic is by exploring the graph and then doing extra work. If you get a heuristic by analyzing the problem domain, you don't have to do such precomputation.

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад

      ​@@davidhicks8290 For some reason I don't see the reply I made to your comment here. I'm gonna be less thorough b/c I don't want to retype everything I did the first time.
      I don't know exactly you mean by "mapping problem". I'm assuming you just mean "shortest path".
      I don't know what heuristics if any are commonly applied to graphs where all you know is the distance between connecting nodes.
      If all you know about the graph you're given is the distances between adjacent nodes, I don't think there is a heuristic you can apply to get a free speedup, but maybe I'm wrong. I think that you need to have some additional knowledge. In general the heuristic function you use will depend on the problem domain. Usually we try to find the shortest path in a graph to solve some problem, like solving a puzzle, or minimizing the cost of something, or minimizing latency, or whatever. So by thinking about the problem that the graph comes from, we can try to think of a heuristic.
      However!
      If we are allowed to precompute a heuristic function in preparation for handling a future shortest path query, or a batch of them, or many for a long time all using the same graph... I think it is possible to algorithmically deduce a useful heuristic. But in the time it takes to run any of these following approaches to find a heuristic, you will definitely have been able to finish one shortest path query.
      The simplest option is to just compute the distances between all nodes to all other nodes. The table that you get as a result will be a 100% accurate heuristic, but expensive to precompute, and uses O(N^2) memory.
      One idea I have is that you can embed a graph in 2D, 3D or any higher dimensional space, and try to move the nodes as far apart as you can while respecting the distance constraint. Perhaps you can separate out the nodes with gradient descent or by doing something like a physics simulation where repulsive forces are applied to the nodes. Anyways, the Euclidean metric would be your heuristic in this case. This method may very well take too long practically to compute though.
      Last idea I have is that you can split up your starting graph into smaller subgraphs. Treat these subgraphs as a single node each, look at how they connect to each other, and assign distances based on that. You get another graph that is smaller than what you started with, and you can form a heuristic by doing yet another search algorithm on this kinda meta graph. What makes this a relaxed version of the original problem, is that instead of finding a path from one node to another, you just need a path connecting "zones" (and movement inside a zone becomes free). I can imagine a few ways you can tweak this approach to have a more accurate heuristic, as well as trade-off accuracy and time/memory.

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад

      @@davidhicks8290
      In short, I don't think there is a useful heuristic that works for any arbitrary graph, where the only information you have about the graph is the weights between the nodes. But maybe I'm wrong.
      Heuristics for A* search are I think typically tailored to a problem domain. For shortest path to minimize latency for a specific problem you might use one heuristic, for solving puzzles in a minimum amount of steps you might use another, etc.
      If you're given a graph with no extra information, you can algorithmically come up with your own heuristic function, but in the time it takes to compute such a function, you probably could have already finished finding the shortest path from your start to your goal with UCS. But if you have to do many shortest path searches on the same graph, it could make sense. I have a few ideas for how you could compute a heuristic function.

  • @cardosov
    @cardosov 6 месяцев назад

    Thanks

  • @Microchaosmac
    @Microchaosmac 6 месяцев назад

    This was awesome!
    Beautiful presentation.
    Learned a lot ^^

  • @Xxnightwalk1
    @Xxnightwalk1 6 месяцев назад

    Thank you so much, your videos are always very clear and informative

  • @mysyntax1311
    @mysyntax1311 6 месяцев назад

    welcome back legend!!

  • @General12th
    @General12th 6 месяцев назад +1

    I can't wait!

  • @vigneshjayaraman791
    @vigneshjayaraman791 3 месяца назад

    Thank god you are back :)

  • @knkootbaoat6759
    @knkootbaoat6759 6 месяцев назад +1

    welcome back!

  • @mujtabaalam5907
    @mujtabaalam5907 5 месяцев назад +3

    Google has never publicly declared which algorithm it uses for maps, but the current public state of thr art is the hub labelling algorithm by Abraham et al

  • @8y8x
    @8y8x 6 месяцев назад +1

    HE CAME BACK!!!!

  • @joelflanagan7132
    @joelflanagan7132 6 месяцев назад

    Can't wait to recommend this to my students next year.

  • @MrLuigiBean1
    @MrLuigiBean1 6 месяцев назад

    Fantastic work as always!!

  • @NicolasChanCSY
    @NicolasChanCSY 6 месяцев назад +4

    Here's how I memorized the need of admissible heuristic: if you cannot justify the alternative route even when you are being optimistic about it, then why go down that route?

  • @leisuretime7417
    @leisuretime7417 6 месяцев назад +1

    I cannot believe this timing holy shit we are literally studying problem solving by searching in our AI class and this video comes up in my feed just as I completed my assignment problems for this class. This is a great video mate, cheers!

  • @farklegriffen2624
    @farklegriffen2624 5 месяцев назад +18

    0:25 "Pacifically"

  • @prototypeinheritance515
    @prototypeinheritance515 6 месяцев назад +1

    I am so happy. I thought you couldn't continue this channel because of economic reasons

  • @kaishang6406
    @kaishang6406 6 месяцев назад

    the channel is still alive!

  • @Killerkraft975
    @Killerkraft975 6 месяцев назад

    Its funny, I immediately thought, combine them both, right after the drawback of uniform cost search. I didn't realise how efficient the algorithm really was until i figured it out.

  • @broccoloodle
    @broccoloodle 5 месяцев назад

    to addon, with admissible heuristic, not only A* search is able to find the optimal path, A* search is also the optimal algorithm, i.e. there is no other algorithm able to expand fewer nodes than A*

  • @atha5469
    @atha5469 6 месяцев назад

    Excellent video !

  • @isbat31416
    @isbat31416 6 месяцев назад

    Welcome back ❤

  • @DiegoGarcia-nm6ki
    @DiegoGarcia-nm6ki 6 месяцев назад +1

    All i see iis flames! 🔥

  • @roborogue_
    @roborogue_ 6 месяцев назад

    NEW REDUCIBLE VIDEO LETS FUCKING GO
    (fav channel out of 1k)

  • @ngtrxpwgdrk
    @ngtrxpwgdrk 6 месяцев назад

    Great explanation!

  • @_spartan11796
    @_spartan11796 6 месяцев назад

    Sweet a new video!

  • @suseJattackIsBack
    @suseJattackIsBack 6 месяцев назад

    the legend has returned

  • @KevinHorecka
    @KevinHorecka 6 месяцев назад

    It seems like if you could compute some statistical properties of your graph you could use those to make some better choices about your heuristic. Make the heuristic have a few more parameters and you could probably even build a model trainable on random or a graph dataset and optimize the heuristic for your specific problem. I'm sure someone already does this. Would be interested if it has a name.

  • @LinesAreVeryCool
    @LinesAreVeryCool 6 месяцев назад +1

    9:57 Isn't 5 rising to the top because it has 0.8 lower cost? The h(5) and h(6) are the same, so I wouldn't that is what actually causes it to rise to the top. Since 6 is also at 2.8 but doesn't rise to the top due to the difference in cost to get there

  • @Dr.SamirKumarSadhukhan-jw1wk
    @Dr.SamirKumarSadhukhan-jw1wk Месяц назад

    Dear Sir, you may use the state-of-the-art Bidirectional heuristic search BAE* (Bidirectional A* wirh Error).

  • @abyssaljam441
    @abyssaljam441 5 месяцев назад +1

    I wish UCS was in Google maps, as then you could look up where can i get to in an hour, if you only have a few hours free in the afternoon..

  • @Philogy
    @Philogy 6 месяцев назад +4

    Isn’t “Uniform Cost Search” Dijkstra’s Algorithm?

    • @the_cheese_cultist
      @the_cheese_cultist 5 месяцев назад +1

      they're different names for essentially the same algorithm

  • @adoq
    @adoq 6 месяцев назад

    wow he's back

  • @rusty-neko
    @rusty-neko 6 месяцев назад

    WOW u are really alive

  • @bennikllr5509
    @bennikllr5509 6 месяцев назад

    Nice video. Please do more again

  • @iso_2013
    @iso_2013 5 месяцев назад +1

    0:24 *specifically

  • @thomasmeslin8399
    @thomasmeslin8399 6 месяцев назад

    A* is great indeed ! When I learned it, the uniform cost search is so bad compared to it.

  • @pgrvloik
    @pgrvloik 5 месяцев назад

    How is the Euclidean distance between nodes calculated? Does it require the GPS coordinates of each node?

  • @sebastianzander87
    @sebastianzander87 6 месяцев назад +1

    What does it have to do with AI (mentioned in the thumbnail)?

  • @traveler9212
    @traveler9212 6 месяцев назад

    Welcome back.

  • @soumalya
    @soumalya 5 месяцев назад

    While seeing this video the code of djikstra, bellman ford, floyd warshall went through my head..

  • @30IYouTube
    @30IYouTube 6 месяцев назад

    Researching this takes a very, VERY long time, because it takes O(n^(enourmous but definitely constant number)) to solve and O(n^^(even biger constant number)) to research where n^^m is a power tower of n's height m.

  • @brightthebackpack
    @brightthebackpack 4 месяца назад

    would anything change if we multipled the heuristic instead of adding it?

  • @lucas.cogrossi
    @lucas.cogrossi 6 месяцев назад

    hes back

  • @itsAbhinav5383
    @itsAbhinav5383 5 месяцев назад

    I was thinking of using the result of greedy search as heuristic for A*
    would it be usable?

  • @timseguine2
    @timseguine2 6 месяцев назад

    Isn't what you described as Uniform Cost Search usually called Dijkstra's algorithm?

    • @the_cheese_cultist
      @the_cheese_cultist 5 месяцев назад

      they're different names for the same algorithm.

  • @BleachWizz
    @BleachWizz 6 месяцев назад

    12:30- wait but you want to use manhatan distance and find optimal on the euclidean distance?
    manhatan distance DOES find optimal solution. In the manhatan distance.

  • @zrIywcN8XJdHaY13K3tx
    @zrIywcN8XJdHaY13K3tx 6 месяцев назад

    i was here!

  • @gigantopithecus8254
    @gigantopithecus8254 6 месяцев назад

    nroi just implemented this

  • @高进-k1h
    @高进-k1h 6 месяцев назад

    finally updated😂

  • @leovalde7z
    @leovalde7z 6 месяцев назад

    its beeen sooo long!

  • @forever_stay6793
    @forever_stay6793 6 месяцев назад

    If anyone knows of any good videos explaining how multi-objective A* algorithms work please share :')

  • @CHEH_tf
    @CHEH_tf 6 месяцев назад

    n00b ads, my bro forced me to watch this on stock youtube

  • @ciCCapROSTi
    @ciCCapROSTi 5 месяцев назад

    When you say work backwards, but the problem is perfectly symmetric it doesn't make much sense

  • @suaeb175
    @suaeb175 6 месяцев назад

  • @noanyobiseniss7462
    @noanyobiseniss7462 6 месяцев назад +3

    I thought the shortest route problem has been solved by fungus.

    • @nekoDan
      @nekoDan 6 месяцев назад

      The beginning of this video has an organic approach for a good solution: ruclips.net/video/X-iSQQgOd1A/видео.htmlsi=MwelIyWoMvpU7AR9

  • @psolien
    @psolien 6 месяцев назад

    you've beeen missed!

  • @cybermats2004
    @cybermats2004 5 месяцев назад

    On image it looks easy and then you look at how to code

  • @patfre
    @patfre 6 месяцев назад +4

    Bro committed a crime you talked about A* without mentioning Dijktra’s algorithm which is what it’s based on

  • @humusstealr9982
    @humusstealr9982 5 месяцев назад

    Ai

  • @neon2633
    @neon2633 6 месяцев назад

  • @TehPwnerer
    @TehPwnerer 6 месяцев назад

    A* search formulates the path(graph) problem into a gradient descent. The path of least resistance you could say, is lightning search!

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад

      I disagree with this somewhat. Although A* uses the heuristic to "tilt" the search towards the goal, it may simultaneously search many paths.
      In contrast, gradient descent in ML, at least a basic implementation of it, essentially acts like a greedy search algorithm rather than A*.

  • @besiansherifaj9350
    @besiansherifaj9350 5 месяцев назад

    GREEDY THUMBNAIL Yellow Line

  • @UnePintade
    @UnePintade 5 месяцев назад

    How is a perfectly defined procedure AI ? 😭

  • @user-nj1qc7uc9c
    @user-nj1qc7uc9c 6 месяцев назад +2

    Did you actually put "AI" in the thumbnail?
    Ive never unsubscribed so quickly in my life
    AI can refer to things other than ML, but here it is 100% buzzword clickbait
    Dijkstra is rolling in his grave

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад +4

      For what it's worth, BFS, Dijkstra's, A*, finding heuristics for A* were all covered as part of an AI course I took in uni.
      A* is widely applicable and extends beyond just finding a path from one place to another on a map or grid or whatever.
      The backbone of chess playing AI is minimax, an algorithm which just switches between computing min and max on a search tree, making it not so different in complexity to A*, yet I assume you have no problem with calling it AI.
      Also, a much older form of AI was "Expert Systems", which generally speaking used a knowledge base(which holds facts and rules) and an inference engine (which applies rules to conclude new facts), and to resolve a query inference engines perform a search! Prolog for example does a depth-first, backtracking search.
      I would imagine that any versatile symbolic AI would be utilizing some search algorithms as a core component.

    • @timseguine2
      @timseguine2 6 месяцев назад

      This is the dumbest comment ever. This belongs to the domain of what is known as Classical AI and always has been canonically. If you knew anything about the history of computing whatsoever you would know that.
      Get off your high horse and quit the pretend outrage. Read any textbook from the 80s or 90s on AI (probably today too but no clue since I am old AF and have no reason to check newer learning material) and there is going to be a ton of stuff about graph search algorithms.

  • @James-l5s7k
    @James-l5s7k 6 месяцев назад

    All of these are bad. Write an adjacency matrix instead and take it to the highest power you can before the matrix converges: simple.

    • @Vaaaaadim
      @Vaaaaadim 6 месяцев назад

      That solution would be memory-intensive, and requires you to explore the whole graph first (I think). Also the search space for a problem can be infinite.
      And if we have V vertices, E edges in the graph, and assume matrix multiplication is an O(n^2.4) algorithm, the time complexity of your approach would be O(log(V) * V^2.4) (assuming you're using a binary search sorta approach). In contrast Uniform Cost Search is O(E + V*log(V)).

    • @eugenedsky3264
      @eugenedsky3264 6 месяцев назад

      Meh... Write a simple brute force search with all special conditions on input data (like the Euclidean distance rule mentioned in the video) and then apply the whole program optimization (symbolic regression?) by AI. No need to even learn about those fancy... adjacency matrices?

    • @the_cheese_cultist
      @the_cheese_cultist 5 месяцев назад

      that's just Floyd Warshall with a log factor

  • @cuineform3708
    @cuineform3708 3 месяца назад

    It's crazy that this video didn't perform better. Try updating the title or thumbnail, like what veritasium describes in m.ruclips.net/video/S2xHZPH5Sng/видео.html . I really like your videos and I'm sure it's dissapointing to put in a lot of effort and not receive the adequate recognition for it.

  • @markuszeller_official
    @markuszeller_official 6 месяцев назад

    Awesome explained and beautiful visuals!