Description Usage Arguments Value Examples
The search space is defined by a list passed thorugh params.
1 |
start |
initial node in the search space |
params |
a list containing functions necessary to define the search problem: |
max.iters |
maximum number of iterations to run - for debuggin purposes only, defaults to |
... |
additional parameters passed to each of the functions defined in |
A list containing two components solution
and history
.
1 2 3 4 5 6 7 8 9 10 11 12 | # Searching for a path from (0,0), to (0,3) with three points blocked along the way
dirs <- list(c(1,0),c(0,1),c(0,-1),c(-1,0))
params <- list(
heuristic = function(el, goal) sum((goal-el)^2),
distance = function(el, parent, parentDistance, ...) parentDistance + 1,
neighbours = function(el, ...) setdiff( lapply(dirs, function(d) el+d),
list(c(0,2), c(1,1), c(-1,1))),
is_feasible = function(node, goal){ identical(node, goal) }
)
res <- astar(c(0,0), params, goal = c(0,3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.