Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue1082] Use Options objects only in Features #218

Merged
merged 238 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 215 commits
Commits
Show all changes
238 commits
Select commit Hold shift + click to select a range
c37b2c3
Move unpacking of opts to BlindSearchHeuristicFeature.
SimonDold Nov 8, 2023
681c3e1
Florians feedback
SimonDold Nov 16, 2023
8db40f2
add malte discussion comment
SimonDold Nov 16, 2023
d2403f9
remove destructor.
SimonDold Nov 20, 2023
3eca358
add name parameter to evaluator
FlorianPommerening Nov 22, 2023
829df0a
Move unpacking of opts to BlindSearchHeuristicFeature.
SimonDold Nov 8, 2023
a92b5b4
Florians feedback
SimonDold Nov 16, 2023
696a2d9
add malte discussion comment
SimonDold Nov 16, 2023
5428d7f
remove destructor.
SimonDold Nov 20, 2023
dac2226
Move unpacking of opts to BlindSearchHeuristicFeature.
SimonDold Nov 8, 2023
f6a4256
Florians feedback
SimonDold Nov 16, 2023
e8c9874
remove destructor.
SimonDold Nov 20, 2023
a72fffd
add name parameter to evaluator
FlorianPommerening Nov 22, 2023
3fc0abc
[issue1082] intern parameter order
SimonDold Feb 1, 2024
0e160d5
[issue1082] style
SimonDold Feb 1, 2024
1e315dd
[issue1082] fix rebase
SimonDold Feb 1, 2024
770cc27
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Feb 1, 2024
f03ba76
[issue1082] restore destructors
SimonDold Feb 1, 2024
af6f95a
[issue1082] Jendriks requested changes
SimonDold Feb 1, 2024
4f671ae
[issue1082] make transform const
SimonDold Feb 1, 2024
1170b1e
[issue1082] add default name, adjust wiki order
SimonDold Feb 1, 2024
d688a65
[issue1082] style
SimonDold Feb 1, 2024
a6ca706
[issue1082] move 'name' to log_options
SimonDold Feb 2, 2024
34e63ba
[issue1082] comments
SimonDold Feb 2, 2024
87f0f8b
[issue1082] style
SimonDold Feb 2, 2024
50cf916
[issue1082] comment
SimonDold Feb 2, 2024
edc1fdd
[issue1082] update merge_strategy_factory_precomputed
SimonDold Feb 2, 2024
218c31a
[issue1082] update merge_strategy_factory_sccs
SimonDold Feb 2, 2024
6047e02
[issue1082] style
SimonDold Feb 2, 2024
853ddd9
[issue1082] update constructor of merge_strategy_factory_stateless
SimonDold Feb 2, 2024
8ee8739
[issue1082] remove ByOptions-constructor
SimonDold Feb 2, 2024
587dfb1
[issue1082] style
SimonDold Feb 2, 2024
5b8728b
Merge pull request #3 from SimonDold/issue1082-MergeStrategy
SimonDold Feb 2, 2024
1db6f50
[issue1082] update merge_tree_factory_linear
SimonDold Feb 2, 2024
acf0b1c
[issue1082] update merge_tree_factory_linear (#4)
SimonDold Feb 2, 2024
7e27747
[issue1082] update label_reduction
SimonDold Feb 2, 2024
e55e395
[issue1082] handle warning
SimonDold Feb 2, 2024
8543ab0
[issue1082] remove const
SimonDold Feb 2, 2024
d5ead08
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Feb 2, 2024
b49e3ae
change constructors in pdb code
FlorianPommerening Feb 2, 2024
c6733b7
[issue1082] handle warnings
SimonDold Feb 3, 2024
8347a5a
[issue1082] handle warnings
SimonDold Feb 3, 2024
b99ceef
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Feb 3, 2024
4954365
[issue1082] style
SimonDold Feb 3, 2024
0b0d16d
[issue1082] add get_parameters_from_options functions
SimonDold Feb 5, 2024
93973cf
[issue1082] flatten HMHeuristic
SimonDold Feb 5, 2024
9cd7e6d
[issue1082] fix compiler complaints.
SimonDold Feb 5, 2024
e559495
[issue1082] style.
SimonDold Feb 5, 2024
7551e69
[issue1082] remove names or replace name with description.
SimonDold Feb 5, 2024
d0b73b1
[issue1082] restore name() and remove introduced log.
SimonDold Feb 6, 2024
ee1e5c0
[issue1082] replace name with description.
SimonDold Feb 6, 2024
9887d7c
[issue1082] use smart_pointers to tuples.
SimonDold Feb 6, 2024
4b865dd
[issue1082] reduce boiler plate.
SimonDold Feb 6, 2024
1b0ef71
[issue1082] update linear().
SimonDold Feb 7, 2024
3c32e69
[issue1082] update MergeScoringFunctions.
SimonDold Feb 7, 2024
e2893b7
[issue1082] add coordination file
SimonDold Feb 7, 2024
453e658
[issue1082] update RelaxationHeuristics.
SimonDold Feb 7, 2024
015fe60
style
SimonDold Feb 7, 2024
72b0915
[issue1082] update pdbs.
SimonDold Feb 7, 2024
a956c83
[issue1082] add more indirection to RelaxationHeuristics to mathc the…
SimonDold Feb 7, 2024
9fe28ad
[issue1082] style.
SimonDold Feb 7, 2024
2e08173
Update BlindSearchHeuristic
grucla Feb 7, 2024
97246e8
Update ContextEnhancedAdditiveHeuristic
grucla Feb 7, 2024
adf5127
[issue1082] Update CGHeuristic
grucla Feb 7, 2024
4153073
Fix style.
grucla Feb 7, 2024
e023dea
[issue1082] BREAKING update many M&S components.
SimonDold Feb 7, 2024
ce38266
[issue1082] Update GoalCountHeuristic
grucla Feb 7, 2024
681209e
[halfmas] comment.
SimonDold Feb 7, 2024
4c2bdb1
Merge branch 'issue1082-MaS' into issue1082-partial-Mas
SimonDold Feb 7, 2024
0f703df
Remove explicity from GoalCountHeuristic constructor
grucla Feb 7, 2024
3172488
[issue1082] Update LandmarkCutHeuristic
grucla Feb 7, 2024
2125076
mark files that do not require changes
FlorianPommerening Feb 7, 2024
2b7bf6c
[issue1082] update M&S components.
SimonDold Feb 7, 2024
9c53523
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Feb 7, 2024
b2ef706
[issue1082] fix merge.
SimonDold Feb 7, 2024
0503015
new approach for argument tuples
FlorianPommerening Feb 7, 2024
5e74d90
use flattened arguments in make_shared_from_arg_tuples
FlorianPommerening Feb 8, 2024
5158467
[issue1082] update mechanical changes
SimonDold Feb 8, 2024
1ea373a
Issue1082 with fixed order in make_shared (#5)
FlorianPommerening Feb 8, 2024
1ef655b
Update AAA_Mechanical_Changes.md
SimonDold Feb 8, 2024
669444c
Add landmark files to TODO list.
ClemensBuechner Feb 7, 2024
cb86f12
Implement flat constructors for landmark factories.
ClemensBuechner Feb 7, 2024
1fd6ab2
Fix order.
ClemensBuechner Feb 8, 2024
36dc0f2
Update to new model.
ClemensBuechner Feb 8, 2024
bd63331
Remove all options from constructors in landmark directory.
ClemensBuechner Feb 8, 2024
f014045
Add comments and make option-related functions external.
ClemensBuechner Feb 8, 2024
d90e3d8
Fix typo.
ClemensBuechner Feb 8, 2024
74d1f98
[issue1082] update rng_options, add get_xyz_arguments_from_options.
SimonDold Feb 8, 2024
39f7407
Merge branch 'issue1082FP' into issue1082
SimonDold Feb 8, 2024
ae4f482
[issue1082] fix argument order.
SimonDold Feb 8, 2024
52c9451
[issue1082] style.
SimonDold Feb 8, 2024
3244f79
style.
SimonDold Feb 8, 2024
ff1c0ce
style.
SimonDold Feb 8, 2024
d2fae48
Merge branch 'issue1082CleBue' into issue1082
SimonDold Feb 8, 2024
c4e15fd
[issue1082] minimize the use of Options in lm_heuristics.
SimonDold Feb 8, 2024
fa28521
[issue1082] remove unused field.
SimonDold Feb 8, 2024
1b2acb9
[issue1082] move add_heuristic_options_to_feature outside of class.
SimonDold Feb 8, 2024
7aa2c45
smaller implementation of tuple flattening
FlorianPommerening Feb 8, 2024
0452fb9
small fixes
FlorianPommerening Feb 8, 2024
bd5addc
[issue1082] move add_xyz_options_to_feature outside of class.
SimonDold Feb 8, 2024
ea73ee6
update operator-counting
FlorianPommerening Feb 8, 2024
4f13d8a
update pruning
FlorianPommerening Feb 8, 2024
9884598
update tasks
FlorianPommerening Feb 8, 2024
7fe1b62
mark changes
FlorianPommerening Feb 8, 2024
d3c6336
update cegar heuristic
FlorianPommerening Feb 9, 2024
3e11f79
[issue1082] update SearchAlgorithms.
SimonDold Feb 9, 2024
4c499c0
[issue1082] style.
SimonDold Feb 9, 2024
67ac356
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Feb 9, 2024
720f058
[issue1082] style.
SimonDold Feb 9, 2024
d77141f
[issue1082] reduce use of auto.
SimonDold Feb 9, 2024
01da84a
update cegar generators
FlorianPommerening Feb 9, 2024
b140624
mark changes
FlorianPommerening Feb 9, 2024
4dcee46
[issue1082] update done list .
SimonDold Feb 9, 2024
87b6fb5
[issue1082] style.
SimonDold Feb 9, 2024
d9b984d
[issue1082] fix merge.
SimonDold Feb 9, 2024
fc94d78
[issue1082] update done file.
SimonDold Feb 9, 2024
d73e301
[issue1082] style.
SimonDold Feb 9, 2024
9b6f0d8
[issue1082] OpenList (in progress)
SimonDold Feb 9, 2024
ce85f32
[issue1082] reduce tox complaints.
SimonDold Feb 9, 2024
dae511e
[issue1082] in progress.
SimonDold Feb 9, 2024
03cde6e
Merge branch 'issue1082OpenList' into issue1082
SimonDold Feb 9, 2024
d065ca0
[issue1082] in progress.
SimonDold Feb 11, 2024
3f4d729
update best_first
SimonDold Feb 11, 2024
62b19df
update alternation_open_list.
SimonDold Feb 11, 2024
04995d6
update pareto_open_list.
SimonDold Feb 11, 2024
e4caa43
update tiebreaking_open_list.
SimonDold Feb 11, 2024
d42fb1a
update type_based_open_list.
SimonDold Feb 11, 2024
26459cd
update epsilon_greedy_open_list.
SimonDold Feb 11, 2024
57b2106
remove options include.
SimonDold Feb 11, 2024
a2dc81f
change constructor call to match pattern.
SimonDold Feb 11, 2024
ab042d3
style
SimonDold Feb 11, 2024
309ccc5
style
SimonDold Feb 11, 2024
1dd1747
style
SimonDold Feb 11, 2024
846ee62
reduce use of options object in search common
SimonDold Feb 11, 2024
96edee9
reduce use of options object in search common
SimonDold Feb 11, 2024
6ce4aee
removeoptions object in search common header
SimonDold Feb 11, 2024
25c3203
remove options object from open list factories
SimonDold Feb 11, 2024
433d5a6
style
SimonDold Feb 11, 2024
b8d7399
polish
SimonDold Feb 11, 2024
02b471c
polish
SimonDold Feb 11, 2024
7cea103
merge update OpenLists
SimonDold Feb 11, 2024
e2d1689
reduce copies.
SimonDold Feb 12, 2024
ebcf047
issue1082 evaluators
tanjaschindler Feb 12, 2024
1e49199
[issue1082] update done file.
tanjaschindler Feb 12, 2024
c72419e
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Feb 15, 2024
1ff99aa
style
SimonDold Feb 15, 2024
1ce8c7a
remove ByOpts-Constructors, reduce copies.
SimonDold Feb 15, 2024
1845863
update potentials
SimonDold Feb 16, 2024
8b8247a
style
SimonDold Feb 16, 2024
9e9a1cc
[issue1082] remove unused ByOpts methods
tanjaschindler Feb 16, 2024
77586ee
style
tanjaschindler Feb 16, 2024
957a6d4
[issue1082] triage TODOs
tanjaschindler Feb 16, 2024
95d3579
add automated check (not working yet)
SimonDold Mar 1, 2024
407d2e0
add automated check for constructor parameter order
SimonDold Mar 3, 2024
1462992
remove unused function
SimonDold Mar 3, 2024
3866efc
fix recognition for multiple features in one .cc
SimonDold Mar 3, 2024
89b3ba3
Merge remote-tracking branch 'MyFork/issue1082' into issue1082
SimonDold Mar 3, 2024
8cffea8
make code cleaner
SimonDold Mar 3, 2024
073209a
adjust constructor parameters to fit CLI parameters
SimonDold Mar 3, 2024
a9b1368
remove never changing parameters.
SimonDold Mar 4, 2024
f78cd78
rename 'name' to description.
SimonDold Mar 4, 2024
f6b0149
add exceptions.
SimonDold Mar 4, 2024
314e4e0
fix order
SimonDold Mar 4, 2024
eb9eff6
match parameter names.
SimonDold Mar 4, 2024
4e99bb6
add exceptions.
SimonDold Mar 4, 2024
503d5db
remove options object from LandmarHeuristic.
SimonDold Mar 6, 2024
4e13d05
deactivate parameter_check
SimonDold Mar 7, 2024
863df3d
fix feature_parameter extraction
SimonDold Mar 12, 2024
6eea000
fix typo
SimonDold Mar 12, 2024
dc60080
fix typo
SimonDold Mar 12, 2024
31b323b
Revert "fix typo"
SimonDold Mar 12, 2024
d2a4882
style
SimonDold Mar 12, 2024
e162e78
change parameter_names in constructor to match feature
SimonDold Mar 12, 2024
6313754
add pwd output
SimonDold Mar 13, 2024
d1ff2b3
Revert "add pwd output"
SimonDold Mar 13, 2024
e336ea1
add pwd output
SimonDold Mar 13, 2024
fb522c2
add tree output
SimonDold Mar 13, 2024
574de7f
update tree
SimonDold Mar 13, 2024
4da75db
update tree
SimonDold Mar 13, 2024
7371d9a
add separate parameters check
SimonDold Mar 14, 2024
f22623d
typo
SimonDold Mar 14, 2024
45a7daa
style
SimonDold Mar 14, 2024
c42d9b3
fix comment
SimonDold Apr 5, 2024
7fdf881
triage todo
SimonDold Apr 5, 2024
35a2867
add comment
SimonDold Apr 5, 2024
b697025
Merge branch 'aibasel:main' into issue1082
SimonDold Apr 5, 2024
8639708
put parameter in few lines
SimonDold Apr 8, 2024
45488a6
tox fix style
SimonDold Apr 8, 2024
f05376d
style
SimonDold Apr 10, 2024
55c2c9e
style
SimonDold Apr 10, 2024
cf3262f
reduce line length
SimonDold Apr 11, 2024
427c1a7
remove issue 1082 comments
SimonDold Apr 11, 2024
5f7c9d1
use perfect forwarding
SimonDold Apr 12, 2024
b12fd9d
style
SimonDold Apr 12, 2024
bde514e
style
SimonDold Apr 12, 2024
e8f5ec8
delete accidental commited files
SimonDold Apr 13, 2024
c013093
delete accidental commited files
SimonDold Apr 13, 2024
ca33ae0
accept position of make_shared_from_arg_tuples
SimonDold Apr 13, 2024
94a0f91
add tree output
SimonDold Apr 13, 2024
8db5b2a
add output
SimonDold Apr 13, 2024
bf80ae7
add tree output
SimonDold Apr 13, 2024
0d11710
reduce output
SimonDold Apr 13, 2024
a5dd482
add output
SimonDold Apr 13, 2024
faafea1
add output
SimonDold Apr 13, 2024
74ca884
add trailing slash
SimonDold Apr 13, 2024
3c942d4
replace tree with ls
SimonDold Apr 13, 2024
a97fc33
add pwd output
SimonDold Apr 13, 2024
d4fe6b7
.
SimonDold Apr 13, 2024
8605c1f
add output
SimonDold Apr 13, 2024
1f79d57
change dir before output
SimonDold Apr 13, 2024
bc2432e
change dir before output
SimonDold Apr 13, 2024
e73ddc5
change dir before output
SimonDold Apr 13, 2024
745b38e
add src to artifact
SimonDold Apr 17, 2024
dbee140
remove output
SimonDold Apr 17, 2024
0af7fae
remove debug output
SimonDold Jun 19, 2024
45d501e
Update logging.h
SimonDold Jun 28, 2024
361fbdd
style
SimonDold Jun 28, 2024
7dd6c8d
implement feddback
SimonDold Jun 28, 2024
7fd9d24
reduce error message width.
SimonDold Jun 28, 2024
dd1fda2
adjust to review comments.
SimonDold Jul 2, 2024
d4f8655
review comments
SimonDold Jul 3, 2024
22b3c76
style
SimonDold Jul 3, 2024
fd037d7
remove unused function.
SimonDold Jul 3, 2024
2ae78b9
remove unused function.
SimonDold Jul 3, 2024
0306ecc
undo unnecessary change.
SimonDold Jul 3, 2024
a6fc4a5
adjust parameter order.
SimonDold Jul 3, 2024
97a16f2
undo unnecessary include.
SimonDold Jul 3, 2024
c50b1a0
fix style
SimonDold Jul 3, 2024
03ee101
use move in constructor.
SimonDold Jul 4, 2024
a4eadf7
change parameter order.
SimonDold Jul 4, 2024
2c9f383
break ling line.
SimonDold Jul 4, 2024
f9b49dc
rename function.
SimonDold Jul 4, 2024
8f3b87b
adjust field order to match constructor parameter order.
SimonDold Jul 4, 2024
51e101c
put include back into .cc and add get_canonical_pdbs_arguments_from_o…
SimonDold Jul 4, 2024
1e13122
remove unnecessary include.
SimonDold Jul 4, 2024
c623d0d
fix style.
SimonDold Jul 4, 2024
e228cac
merge
SimonDold Jul 5, 2024
4a7cea2
add comment.
SimonDold Jul 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
# only need to archive that one.
if: ${{ matrix.version.run_tox_tests }}
run: |
files_to_archive="fast-downward.py driver misc builds/debug/bin/ \
files_to_archive="fast-downward.py driver misc src builds/debug/bin/ \
builds/release/bin/ ${SOPLEX_LIB} ${SOPLEX_INCLUDE}"
if [[ ! -z "${CPLEX_URL}" ]]; then
files_to_archive="${files_to_archive} ${CPLEX_LIB}"
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
- name: Run driver, translator and search tests
run: |
cd misc/
tox -e driver,translator,search,autodoc
tox -e driver,translator,search,parameters,autodoc

- name: Run CPLEX tests
if: ${{ env.CPLEX_URL != 0 }}
Expand Down
258 changes: 258 additions & 0 deletions misc/tests/test-parameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
#! /usr/bin/env python3

HELP = """\
Check that parameters for the command line features match the parameters
of the C++ constructors. Use txt2tags to compare the parameters
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
mentioned in the wiki to the parameters in the corresponding .cc file.
"""

import argparse
import os
import os.path
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
import re
import subprocess
import sys

DIR = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(DIR))
SRC_DIR = os.path.join(REPO, "src")

SHORT_HANDS = {
"ipdb": "cpdbs(hillclimbing())",
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
"astar": "eager(tiebreaking([sum([g(), h]), h],"
" unsafe_pruning=false), reopen_closed=true,"
" f_eval=sum([g(), h]))",
"lazy_greedy": "lazy(alt([single(h1), single(h1,"
" pref_only=true), single(h2), single(h2,"
" pref_only=true)], boost=100), preferred=h2)",
"lazy_wastar": "lazy(single(sum([g(), weight(eval1, 2)])),"
" reopen_closed=true)",
"eager_greedy": "eager(single(eval1))",
"eager_wastar": """ See corresponding notes for"""
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
""" "(Weighted) A* search (lazy)" """,


}

TEMPORARY_EXCEPTIONS = [
"iterated",
"eager",
"sample_based_potentials",
"initial_state_potential",
"all_states_potential",
"diverse_potentials",
]

PERMANENT_EXCEPTIONS = [
"adapt_costs"
]

CREATE_COMPONENT_REGEX = r"(^|\s|\W)create_component"
C_VAR_PATTERN = r'[^a-zA-Z0-9_]' # overapproximation
SimonDold marked this conversation as resolved.
Show resolved Hide resolved


def get_src_files(path, extensions, ignore_dirs=None):
ignore_dirs = ignore_dirs or []
src_files = []
for root, dirs, files in os.walk(path):
for ignore_dir in ignore_dirs:
if ignore_dir in dirs:
dirs.remove(ignore_dir)
src_files.extend([
os.path.join(root, file)
for file in files if file.endswith(extensions)])
return src_files

def extract_cpp_class(input_string):
pattern = r'<(.*?)>'
match = re.search(pattern, input_string)
assert match
return match.group(1)


def get_constructor_parameters(cc_file, class_name):
with open(cc_file, 'r') as file:
content = file.read()
pattern = rf'{class_name}\s*\((.*?)\)'
match = re.search(pattern, content, re.DOTALL)

if match:
parameters = match.group(1).strip()
return (True, parameters)
else:
return (False, "")

def matching(opening, closing):
return ((opening, closing) == ('(', ')') or
(opening, closing) == ('[', ']'))

def extract_feature_parameter_list(feature_name):
s = str(subprocess.run(["./../../builds/release/bin/downward",
"--help", "--txt2tags",
"{}".format(feature_name)],
stdout=subprocess.PIPE).stdout)
position = s.find(feature_name + "(")
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
assert position != -1
s = s[position + len(feature_name) + 1::] # start after the first '('
stack = ['(']
result = []
for c in s:
if c == '(' or c == "[":
stack.append(c)
elif c == ')' or c == "]":
assert matching(stack[-1], c)
stack.pop()
if not stack:
break
if len(stack) == 1: # not within nested parenthesis/brackets
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
result.append(c)
result = ''.join(result)
result = re.sub(r'=.*?,', ',', result + ",").split()
return result

def extract_feature_name_and_cpp_class(cc_file, cc_files, cwd, num):
source_without_comments = subprocess.check_output(
["gcc", "-fpreprocessed", "-dD", "-E", cc_file]).decode("utf-8")

name_pattern = r'TypedFeature\("([^"]*)"\)'
class_pattern = r'TypedFeature<(.*?)>'
SimonDold marked this conversation as resolved.
Show resolved Hide resolved

feature_names = []
class_names = []
other_namespaces = []
feature_error_msgs = []
class_error_msgs = []
for line in source_without_comments.splitlines():
if re.search(name_pattern, line):
feature_name = re.search(name_pattern, line).group(1)
feature_error_msg = "feature_name: " + feature_name + "\n"
feature_names.append(feature_name)
feature_error_msgs.append(feature_error_msg)

if re.search(class_pattern, line):
feature_class = re.search(class_pattern, line).group(1)
class_name = feature_class.split()[-1].split("::")[-1]
other_namespace = (len(feature_class.split()[-1].split("::"))
== 2)
class_error_msg = "class_name: " + class_name + "\n"
class_names.append(class_name)
other_namespaces.append(other_namespace)
class_error_msgs.append(class_error_msg)
return (feature_names[num], class_names[num], other_namespaces[num],
feature_error_msgs[num] + class_error_msgs[num])

def get_cpp_class_parameters(
class_name, other_namespace, cc_file, cc_files, cwd):
found_in_file, parameters = get_constructor_parameters(
cc_file, class_name)
if not found_in_file:
# check in all files
for cc_file2 in cc_files:
found_in_file, parameters = get_constructor_parameters(
cc_file2, class_name)
if found_in_file:
break

if found_in_file:
parameters = parameters.replace("\n", "") + ","
parameters = parameters.split()
parameters = [word for word in parameters if "," in word]
parameters = [re.sub(C_VAR_PATTERN, '', word) + ","
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
for word in parameters]
return parameters
else:
# assume default constructor
return [","]

def get_create_component_lines(cc_file):
source_without_comments = subprocess.check_output(
["gcc", "-fpreprocessed", "-dD", "-E", cc_file]).decode("utf-8")
lines = []
for line in source_without_comments.splitlines():
if re.search(CREATE_COMPONENT_REGEX, line):
lines.append(line.strip())
return lines

def compare_component_parameters(cc_file, cc_files, cwd):
found_error = False
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
error_msg = ""
create_component_lines = get_create_component_lines(cc_file)
if not create_component_lines == []:
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
for i, create_component_line in enumerate(
create_component_lines):
(feature_name, cpp_class, other_namespace,
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
extracted_error_msg) = (
extract_feature_name_and_cpp_class(
cc_file, cc_files, cwd, i))
error_msg += "\n\n=====================================\n"
error_msg += "= = = " + cpp_class + " = = =\n"
error_msg += extracted_error_msg + "\n"
feature_parameters = extract_feature_parameter_list(
feature_name)

error_msg += ("== FEATURE PARAMETERS '"
+ feature_name + "'==\n")
error_msg += str(feature_parameters) + "\n"

cpp_class_parameters = get_cpp_class_parameters(

cpp_class, other_namespace, cc_file, cc_files, cwd)

error_msg += "== CLASS PARAMETERS '" + cpp_class + "'==\n"
error_msg += str(cpp_class_parameters) + "\n"

if feature_name in SHORT_HANDS:
print(f"feature_name '{feature_name}' is ignored"
" because it is marked as shorthand")
elif feature_name in PERMANENT_EXCEPTIONS:
print(f"feature_name '{feature_name}' is ignored"
" because it is marked as PERMANENT_EXCEPTION")
elif feature_name in TEMPORARY_EXCEPTIONS:
print(f"feature_name '{feature_name}' is ignored"
" because it is marked as TEMPORARY_EXCEPTION")
elif feature_parameters != cpp_class_parameters:
found_error = True
if not len(feature_parameters) == len(cpp_class_parameters):
error_msg += "Wrong sizes\n"
for i in range(min(len(feature_parameters),
len(cpp_class_parameters))):
if feature_parameters[i] != cpp_class_parameters[i]:
error_msg += (feature_parameters[i] +
" =/= " + cpp_class_parameters[i] + "\n")
error_msg += cc_file + "\n"

return found_error, error_msg

def error_check(cc_files, cwd):
errors = []
for cc_file in cc_files:
found_error, error = compare_component_parameters(
cc_file, cc_files, cwd)
if found_error:
errors.append(error)
if errors:
print("#######################################################")
SimonDold marked this conversation as resolved.
Show resolved Hide resolved
print("#######################################################")
print("#######################################################")
print("#######################################################")
print("#######################################################")
print(".: ERRORS :.")
for error in errors:
print(error)
sys.exit(1)

def main():
"""
Currently, we only check that the parameters in the Constructor in
the .cc file matches the parameters for the CLI.
"""
search_dir = os.path.join(SRC_DIR, "search")
cc_files = get_src_files(search_dir, (".cc",))
assert len(cc_files) > 0
print("Checking Component Parameters of"
" {} *.cc files".format(len(cc_files)))
return error_check(cc_files, cwd=DIR) == 0


if __name__ == "__main__":
main()
7 changes: 6 additions & 1 deletion misc/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# the translator tests it is sufficient to build the 'translate' configuration.

[tox]
envlist = build, driver, translator, search, style, autodoc, clang-tidy
envlist = build, driver, translator, parameters, search, style, autodoc, clang-tidy
basepython = python3
skip_missing_interpreters = true
skipsdist = true
Expand Down Expand Up @@ -39,6 +39,11 @@ changedir = {toxinidir}/tests/
commands =
python test-translator.py benchmarks/ all

[testenv:parameters]
changedir = {toxinidir}/tests/
commands =
python test-parameters.py

[testenv:search]
changedir = {toxinidir}/tests/
deps =
Expand Down
1 change: 1 addition & 0 deletions src/search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ create_fast_downward_library(
utils/system_unix
utils/system_windows
utils/timer
utils/tuples
CORE_LIBRARY
)
# On Linux, find the rt library for clock_gettime().
Expand Down
53 changes: 34 additions & 19 deletions src/search/cartesian_abstractions/additive_cartesian_heuristic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,32 @@ using namespace std;

namespace cartesian_abstractions {
static vector<CartesianHeuristicFunction> generate_heuristic_functions(
const plugins::Options &opts, utils::LogProxy &log) {
const vector<shared_ptr<SubtaskGenerator>> &subtask_generators,
int max_states, int max_transitions, double max_time,
PickSplit pick, bool use_general_costs, int random_seed,
const shared_ptr<AbstractTask> &transform, utils::LogProxy &log) {
if (log.is_at_least_normal()) {
log << "Initializing additive Cartesian heuristic..." << endl;
}
vector<shared_ptr<SubtaskGenerator>> subtask_generators =
opts.get_list<shared_ptr<SubtaskGenerator>>("subtasks");
shared_ptr<utils::RandomNumberGenerator> rng =
utils::parse_rng_from_options(opts);
utils::get_rng(random_seed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not fit the '72 characters if possible' style guide
"Line width is 72 characters if possible, 80 characters max." - https://www.fast-downward.org/ForDevelopers/Whitespace?highlight=%2872%29

CostSaturation cost_saturation(
subtask_generators,
opts.get<int>("max_states"),
opts.get<int>("max_transitions"),
opts.get<double>("max_time"),
opts.get<bool>("use_general_costs"),
opts.get<PickSplit>("pick"),
*rng,
log);
return cost_saturation.generate_heuristic_functions(
opts.get<shared_ptr<AbstractTask>>("transform"));
subtask_generators, max_states, max_transitions, max_time, pick,
use_general_costs, *rng, log);
return cost_saturation.generate_heuristic_functions(transform);
}

AdditiveCartesianHeuristic::AdditiveCartesianHeuristic(
const plugins::Options &opts)
: Heuristic(opts),
heuristic_functions(generate_heuristic_functions(opts, log)) {
const vector<shared_ptr<SubtaskGenerator>> &subtasks,
int max_states, int max_transitions, double max_time,
PickSplit pick, bool use_general_costs, int random_seed,
const shared_ptr<AbstractTask> &transform, bool cache_estimates,
const string &description, utils::Verbosity verbosity)
: Heuristic(transform, cache_estimates, description, verbosity),
heuristic_functions(generate_heuristic_functions(
subtasks, max_states, max_transitions,
max_time, pick, use_general_costs,
random_seed, transform, log)) {
Comment on lines +43 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
subtasks, max_states, max_transitions,
max_time, pick, use_general_costs,
random_seed, transform, log)) {
subtasks, max_states, max_transitions, max_time, pick,
use_general_costs, random_seed, transform, log)) {

indent with 4 spaces

Copy link
Contributor Author

@SimonDold SimonDold Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree
but tox -e fix-style disagrees.

}

int AdditiveCartesianHeuristic::compute_heuristic(const State &ancestor_state) {
Expand Down Expand Up @@ -125,8 +126,8 @@ class AdditiveCartesianHeuristicFeature
"use_general_costs",
"allow negative costs in cost partitioning",
"true");
Heuristic::add_options_to_feature(*this);
utils::add_rng_options(*this);
utils::add_rng_options_to_feature(*this);
add_heuristic_options_to_feature(*this, "cegar");

document_language_support("action costs", "supported");
document_language_support("conditional effects", "not supported");
Expand All @@ -137,6 +138,20 @@ class AdditiveCartesianHeuristicFeature
document_property("safe", "yes");
document_property("preferred operators", "no");
}

virtual shared_ptr<AdditiveCartesianHeuristic> create_component(
const plugins::Options &opts,
const utils::Context &) const override {
return plugins::make_shared_from_arg_tuples<AdditiveCartesianHeuristic>(
opts.get_list<shared_ptr<SubtaskGenerator>>("subtasks"),
opts.get<int>("max_states"),
opts.get<int>("max_transitions"),
opts.get<double>("max_time"),
opts.get<PickSplit>("pick"),
opts.get<bool>("use_general_costs"),
utils::get_rng_arguments_from_options(opts),
get_heuristic_arguments_from_options(opts));
}
};

static plugins::FeaturePlugin<AdditiveCartesianHeuristicFeature> _plugin;
Expand Down
Loading
Loading