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

Add satisficing FDSS 2023 portfolio. #175

Merged
merged 13 commits into from
Oct 6, 2023
80 changes: 80 additions & 0 deletions driver/portfolios/seq_opt_fdss_2023.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""
This is the "Fast Downward Stone Soup 2023" sequential portfolio that
participated in the IPC 2023 optimal track.

Clemens Büchner, Remo Christen, Augusto Blaas Corrêa, Salomé Eriksson, Patrick Ferber, Jendrik Seipp and Silvan Sievers.
Fast Downward Stone Soup 2023.
In Tenth International Planning Competition (IPC 2023), Deterministic Part. 2023.
"""

SAS_FILE = "output.sas"
OPTIMAL = True

CONFIGS_STRIPS = [
# ipdb-60s-por
(542, ['--search', 'astar(ipdb(max_time=60), pruning=limited_pruning(pruning=atom_centric_stubborn_sets(), min_required_pruning_ratio=0.2))']),
# can-cegar-10s-por
(93, ['--search', 'astar(cpdbs(multiple_cegar(max_pdb_size=1000000,max_collection_size=10000000,pattern_generation_max_time=infinity,total_max_time=10,stagnation_limit=2.0,blacklist_trigger_percentage=0.75,enable_blacklist_on_stagnation=true,use_wildcard_plans=true)), pruning=limited_pruning(pruning=atom_centric_stubborn_sets(), min_required_pruning_ratio=0.2))']),
# mas-ssc-sbmiasm-300s-por
(213, ['--search', 'astar(merge_and_shrink(shrink_strategy=shrink_bisimulation(greedy=false), merge_strategy=merge_sccs(order_of_sccs=topological, merge_selector=score_based_filtering(scoring_functions=[sf_miasm(shrink_strategy=shrink_bisimulation(greedy=false),max_states=50000,threshold_before_merge=1),total_order(atomic_ts_order=reverse_level,product_ts_order=new_to_old,atomic_before_product=false)])), label_reduction=exact(before_shrinking=true, before_merging=false), max_states=50k, threshold_before_merge=1, main_loop_max_time=300), pruning=limited_pruning(pruning=atom_centric_stubborn_sets(), min_required_pruning_ratio=0.2))']),
# bjolp
(206, ['--search', 'let(lmc, landmark_cost_partitioning(lm_merged([lm_rhw(), lm_hm(m=1)])), astar(lmc,lazy_evaluator=lmc))']),
# seq-lmcut-por
(105, ['--search', 'astar(operatorcounting([state_equation_constraints(), lmcut_constraints()], lpsolver=cplex), pruning=limited_pruning(pruning=atom_centric_stubborn_sets(), min_required_pruning_ratio=0.2))']),
# potential-initial-state
(83, ['--search', 'astar(initial_state_potential())']),
# cartesian-cegar-landmarks-goals-60s-por
(96, ['--search', 'astar(cegar(subtasks=[landmarks(order=random), goals(order=random)], max_states=infinity, max_transitions=infinity, max_time=60), pruning=limited_pruning(pruning=atom_centric_stubborn_sets(), min_required_pruning_ratio=0.2))']),
# can-sys3
(218, ['--search', 'astar(cpdbs(patterns=systematic(3)))']),
# seq-lmcut-hplus-relaxed
(91, ['--search', 'astar(operatorcounting([state_equation_constraints(), lmcut_constraints(), delete_relaxation_constraints(use_time_vars=false, use_integer_vars=false)], lpsolver=cplex))']),
]

CONFIGS_COND_EFFS = [
# mas-ssc-dfp-60s
(1137, ['--search', 'astar(merge_and_shrink(shrink_strategy=shrink_bisimulation(greedy=false), merge_strategy=merge_sccs(order_of_sccs=topological, merge_selector=score_based_filtering(scoring_functions=[goal_relevance(), dfp(), total_order(atomic_ts_order=reverse_level,product_ts_order=new_to_old,atomic_before_product=false)])), label_reduction=exact(before_shrinking=true, before_merging=false), max_states=50k, threshold_before_merge=1, main_loop_max_time=60))']),
# mas-ssc-sbmiasm-300s
(346, ['--search', 'astar(merge_and_shrink(shrink_strategy=shrink_bisimulation(greedy=false), merge_strategy=merge_sccs(order_of_sccs=topological, merge_selector=score_based_filtering(scoring_functions=[sf_miasm(shrink_strategy=shrink_bisimulation(greedy=false),max_states=50000,threshold_before_merge=1),total_order(atomic_ts_order=reverse_level,product_ts_order=new_to_old,atomic_before_product=false)])), label_reduction=exact(before_shrinking=true, before_merging=false), max_states=50k, threshold_before_merge=1, main_loop_max_time=300))']),
# hmax
(229, ['--search', 'astar(hmax())']),
]

CONFIGS_AXIOMS = [
(1800, ['--search', 'astar(blind())']),
]


def get_pddl_features(task):
has_axioms = False
has_conditional_effects = False
with open(task) as f:
in_op = False
for line in f:
line = line.strip()
if line == "begin_rule":
has_axioms = True

if line == "begin_operator":
in_op = True
next(f) # Skip line with operator name.
elif line == "end_operator":
in_op = False
elif in_op:
parts = line.split()
if len(parts) >= 6 and all(p.lstrip('-').isdigit() for p in parts):
jendrikseipp marked this conversation as resolved.
Show resolved Hide resolved
has_conditional_effects = True
return has_axioms, has_conditional_effects


HAS_AXIOMS, HAS_CONDITIONAL_EFFECTS = get_pddl_features(SAS_FILE)

print(f"Task has axioms: {HAS_AXIOMS}")
print(f"Task has conditional effects: {HAS_CONDITIONAL_EFFECTS}")

if HAS_AXIOMS:
CONFIGS = CONFIGS_AXIOMS
elif HAS_CONDITIONAL_EFFECTS:
CONFIGS = CONFIGS_COND_EFFS
else:
CONFIGS = CONFIGS_STRIPS
65 changes: 65 additions & 0 deletions driver/portfolios/seq_sat_fdss_2023.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""
This is the "Fast Downward Stone Soup 2023" sequential portfolio that
participated in the IPC 2023 agile and satisficing tracks.

Clemens Büchner, Remo Christen, Augusto Blaas Corrêa, Salomé Eriksson, Patrick Ferber, Jendrik Seipp and Silvan Sievers.
Fast Downward Stone Soup 2023.
In Tenth International Planning Competition (IPC 2023), Deterministic Part. 2023.
"""

OPTIMAL = False

CONFIGS = [
# fdss-2018-01
(383, ['--search', 'let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one)),let(hff, ff(transform=adapt_costs(one)),lazy(alt([single(hff),single(hff,pref_only=true),single(hlm),single(hlm,pref_only=true),type_based([hff,g()])],boost=1000),preferred=[hff,hlm],cost_type=one,reopen_closed=false,randomize_successors=true,preferred_successors_first=false,bound=BOUND, verbosity=silent)))']),
# fdss-2018-03
(57, ['--search', 'let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one)),let(hff, ff(transform=adapt_costs(one)),lazy(alt([single(hff),single(hff,pref_only=true),single(hlm),single(hlm,pref_only=true)],boost=1000),preferred=[hff,hlm],cost_type=one,reopen_closed=false,randomize_successors=false,preferred_successors_first=true,bound=BOUND, verbosity=silent)))']),
# lazy_hff_hlm-epsilon-greedy_pref_ops-no-reasonable-orders
(60, ['--search', 'let(hlm, landmark_sum(lm_rhw(), pref=true, transform=adapt_costs(one)),let(hff, ff(transform=adapt_costs(one)),lazy(alt([single(hff),single(hff,pref_only=true),epsilon_greedy(hlm),single(hlm,pref_only=true)],boost=1000),preferred=[hff,hlm],cost_type=one,reopen_closed=false,randomize_successors=true, bound=BOUND, verbosity=silent)))']),
# fdss-2014-01
(22, ['--search', 'let(hadd, add(transform=adapt_costs(one)),let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(plusone)),lazy_greedy([hadd,hlm],preferred=[hadd,hlm],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2018-04
(30, ['--search', 'let(hff, ff(transform=adapt_costs(one)),let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one)),eager_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2014-08
(206, ['--search', 'let(hff, ff(transform=adapt_costs(one)),let(hadd, add(transform=adapt_costs(one)),lazy_greedy([hadd,hff],preferred=[hadd,hff],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2014-03
(30, ['--search', 'let(hadd, add(transform=adapt_costs(one)),let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(plusone)),eager_greedy([hadd,hlm],preferred=[hadd,hlm],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2018-07
(21, ['--search', 'let(hcea, cea(transform=adapt_costs(one)),let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one)),lazy_greedy([hcea,hlm],preferred=[hcea,hlm],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2018-09
(59, ['--search', 'let(hff, ff(transform=adapt_costs(one)),lazy(alt([single(sum([g(),weight(hff,10)])),single(sum([g(),weight(hff,10)]),pref_only=true)],boost=2000),preferred=[hff],reopen_closed=false,cost_type=one,bound=BOUND, verbosity=silent))']),
# fdss-2014-11
(89, ['--search', 'let(hff, ff(transform=adapt_costs(one)),let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(plusone)),lazy_wastar([hff,hlm],w=3,preferred=[hff,hlm],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2018-14
(29, ['--search', 'let(hgoalcount, goalcount(transform=adapt_costs(plusone)),let(hff, ff(),lazy(alt([single(sum([g(),weight(hff,10)])),single(sum([g(),weight(hff,10)]),pref_only=true),single(sum([g(),weight(hgoalcount,10)])),single(sum([g(),weight(hgoalcount,10)]),pref_only=true)],boost=2000),preferred=[hff,hgoalcount],reopen_closed=false,cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-1-03
(53, ['--search', 'let(hcea, cea(transform=adapt_costs(one)),let(hcg, cg(transform=adapt_costs(one)),lazy_greedy([hcea,hcg],preferred=[hcea,hcg],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2014-16
(19, ['--search', 'let(hcg, cg(transform=adapt_costs(one)),let(hff, ff(transform=adapt_costs(one)),lazy_wastar([hcg,hff],w=3,preferred=[hcg,hff],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2018-18
(177, ['--search', 'let(hcg, cg(transform=adapt_costs(plusone)),lazy(alt([type_based([g()]),single(hcg),single(hcg,pref_only=true)],boost=0),preferred=[hcg],reopen_closed=true,cost_type=plusone,bound=BOUND, verbosity=silent))']),
# fdss-2014-13
(30, ['--search', 'let(hcg, cg(transform=adapt_costs(one)),let(hlm, landmark_sum(lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(plusone)),eager_greedy([hcg,hlm],preferred=[hcg,hlm],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2014-18
(30, ['--search', 'let(hadd, add(transform=adapt_costs(one)),eager(alt([single(sum([g(), weight(hadd, 3)])),single(sum([g(), weight(hadd,3)]),pref_only=true)]),preferred=[hadd],cost_type=one,bound=BOUND, verbosity=silent))']),
# fdss-1-11
(26, ['--search', 'let(h, cea(transform=adapt_costs(one)),eager_greedy([h],preferred=[h],cost_type=one,bound=BOUND, verbosity=silent))']),
# fdss-2014-19
(27, ['--search', 'let(hff, ff(transform=adapt_costs(one)),let(hcea, cea(transform=adapt_costs(one)),eager(alt([single(sum([g(),weight(hff,3)])),single(sum([g(),weight(hff,3)]),pref_only=true),single(sum([g(),weight(hcea,3)])),single(sum([g(),weight(hcea,3)]),pref_only=true)]),preferred=[hff,hcea],cost_type=one,bound=BOUND, verbosity=silent)))']),
# fdss-2018-02
(18, ['--search', 'let(lmg, lm_rhw(only_causal_landmarks=false,disjunctive_landmarks=true,use_orders=false),let(hlm, landmark_cost_partitioning(lmg,transform=adapt_costs(one)),let(hff, ff(transform=adapt_costs(one)),lazy(alt([type_based([g()]),single(hlm),single(hlm,pref_only=true),single(hff),single(hff,pref_only=true)],boost=0),preferred=[hlm],reopen_closed=false,cost_type=plusone,bound=BOUND, verbosity=silent))))']),
# fdss-2018-16
(29, ['--search', 'let(lmg, lm_rhw(only_causal_landmarks=false,disjunctive_landmarks=false,use_orders=true),let(hlm, landmark_sum(lmg,transform=adapt_costs(one)),let(hff, ff(transform=adapt_costs(one)),let(hblind, blind(),lazy(alt([type_based([g()]),single(sum([g(),weight(hblind,2)])),single(sum([g(),weight(hblind,2)]),pref_only=true),single(sum([g(),weight(hlm,2)])),single(sum([g(),weight(hlm,2)]),pref_only=true),single(sum([g(),weight(hff,2)])),single(sum([g(),weight(hff,2)]),pref_only=true)],boost=4419),preferred=[hlm],reopen_closed=true,cost_type=one,bound=BOUND, verbosity=silent)))))']),
# fdss-2018-29
(90, ['--search', 'let(hadd, add(transform=adapt_costs(plusone)),let(hff, ff(),lazy(alt([tiebreaking([sum([weight(g(),4),weight(hff,5)]),hff]),tiebreaking([sum([weight(g(),4),weight(hff,5)]),hff],pref_only=true),tiebreaking([sum([weight(g(),4),weight(hadd,5)]),hadd]),tiebreaking([sum([weight(g(),4),weight(hadd,5)]),hadd],pref_only=true)],boost=2537),preferred=[hff,hadd],reopen_closed=true,bound=BOUND, verbosity=silent)))']),
# fdss-2018-31
(28, ['--search', 'let(hff, ff(transform=adapt_costs(one)),lazy(alt([single(sum([weight(g(),2),weight(hff,3)])),single(sum([weight(g(),2),weight(hff,3)]),pref_only=true)],boost=5000),preferred=[hff],reopen_closed=true,cost_type=one,bound=BOUND, verbosity=silent))']),
# fdss-2018-28
(29, ['--search', 'let(hblind, blind(),let(hadd, add(),let(hcg, cg(transform=adapt_costs(one)),let(hhmax, hmax(),eager(alt([tiebreaking([sum([g(),weight(hblind,7)]),hblind]),tiebreaking([sum([g(),weight(hhmax,7)]),hhmax]),tiebreaking([sum([g(),weight(hadd,7)]),hadd]),tiebreaking([sum([g(),weight(hcg,7)]),hcg])],boost=2142),preferred=[],reopen_closed=true,bound=BOUND, verbosity=silent)))))']),
# fdss-2018-35
(85, ['--search', 'let(lmg, lm_hm(conjunctive_landmarks=false,use_orders=false,m=1),let(hcg, cg(transform=adapt_costs(one)),let(hlm, landmark_cost_partitioning(lmg),lazy(alt([single(hlm),single(hlm,pref_only=true),single(hcg),single(hcg,pref_only=true)],boost=0),preferred=[hcg],reopen_closed=false,cost_type=one,bound=BOUND, verbosity=silent))))']),
# fdss-2018-27
(30, ['--search', 'let(lmg, lm_reasonable_orders_hps(lm_rhw(only_causal_landmarks=true,disjunctive_landmarks=true,use_orders=true)),let(hblind, blind(),let(hadd, add(),let(hlm, landmark_sum(lmg,pref=true,transform=adapt_costs(plusone)),let(hff, ff(),lazy(alt([single(sum([weight(g(),2),weight(hblind,3)])),single(sum([weight(g(),2),weight(hblind,3)]),pref_only=true),single(sum([weight(g(),2),weight(hff,3)])),single(sum([weight(g(),2),weight(hff,3)]),pref_only=true),single(sum([weight(g(),2),weight(hlm,3)])),single(sum([weight(g(),2),weight(hlm,3)]),pref_only=true),single(sum([weight(g(),2),weight(hadd,3)])),single(sum([weight(g(),2),weight(hadd,3)]),pref_only=true)],boost=2474),preferred=[hadd],reopen_closed=false,cost_type=one,bound=BOUND, verbosity=silent))))))']),
# fdss-2018-39
(59, ['--search', 'let(lmg, lm_exhaust(only_causal_landmarks=false),let(hgoalcount, goalcount(transform=adapt_costs(plusone)),let(hlm, landmark_sum(lmg),let(hff, ff(),let(hblind, blind(),eager(alt([tiebreaking([sum([weight(g(),8),weight(hblind,9)]),hblind]),tiebreaking([sum([weight(g(),8),weight(hlm,9)]),hlm]),tiebreaking([sum([weight(g(),8),weight(hff,9)]),hff]),tiebreaking([sum([weight(g(),8),weight(hgoalcount,9)]),hgoalcount])],boost=2005),preferred=[],reopen_closed=true,bound=BOUND, verbosity=silent))))))']),
]
36 changes: 27 additions & 9 deletions driver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,27 @@ def translate():
"misc/tests/benchmarks/gripper/prob01.pddl"]
subprocess.check_call(cmd, cwd=REPO_ROOT_DIR)

# We need to translate the example task when this module is imported to have the
# SAS+ file ready for the @pytest.parametrize function below. Translating the
# task in setup_module() does not work here, because the @pytest.parametrize
# decorator is executed before setup_module() is called. An alternative would be
# to use a conftest.py file and call translate() in a pytest_sessionstart()
# function, but that adds another file and leads to dumping the translator
# output to the terminal.
translate()
jendrikseipp marked this conversation as resolved.
Show resolved Hide resolved


def cleanup():
subprocess.check_call([sys.executable, "fast-downward.py", "--cleanup"],
cwd=REPO_ROOT_DIR)


def run_driver(parameters):
def teardown_module(module):
cleanup()
translate()
cmd = [sys.executable, "fast-downward.py"] + parameters


def run_driver(parameters):
cmd = [sys.executable, "fast-downward.py", "--keep"] + parameters
return subprocess.check_call(cmd, cwd=REPO_ROOT_DIR)


Expand Down Expand Up @@ -72,16 +83,19 @@ def _get_portfolio_configs(portfolio: Path):
traceback.print_exc()
raise SyntaxError(
f"The portfolio {portfolio} could not be loaded.")
if "CONFIGS" not in attributes:
raise ValueError("portfolios must define CONFIGS")
return [config for _, config in attributes["CONFIGS"]]
for key, value in attributes.items():
# The optimal FDSS 2023 portfolio defines different configs for different PDDL subsets.
if key.startswith("CONFIGS"):
for _, config in value:
yield config


def _convert_to_standalone_config(config):
replacements = [
("H_COST_TRANSFORM", "no_transform()"),
("S_COST_TYPE", "normal"),
("BOUND", "infinity"),
("lpsolver=cplex", "lpsolver=soplex"), # CPLEX is not available in all CI runners.
jendrikseipp marked this conversation as resolved.
Show resolved Hide resolved
]
for index, part in enumerate(config):
for before, after in replacements:
Expand All @@ -97,13 +111,17 @@ def _run_search(config):
stdin="output.sas")


def test_portfolio_configs():
def _get_all_portfolio_configs():
all_configs = set()
for portfolio in PORTFOLIOS.values():
configs = _get_portfolio_configs(Path(portfolio))
all_configs |= set(tuple(_convert_to_standalone_config(config)) for config in configs)
for config in all_configs:
_run_search(config)
return all_configs


@pytest.mark.parametrize("config", _get_all_portfolio_configs())
def test_portfolio_config(config):
_run_search(config)


@pytest.mark.skipif(not limits.can_set_time_limit(), reason="Cannot set time limits on this system")
Expand Down