Giter Club home page Giter Club logo

the-shortest-path's Introduction

the-shortest-path

About this app

Kalid wants to go from university to home. He has limited time, power, and money. The path to the home contains stations and routes connected with each other. There are three ways to move around (taxi, bus, walking), each one having different costs (time, money). In this algorithm, we will find the best path depending on Kalid’s prioritization (ex. going home with the lowest money cost and his power more than zero).

About A* and State space search

State space search is a technique for finding solutions to problems by exploring the possible states and actions that lead from the initial state to the goal state. algorithm for state space search A* is a popular that uses a heuristic function to estimate the cost of reaching the goal from each state. The algorithm maintains a priority queue of states, ordered by the sum of the cost so far and the heuristic cost. It repeatedly expands the state with the lowest priority, until it reaches the goal or the queue is empty.

Examples

The first map

It contains 5 stations and 8 routes Coins 5000 and energy 1

  1. Min Time, Power less than myPower, Money less than myMoney

      1. start-station-id: 1 -- end-station-id: home money-cost: 4400.0 __ power-cost: 15.0 __ way: buss
      1. start-station-id: start -- end-station-id: 1 money-cost: 4000.0 __ power-cost: 20.0 __ way: taxi
    • Process time 53 ms

    • Visited roots 4

  2. Min Time, Max Power, Min Money

      1. start-station-id: 2 -- end-station-id: home money-cost: 0.0 __ power-cost: -100.0 __ way: walk
      1. start-station-id: start -- end-station-id: 2 money-cost: 0.0 __ power-cost: -30.0 __ way: walk
    • Process time 19 ms

    • Visited roots 4

The second map

It contains 8 stations and 11 routes Coins 16000 and energy 4

  1. Min Money, Power less than myPower

      1. start-station-id: 6 -- end-station-id: home money-cost: 400.0 __ power-cost: -400.0 __ way: buss
      1. start-station-id: 5 -- end-station-id: 6 money-cost: 0.0 __ power-cost: -390.0 __ way: walk
      1. start-station-id: 3 -- end-station-id: 5 money-cost: 0.0 __ power-cost: -260.0 __ way: walk
      1. start-station-id: start -- end-station-id: 3 money-cost: 0.0 __ power-cost: -150.0 __ way: walk
    • Process time 21 ms

    • Visited root 9

  2. Min Time, Max Power, Min Money

      1. start-station-id: 6 -- end-station-id: home money-cost: 0.0 __ power-cost: -500.0 __ way: walk
      1. start-station-id: 1 -- end-station-id: 6 money-cost: 0.0 __ power-cost: -300.0 __ way: walk
      1. start-station-id: start -- end-station-id: 1 money-cost: 0.0 __ power-cost: -150.0 __ way: walk
    • Process time 19 ms

    • Visited root 14

the-shortest-path's People

Contributors

obaa10 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.