File tree Expand file tree Collapse file tree 4 files changed +61
-8
lines changed Expand file tree Collapse file tree 4 files changed +61
-8
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ $ julia --color=yes -e 'using Pkg; Pkg.add(Pkg.PackageSpec(path="https://github.
32
32
$ julia --color=yes -e ' using Pkg; Pkg.add(Pkg.PackageSpec(path="https://github.com/JuliaPy/PyCall.jl"))'
33
33
```
34
34
35
- - Install Python dependencies
35
+ - Install Python dependencies
36
36
37
37
``` bash
38
38
$ python3 -m pip install --upgrade pip
@@ -41,6 +41,10 @@ $ cd pddl-plarser
41
41
$ python3 -m pip install -r requirements.txt
42
42
```
43
43
44
+ # Usage
45
+
46
+ Navigate to the root directory and you can run the tool by using : ` python3 main.py "data/domain.pddl" "data/problem.pddl" `
47
+
44
48
# REFL Mode
45
49
46
50
- Clone the repository: ` git clone https://github.com/APLA-Toolbox/pddl-plarser `
Original file line number Diff line number Diff line change 1
- import src .automated_planner as plarser
1
+ import src .automated_planner as parser
2
2
import argparse
3
3
4
4
@@ -11,8 +11,8 @@ def main():
11
11
args_parser .add_argument ("problem" , type = str , help = "PDDL problem file" )
12
12
args_parser .add_argument ("-v" , "--verbose" , help = "Increases the output's verbosity" )
13
13
args = args_parser .parse_args ()
14
- apla_tbx = plarser .AutomatedPlanner (args .domain , args .problem )
15
- path , time = apla_tbx .dijktra_best_first_search (time_it = True )
14
+ apla_tbx = parser .AutomatedPlanner (args .domain , args .problem )
15
+ path , time = apla_tbx .depth_first_search (time_it = True )
16
16
print (apla_tbx .get_actions_from_path (path ))
17
17
print ("Computation time: %.2f" % time )
18
18
Original file line number Diff line number Diff line change 1
1
from .modules import loading_bar_handler
2
2
from .bfs import BreadthFirstSearch
3
+ from .dfs import DepthFirstSearch
3
4
from .dijkstra import DijkstraBestFirstSearch
4
5
5
- loading_bar_handler (False )
6
+ UI = False
7
+
8
+ if UI :
9
+ loading_bar_handler (False )
6
10
import julia
11
+
7
12
_ = julia .Julia (compiled_modules = False )
8
- loading_bar_handler (True )
13
+
14
+ if UI :
15
+ loading_bar_handler (True )
16
+
9
17
from julia import PDDL
10
18
from time import time as now
11
19
@@ -75,6 +83,19 @@ def breadth_first_search(self, time_it=False):
75
83
else :
76
84
return path , None
77
85
86
+ def depth_first_search (self , time_it = False ):
87
+ if time_it :
88
+ start_time = now ()
89
+ dfs = DepthFirstSearch (self )
90
+ last_node = dfs .search ()
91
+ if time_it :
92
+ total_time = now () - start_time
93
+ path = self .__retrace_path (last_node )
94
+ if time_it :
95
+ return path , total_time
96
+ else :
97
+ return path , None
98
+
78
99
def dijktra_best_first_search (self , time_it = False ):
79
100
if time_it :
80
101
start_time = now ()
Original file line number Diff line number Diff line change
1
+ from .node import Node
2
+
1
3
class DepthFirstSearch :
2
4
def __init__ (self , automated_planner ):
5
+ self .visited = []
3
6
self .automated_planner = automated_planner
7
+ self .init = Node (self .automated_planner .initial_state , automated_planner )
8
+ self .stack = [self .init ]
4
9
5
10
def search (self ):
6
- print ("-/!\- No path found -/!\-" )
7
- return []
11
+ while self .stack :
12
+ current_node = self .stack .pop (0 )
13
+ if current_node not in self .visited :
14
+ self .visited .append (current_node )
15
+
16
+ if self .automated_planner .satisfies (
17
+ self .automated_planner .problem .goal , current_node .state
18
+ ):
19
+ return current_node
20
+
21
+ actions = self .automated_planner .available_actions (current_node .state )
22
+ for act in actions :
23
+ child = Node (
24
+ state = self .automated_planner .transition (
25
+ current_node .state , act
26
+ ),
27
+ automated_planner = self .automated_planner ,
28
+ parent_action = act ,
29
+ parent = current_node ,
30
+ )
31
+ if child in self .visited :
32
+ continue
33
+ self .stack .append (child )
34
+ print ("!!! No path found !!!" )
35
+ return None
You can’t perform that action at this time.
0 commit comments