Skip to content

Commit

Permalink
minor fixes in a-star heuristic functions (#15)
Browse files Browse the repository at this point in the history
* fixed get_velocities

* Update routing.jl

* minor fixes
  • Loading branch information
bartoszpankratz authored and pszufe committed May 17, 2019
1 parent 2dd931f commit 859bb9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/a_star.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end
s::Integer,
t::Integer,
distmx::AbstractMatrix{T}=LightGraphs.weights(g),
heuristic::Function = n -> zero(T)) where {T, U}
heuristic::Function = (u,v) -> zero(T)) where {T, U}
High level function - implementation of A star search algorithm:
(https://en.wikipedia.org/wiki/A*_search_algorithm).
Expand All @@ -56,7 +56,7 @@ function a_star_algorithm(g::LightGraphs.AbstractGraph{U}, # the g
s::Integer, # the start vertex
t::Integer, # the end vertex
distmx::AbstractMatrix{T}=LightGraphs.weights(g),
heuristic::Function = n -> zero(T)) where {T, U}
heuristic::Function = (u,v) -> zero(T)) where {T, U}
checkbounds(distmx, Base.OneTo(nv(g)), Base.OneTo(nv(g)))
frontier = DataStructures.PriorityQueue{Tuple{T, U},T}()
frontier[(zero(T), U(s))] = zero(T)
Expand Down
4 changes: 2 additions & 2 deletions src/routing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ calculate_distance(m::OpenStreetMapX.MapData, weights::SparseArrays.SparseMatrix

function find_route(m::OpenStreetMapX.MapData, node0::Int, node1::Int,
weights::SparseArrays.SparseMatrixCSC{Float64,Int64};
routing::Symbol = :astar, heuristic::Function = n -> zero(Float64),
routing::Symbol = :astar, heuristic::Function = (u,v) -> zero(Float64),
get_distance::Bool = false, get_time::Bool = false)
result = Any[]
start_vertex = m.v[node0]
Expand Down Expand Up @@ -206,7 +206,7 @@ end

function find_route(m::OpenStreetMapX.MapData, node0::Int, node1::Int, node2::Int,
weights::SparseArrays.SparseMatrixCSC{Float64,Int64};
routing::Symbol = :astar, heuristic::Function = n -> zero(Float64),
routing::Symbol = :astar, heuristic::Function = (u,v) -> zero(Float64),
get_distance::Bool = false, get_time::Bool = false)
result = Any[]
route1 = OpenStreetMapX.find_route(m, node0, node1, weights,
Expand Down

0 comments on commit 859bb9d

Please sign in to comment.