Skip to content

Commit 059530d

Browse files
authored
Merge pull request #37 from APLA-Toolbox/improve-devops
revert changes
2 parents 77220ba + 0bdb48c commit 059530d

5 files changed

Lines changed: 21 additions & 4 deletions

File tree

.github/workflows/format.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: format
22
on:
3-
push:
4-
branches: [master]
3+
pull_request:
4+
branches: [main]
55
jobs:
66
format:
77
runs-on: ubuntu-latest
@@ -24,5 +24,5 @@ jobs:
2424
- name: Commit changes
2525
uses: stefanzweifel/git-auto-commit-action@v4.1.2
2626
with:
27-
commit_message: 🎉 Apply formatting changes
28-
branch: master
27+
commit_message: Apply formatting changes
28+
branch: ${{ github.head_ref }}

src/automated_planner.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,29 @@ def __init__(self, domain_path, problem_path):
3030
"""
3131
Transition from one state to the next using an action
3232
"""
33+
3334
def transition(self, state, action):
3435
return self.pddl.transition(self.domain, state, action, check=False)
3536

3637
"""
3738
Returns all available actions from the given state
3839
"""
40+
3941
def available_actions(self, state):
4042
return self.pddl.available(state, self.domain)
4143

4244
"""
4345
Check if a vector of terms is satisfied by the given state
4446
"""
47+
4548
def satisfies(self, asserted_state, state):
4649
return self.pddl.satisfy(asserted_state, state, self.domain)[0]
4750

4851
"""
4952
Check if the term is satisfied by the state
5053
To do: compare if it's faster to compute the check on a vector of terms in julia or python
5154
"""
55+
5256
def state_has_term(self, state, term):
5357
if self.pddl.has_term_in_state(self.domain, state, term):
5458
return True
@@ -59,12 +63,14 @@ def state_has_term(self, state, term):
5963
Flatten the goal to a vector of terms
6064
To do: check if we can iterate over the jl vector
6165
"""
66+
6267
def __flatten_goal(self):
6368
return self.pddl.flatten_goal(self.problem)
6469

6570
"""
6671
Retrieves the linked list path
6772
"""
73+
6874
def __retrace_path(self, node):
6975
if not node:
7076
return []
@@ -78,6 +84,7 @@ def __retrace_path(self, node):
7884
"""
7985
Returns all the actions operated to reach the goal
8086
"""
87+
8188
def get_actions_from_path(self, path):
8289
if not path:
8390
logging.warning("Path is empty, can't operate...")
@@ -95,6 +102,7 @@ def get_actions_from_path(self, path):
95102
"""
96103
Returns all the states that should be opened from start to goal
97104
"""
105+
98106
def get_state_def_from_path(self, path):
99107
if not path:
100108
logging.warning("Path is empty, can't operate...")
@@ -107,6 +115,7 @@ def get_state_def_from_path(self, path):
107115
"""
108116
Runs the BFS algorithm on the loaded domain/problem
109117
"""
118+
110119
def breadth_first_search(self, time_it=False):
111120
if time_it:
112121
start_time = now()
@@ -123,6 +132,7 @@ def breadth_first_search(self, time_it=False):
123132
"""
124133
Runs the DFS algorithm on the domain/problem
125134
"""
135+
126136
def depth_first_search(self, time_it=False):
127137
if time_it:
128138
start_time = now()
@@ -139,6 +149,7 @@ def depth_first_search(self, time_it=False):
139149
"""
140150
Runs the Dijkstra algorithm on the domain/problem
141151
"""
152+
142153
def dijktra_best_first_search(self, time_it=False):
143154
if time_it:
144155
start_time = now()

src/heuristics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
def zero_heuristic(state, automated_planner):
22
return 0
33

4+
45
def goal_count_heuristic(state, automated_planner):
56
count = 0
67
for goal in automated_planner.goals:

tests/test_automated_planner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@ def test_available_actions():
1717
actions = apla.available_actions(apla.initial_state)
1818
assert len(actions) > 0
1919

20+
2021
def test_execute_action():
2122
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
2223
actions = apla.available_actions(apla.initial_state)
2324
new_state = apla.transition(apla.initial_state, actions[0])
2425
assert str(new_state) != str(apla.initial_state)
2526

27+
2628
def test_state_has_term():
2729
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
2830
is_goal = apla.state_has_term(apla.initial_state, apla.goals[0])
2931
assert is_goal == False
3032

33+
3134
def test_state_assertion():
3235
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
3336
assert apla.satisfies(apla.problem.goal, apla.initial_state) == False

tests/test_heuristics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
- Run search algorithms and test value of h when at goal
1414
"""
1515

16+
1617
def test_zero_heuristic():
1718
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
1819
heuristic = hs.zero_heuristic(apla.initial_state, apla)
1920
assert heuristic == 0
2021

22+
2123
def test_goal_count_heuristic():
2224
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
2325
heuristic = hs.goal_count_heuristic(apla.initial_state, apla)

0 commit comments

Comments
 (0)