Skip to content

Commit

Permalink
Check constraints on the initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
aemartinez committed Aug 26, 2024
1 parent 93f578c commit 6126004
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/planners/backward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ function solve(planner::BackwardPlanner,
search_order = UInt[]
sol = PathSearchSolution(:in_progress, Term[], Vector{typeof(state)}(),
0, search_tree, queue, search_order)
# Run the search
sol = search!(sol, planner, planner.heuristic, domain, spec)
# Check if initial state satisfies trajectory constraints
if is_violated(spec, domain, state)
sol.status = :failure
else # Run the search
sol = search!(sol, planner, planner.heuristic, domain, spec)
end
# Return solution
if save_search
return sol
Expand Down
8 changes: 6 additions & 2 deletions src/planners/bfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ function solve(planner::BreadthFirstPlanner,
search_order = UInt[]
sol = PathSearchSolution(:in_progress, Term[], Vector{typeof(state)}(),
0, search_tree, queue, search_order)
# Run the search
sol = search!(sol, planner, domain, spec)
# Check if initial state satisfies trajectory constraints
if is_violated(spec, domain, state)
sol.status = :failure
else # Run the search
sol = search!(sol, planner, domain, spec)
end
# Return solution
if save_search
return sol
Expand Down
13 changes: 11 additions & 2 deletions src/planners/forward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ function solve(planner::ForwardPlanner,
precompute!(heuristic, domain, state, spec)
# Initialize solution
sol = init_sol(planner, heuristic, domain, state, spec)
# Run the search
sol = search!(sol, planner, heuristic, domain, spec)
# Check if initial state satisfies trajectory constraints
if is_violated(spec, domain, state)
sol.status = :failure
else # Run the search
sol = search!(sol, planner, heuristic, domain, spec)
end
# Return solution
if save_search
return sol
Expand Down Expand Up @@ -378,6 +382,11 @@ function refine!(
# Decide between restarting, rerooting, or continuing the search
if refine_method == :restart
(sol.status == :failure && is_reached(state, sol)) && return sol
# Check if initial state satisfies trajectory constraints
if is_violated(spec, domain, state)
sol.status = :failure
return sol
end
reinit_sol!(sol, planner, heuristic, domain, state, spec)
elseif refine_method == :reroot
reroot!(sol, planner, heuristic, domain, state, spec)
Expand Down

0 comments on commit 6126004

Please sign in to comment.