From 1458d9340827f25ff727360b7de4844385cc6875 Mon Sep 17 00:00:00 2001 From: mgebser Date: Mon, 16 Jan 2017 17:15:19 +0100 Subject: [PATCH 1/7] more parallel ''exists'' encoding variants --- encodings/strips/README.md | 14 +++++++++++- encodings/strips/redundancy.lp | 16 ++++++++----- encodings/strips/strips-incremental.lp | 31 ++++++++++++++++++-------- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/encodings/strips/README.md b/encodings/strips/README.md index 037ce05..9e633b5 100644 --- a/encodings/strips/README.md +++ b/encodings/strips/README.md @@ -17,11 +17,13 @@ The included encoding files provide the following functionalities: * Parameters: `_parallel` (default value: `0`) * Value `1`: “forall” parallel actions that can be arranged in any sequence * Value `2`: “exists” parallel actions that can be arranged in some sequence + * Value `3`: “exists“ parallel actions omitting achievement of preconditions + * Value `4`: “exists“ parallel actions like `3` implemented by acyclicity * Otherwise: sequential actions ### [redundancy.lp](redundancy.lp): enforcement of ‘redundant’ actions to constrain parallel plans * Remarks: - * Only relevant together with parallel actions + * Only relevant together with parallel actions not implemented by acyclicity * Encoded constraints seem rather ineffective though * Heavy space overhead in combination with “exists” parallel actions @@ -44,13 +46,23 @@ plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instan plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=2 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=3 + +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=4 + plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=1 redundancy.lp plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=2 redundancy.lp +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=3 redundancy.lp + plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=2 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) + +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=3 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) + +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=4 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) ``` diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp index ef67f92..0efc8fe 100644 --- a/encodings/strips/redundancy.lp +++ b/encodings/strips/redundancy.lp @@ -1,8 +1,9 @@ % Additional rules for enforcing the inclusion of parallel actions in plans, % whenever such 'redundant' actions are compatible with states and other actions -compatible(A,A1) :- active(A), active(A1), A != A1, _parallel = 2, - not diverge(A,A1), not diverge(A1,A). +compatible(A,A1) :- active(A), active(A1), A != A1, 1 < _parallel, _parallel < 4, + not diverge(A,A1), not diverge(A1,A), + not exclude(A,A1), not exclude(A1,A). compatible(A) :- compatible(A,A1). disable(A,A1,A2) :- disable(A1,A2), compatible(A,A1), compatible(A,A2). @@ -12,22 +13,25 @@ disabled(A,A2) :- disable(A,A2). #program step(t). defeated(A,t) :- active(A), postcondition(A,X,V), fluent(X), not holds(X,V,t), - _parallel = 1 : _parallel != 2. + 1 < _parallel, _parallel < 4. defeated(A,t) :- _parallel = 1, active(A), precondition(A,X,V), not holds(X,V,t-1). defeated(A,t) :- _parallel = 1, active(A), precondition(A,X,V), not holds(X,V,t). defeated(A,t) :- _parallel = 1, active(A), postcondition(A,X,V), not precondition(A,X,V), single(X,t). +defeated(A,t) :- _parallel = 3, active(A), precondition(A,X,V), not holds(X,V,t-1). + proceed(A,X,V,t) :- compatible(A), holds(X,V,t-1), scope(X,V). proceed(A,X,V,t) :- compatible(A,A1), occurs(A1,t), perform(A,A1,t), postcondition(A1,X,V), scope(X,V), not precondition(A1,X,V). perform(A,A1,t) :- disabled(A,A1), not occurs(A1,t). perform(A,A1,t) :- compatible(A,A1), - proceed(A,X,V,t) : precondition(A1,X,V); perform(A,A2,t) : disable(A,A1,A2). + proceed(A,X,V,t) : precondition(A1,X,V), _parallel = 2; + perform(A,A2,t) : disable(A,A1,A2). -defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t). +defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t), _parallel = 2. defeated(A,t) :- compatible(A), disable(A,A2), not perform(A,A2,t). -:- active(A), not occurs(A,t), not defeated(A,t), _parallel = 1 : _parallel != 2. +:- active(A), not occurs(A,t), not defeated(A,t), 1 < _parallel, _parallel < 4. diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index 8f26060..18ef678 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -1,6 +1,8 @@ % Constant '_parallel' to enable parallel actions % - value '1': "forall" parallel actions that can be arranged in any sequence % - value '2': "exists" parallel actions that can be arranged in some sequence +% - value '3': "exists" parallel actions omitting achievement of preconditions +% - value '4': "exists" parallel actions like '3' implemented by acyclicity % - otherwise: sequential actions #const _parallel = 0. @@ -13,15 +15,20 @@ diverge(A1,A2,X) :- active(A1), active(A2), A1 < A2, postcondition(A1,X,V), has_condition(A2,X,1), not postcondition(A2,X,V), - _parallel = 1 : _parallel != 2. + 0 < _parallel, _parallel < 5. diverge(A1,A2) :- diverge(A1,A2,X). -exclude(A1,A2) :- diverge(A1,A2), precondition(A1,X,V), _parallel = 1, +exclude(A1,A2) :- diverge(A1,A2), precondition(A1,X,V), _parallel != 2, has_condition(A2,X,0), not precondition(A2,X,V). disable(A1,A2) :- active(A1), active(A2), A1 != A2, postcondition(A1,X,V), has_condition(A2,X,0), not precondition(A2,X,V), - _parallel = 2, not diverge(A1,A2), not diverge(A2,A1). + not diverge(A1,A2), not diverge(A2,A1), + not exclude(A1,A2), not exclude(A2,A1), + 1 < _parallel, _parallel < 5. + +disable :- #sum{ 1,A1 : disable(A1,A2), _parallel = 4; + -1,A2 : disable(A1,A2), _parallel = 4 } > 0. scope(X,V) :- active(A), precondition(A,X,V), _parallel = 2. @@ -60,7 +67,9 @@ change(X,t) :- holds(X,V,t-1), not holds(X,V,t). % Generate actions -1 {occurs(A,t) : active(A)}. +{occurs(A,t) : active(A)}. + +:- not occurs(A,t) : active(A). :- occurs(A,t), postcondition(A,X,V), fluent(X), not holds(X,V,t). @@ -70,7 +79,7 @@ effect(X,t) :- occurs(A,t), postcondition(A,X,V), fluent(X), not precondition(A, % Checks w.r.t. parallel mode -:- _parallel != 1, _parallel != 2, #count{A : occurs(A,t)} > 1. +:- _parallel != 1, _parallel != 2, _parallel != 3, _parallel != 4, #count{A : occurs(A,t)} > 1. :- _parallel != 2, occurs(A,t), precondition(A,X,V), not holds(X,V,t-1). @@ -85,11 +94,15 @@ proceed(X,V,t) :- holds(X,V,t-1), scope(X,V). proceed(X,V,t) :- occurs(A,t), postcondition(A,X,V), scope(X,V), not precondition(A,X,V), perform(A,t). -perform(A1,t) :- active(A1), _parallel = 2, not occurs(A1,t). -perform(A1,t) :- active(A1), _parallel = 2, - proceed(X,V,t) : precondition(A1,X,V); perform(A2,t) : disable(A1,A2). +perform(A1,t) :- active(A1), 1 < _parallel, _parallel < 4, not occurs(A1,t). +perform(A1,t) :- active(A1), 1 < _parallel, _parallel < 4, + proceed(X,V,t) : precondition(A1,X,V), _parallel = 2; + perform(A2,t) : disable(A1,A2). -:- _parallel = 2, active(A), not perform(A,t). +:- 1 < _parallel, _parallel < 4, active(A), not perform(A,t). + +#edge((A1,t),(A2,t)) : occurs(A1,t), disable(A1,A2), _parallel = 4, not disable. +#edge((A1,t),(A2,t)) : occurs(A2,t), disable(A1,A2), disable. % CHECK PROGRAM From 664762fdec28a8e4e76ce346ef780f88e11d9d29 Mon Sep 17 00:00:00 2001 From: gebser Date: Tue, 17 Jan 2017 10:12:37 +0100 Subject: [PATCH 2/7] about to revise encodings --- encodings/strips/preprocess.lp | 2 ++ encodings/strips/redundancy.lp | 20 ++++++++++++++------ encodings/strips/strips-incremental.lp | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/encodings/strips/preprocess.lp b/encodings/strips/preprocess.lp index bd60246..8b8f5e6 100644 --- a/encodings/strips/preprocess.lp +++ b/encodings/strips/preprocess.lp @@ -6,6 +6,8 @@ #const _closure = 3. +% BASE PROGRAM + % Check feature requirements :- requires(feature(actionCosts)). diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp index 0efc8fe..5c5649d 100644 --- a/encodings/strips/redundancy.lp +++ b/encodings/strips/redundancy.lp @@ -1,6 +1,12 @@ % Additional rules for enforcing the inclusion of parallel actions in plans, % whenever such 'redundant' actions are compatible with states and other actions +% BASE PROGRAM + +selfdefeat(A) :- _parallel = 1, active(A), precondition(A,X,V), has_condition(A,X,1), + not postcondition(A,X,V). +forall(A) :- _parallel = 1, active(A), not selfdefeat(A). + compatible(A,A1) :- active(A), active(A1), A != A1, 1 < _parallel, _parallel < 4, not diverge(A,A1), not diverge(A1,A), not exclude(A,A1), not exclude(A1,A). @@ -10,15 +16,16 @@ disable(A,A1,A2) :- disable(A1,A2), compatible(A,A1), compatible(A,A2). disabled(A,A2) :- disable(A,A1,A2). disabled(A,A2) :- disable(A,A2). +% CHECK PROGRAM + #program step(t). defeated(A,t) :- active(A), postcondition(A,X,V), fluent(X), not holds(X,V,t), - 1 < _parallel, _parallel < 4. + not selfdefeat(A), 0 < _parallel, _parallel < 4. -defeated(A,t) :- _parallel = 1, active(A), precondition(A,X,V), not holds(X,V,t-1). -defeated(A,t) :- _parallel = 1, active(A), precondition(A,X,V), not holds(X,V,t). -defeated(A,t) :- _parallel = 1, active(A), postcondition(A,X,V), not precondition(A,X,V), - single(X,t). +defeated(A,t) :- forall(A), precondition(A,X,V), not holds(X,V,t-1). +defeated(A,t) :- forall(A), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t). +defeated(A,t) :- forall(A), postcondition(A,X,V), not has_condition(A,X,0), single(X,t). defeated(A,t) :- _parallel = 3, active(A), precondition(A,X,V), not holds(X,V,t-1). @@ -34,4 +41,5 @@ perform(A,A1,t) :- compatible(A,A1), defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t), _parallel = 2. defeated(A,t) :- compatible(A), disable(A,A2), not perform(A,A2,t). -:- active(A), not occurs(A,t), not defeated(A,t), 1 < _parallel, _parallel < 4. +:- active(A), not selfdefeat(A), not occurs(A,t), not defeated(A,t), + 0 < _parallel, _parallel < 4. diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index 18ef678..c9c816a 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -101,8 +101,8 @@ perform(A1,t) :- active(A1), 1 < _parallel, _parallel < 4, :- 1 < _parallel, _parallel < 4, active(A), not perform(A,t). -#edge((A1,t),(A2,t)) : occurs(A1,t), disable(A1,A2), _parallel = 4, not disable. -#edge((A1,t),(A2,t)) : occurs(A2,t), disable(A1,A2), disable. +#edge((A1,t),(A2,t)) : disable(A1,A2), occurs(A1,t), _parallel = 4, not disable. +#edge((A1,t),(A2,t)) : disable(A1,A2), occurs(A2,t), disable. % CHECK PROGRAM From 18f4a87dd79f6fd992f68319c5840e0419c90cd4 Mon Sep 17 00:00:00 2001 From: mgebser Date: Tue, 17 Jan 2017 13:31:34 +0100 Subject: [PATCH 3/7] slight modification --- encodings/strips/strips-incremental.lp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index c9c816a..e0d8a04 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -13,12 +13,15 @@ % Define auxiliary predicates for actions w.r.t. parallel mode +selfdefeat(A,X) :- active(A), precondition(A,X,V), has_condition(A,X,1), _parallel = 1, + not postcondition(A,X,V). + diverge(A1,A2,X) :- active(A1), active(A2), A1 < A2, postcondition(A1,X,V), has_condition(A2,X,1), not postcondition(A2,X,V), 0 < _parallel, _parallel < 5. diverge(A1,A2) :- diverge(A1,A2,X). -exclude(A1,A2) :- diverge(A1,A2), precondition(A1,X,V), _parallel != 2, +exclude(A1,A2) :- precondition(A1,X,V), 0 < _parallel, _parallel < 5, _parallel != 2, has_condition(A2,X,0), not precondition(A2,X,V). disable(A1,A2) :- active(A1), active(A2), A1 != A2, postcondition(A1,X,V), @@ -85,8 +88,7 @@ effect(X,t) :- occurs(A,t), postcondition(A,X,V), fluent(X), not precondition(A, :- _parallel = 1, occurs(A,t), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t). -single(X,t) :- occurs(A,t), precondition(A,X,V), _parallel = 1, - has_condition(A,X,1), not postcondition(A,X,V). +single(X,t) :- occurs(A,t), selfdefeat(A,X). :- single(X,t), #count{A : occurs(A,t), postcondition(A,X,V), not precondition(A,X,V)} > 1. From 59e95c7097d3bd63c633e098afc348c7e92dcb4a Mon Sep 17 00:00:00 2001 From: mgebser Date: Tue, 17 Jan 2017 17:15:21 +0100 Subject: [PATCH 4/7] some refactoring --- encodings/strips/README.md | 41 +++++++++++++----------- encodings/strips/incmode.lp | 3 ++ encodings/strips/redundancy.lp | 43 +++++++++++++------------- encodings/strips/strips-incremental.lp | 24 ++++++++------ 4 files changed, 61 insertions(+), 50 deletions(-) create mode 100644 encodings/strips/incmode.lp diff --git a/encodings/strips/README.md b/encodings/strips/README.md index 9e633b5..2d3dbb7 100644 --- a/encodings/strips/README.md +++ b/encodings/strips/README.md @@ -5,21 +5,26 @@ The included encoding files provide the following functionalities: ## Encodings +### [incmode.lp](incmode.lp): include built-in “iclingo“ script for incremental grounding and solving + ### [preprocess.lp](preprocess.lp): static analysis of potentially relevant actions -* Parameters: `_closure` (default value: `3`) +* Parameter: `_closure` (default value: `3`) * Value `1`: forward chaining of effects w.r.t. initial variable values * Value `2`: backward regression of effects w.r.t. goal variable values * Value `3`: both forward chaining and backward regression of effects * Otherwise: off (simply take all actions as given) ### [strips-incremental.lp](strips-incremental.lp): sequential and parallel planning encoding variants -* Parameters: `_parallel` (default value: `0`) +* Parameter: `_parallel` (default value: `0`) * Value `1`: “forall” parallel actions that can be arranged in any sequence * Value `2`: “exists” parallel actions that can be arranged in some sequence * Value `3`: “exists“ parallel actions omitting achievement of preconditions * Value `4`: “exists“ parallel actions like `3` implemented by acyclicity * Otherwise: sequential actions +* Parameter: `planner_on` (default value: `0`) + * Value `0`: no compatibility to ASP-based planner (no idle steps permitted) + * Otherwise: compatibility to ASP-based planner (idle steps permitted) ### [redundancy.lp](redundancy.lp): enforcement of ‘redundant’ actions to constrain parallel plans * Remarks: @@ -34,35 +39,35 @@ The included encoding files provide the following functionalities: Some example invocations (using `clingo` 5.1.0) are as follows: ```bash -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _closure=0 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _closure=0 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _closure=1 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _closure=1 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _closure=2 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _closure=2 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=1 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=1 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=2 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=2 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=3 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=3 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=4 +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=4 -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=1 redundancy.lp +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=1 redundancy.lp -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=2 redundancy.lp +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=2 redundancy.lp -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp -c _parallel=3 redundancy.lp +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=3 redundancy.lp -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=2 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=2 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=3 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=3 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) -plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - preprocess.lp strips-incremental.lp --outf=1 -c _parallel=4 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) +plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=4 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl) ``` diff --git a/encodings/strips/incmode.lp b/encodings/strips/incmode.lp new file mode 100644 index 0000000..e0a8e6b --- /dev/null +++ b/encodings/strips/incmode.lp @@ -0,0 +1,3 @@ +% Include built-in "iclingo" script for incremental grounding and solving + +#include . diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp index 5c5649d..7d420ce 100644 --- a/encodings/strips/redundancy.lp +++ b/encodings/strips/redundancy.lp @@ -3,43 +3,42 @@ % BASE PROGRAM -selfdefeat(A) :- _parallel = 1, active(A), precondition(A,X,V), has_condition(A,X,1), - not postcondition(A,X,V). -forall(A) :- _parallel = 1, active(A), not selfdefeat(A). +selfdefeat(A) :- selfdefeat(A,X). +disjoin(A,A1) :- active(A), has_condition(A,X,P), selfdefeat(A1,X), not selfdefeat(A). compatible(A,A1) :- active(A), active(A1), A != A1, 1 < _parallel, _parallel < 4, - not diverge(A,A1), not diverge(A1,A), - not exclude(A,A1), not exclude(A1,A). + not diverge(A,A1), not exclude(A,A1), not disable(A,A1) : disable(A1,A). compatible(A) :- compatible(A,A1). +compatible(A) :- active(A), active(A1), A != A1, _parallel = 1, not selfdefeat(A), + not diverge(A,A1), not exclude(A,A1), not disjoin(A,A1). -disable(A,A1,A2) :- disable(A1,A2), compatible(A,A1), compatible(A,A2). -disabled(A,A2) :- disable(A,A1,A2). -disabled(A,A2) :- disable(A,A2). +disable(A,A1,A2) :- compatible(A,A1), compatible(A,A2), not disable(A1,A), + disable(A1,A2), not disable(A2,A1). -% CHECK PROGRAM +disabled(A,A2) :- disable(A,A1,A2). +disabled(A,A2) :- disable(A,A2). + +% STEP PROGRAM #program step(t). -defeated(A,t) :- active(A), postcondition(A,X,V), fluent(X), not holds(X,V,t), - not selfdefeat(A), 0 < _parallel, _parallel < 4. +defeated(A,t) :- compatible(A), postcondition(A,X,V), fluent(X), not holds(X,V,t). -defeated(A,t) :- forall(A), precondition(A,X,V), not holds(X,V,t-1). -defeated(A,t) :- forall(A), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t). -defeated(A,t) :- forall(A), postcondition(A,X,V), not has_condition(A,X,0), single(X,t). - -defeated(A,t) :- _parallel = 3, active(A), precondition(A,X,V), not holds(X,V,t-1). +defeated(A,t) :- compatible(A), precondition(A,X,V), not holds(X,V,t-1), _parallel != 2. +defeated(A,t) :- compatible(A), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t), + _parallel = 1. +defeated(A,t) :- compatible(A), has_condition(A,X,1), not has_condition(A,X,0), single(X,t). proceed(A,X,V,t) :- compatible(A), holds(X,V,t-1), scope(X,V). -proceed(A,X,V,t) :- compatible(A,A1), occurs(A1,t), perform(A,A1,t), - postcondition(A1,X,V), scope(X,V), not precondition(A1,X,V). +proceed(A,X,V,t) :- compatible(A,A1), not disable(A1,A), perform(A,A1,t), occurs(A1,t), + scope(X,V), postcondition(A1,X,V), not precondition(A1,X,V). perform(A,A1,t) :- disabled(A,A1), not occurs(A1,t). -perform(A,A1,t) :- compatible(A,A1), +perform(A,A1,t) :- compatible(A,A1), not disable(A1,A), proceed(A,X,V,t) : precondition(A1,X,V), _parallel = 2; perform(A,A2,t) : disable(A,A1,A2). defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t), _parallel = 2. -defeated(A,t) :- compatible(A), disable(A,A2), not perform(A,A2,t). +defeated(A,t) :- compatible(A), disable(A,A1), not perform(A,A1,t). -:- active(A), not selfdefeat(A), not occurs(A,t), not defeated(A,t), - 0 < _parallel, _parallel < 4. +:- compatible(A), not occurs(A,t), not defeated(A,t), 0 < _parallel, _parallel < 4. diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index e0d8a04..4e53643 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -7,31 +7,35 @@ #const _parallel = 0. -#include . +% Constant 'planner_on' to enable encoding support for ASP-based planner +% - value '0': no compatibility to ASP-based planner (no idle steps permitted) +% - otherwise: compatibility to ASP-based planner (idle steps permitted) + +#const planner_on = 0. % BASE PROGRAM % Define auxiliary predicates for actions w.r.t. parallel mode -selfdefeat(A,X) :- active(A), precondition(A,X,V), has_condition(A,X,1), _parallel = 1, - not postcondition(A,X,V). +selfdefeat(A,X) :- active(A), precondition(A,X,V), _parallel = 1, + has_condition(A,X,1), not postcondition(A,X,V). -diverge(A1,A2,X) :- active(A1), active(A2), A1 < A2, postcondition(A1,X,V), +diverge(A1,A2,X) :- active(A1), active(A2), postcondition(A1,X,V), has_condition(A2,X,1), not postcondition(A2,X,V), 0 < _parallel, _parallel < 5. diverge(A1,A2) :- diverge(A1,A2,X). -exclude(A1,A2) :- precondition(A1,X,V), 0 < _parallel, _parallel < 5, _parallel != 2, - has_condition(A2,X,0), not precondition(A2,X,V). +exclude(A1,A2) :- active(A1), active(A2), precondition(A1,X,V), + has_condition(A2,X,0), not precondition(A2,X,V), + 0 < _parallel, _parallel < 5, _parallel != 2. disable(A1,A2) :- active(A1), active(A2), A1 != A2, postcondition(A1,X,V), has_condition(A2,X,0), not precondition(A2,X,V), - not diverge(A1,A2), not diverge(A2,A1), - not exclude(A1,A2), not exclude(A2,A1), + not diverge(A1,A2), not exclude(A1,A2), 1 < _parallel, _parallel < 5. disable :- #sum{ 1,A1 : disable(A1,A2), _parallel = 4; - -1,A2 : disable(A1,A2), _parallel = 4 } > 0. + -1,A2 : disable(A1,A2), _parallel = 4} > 0. scope(X,V) :- active(A), precondition(A,X,V), _parallel = 2. @@ -72,7 +76,7 @@ change(X,t) :- holds(X,V,t-1), not holds(X,V,t). {occurs(A,t) : active(A)}. -:- not occurs(A,t) : active(A). +:- planner_on = 0, not occurs(A,t) : active(A). :- occurs(A,t), postcondition(A,X,V), fluent(X), not holds(X,V,t). From d1f1f9230c43c20c64c7df152362f8b0105111fb Mon Sep 17 00:00:00 2001 From: gebser Date: Tue, 17 Jan 2017 19:52:12 +0100 Subject: [PATCH 5/7] added predicate --- encodings/strips/strips-incremental.lp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index 4e53643..6d54966 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -34,8 +34,7 @@ disable(A1,A2) :- active(A1), active(A2), A1 != A2, postcondition(A1,X,V), not diverge(A1,A2), not exclude(A1,A2), 1 < _parallel, _parallel < 5. -disable :- #sum{ 1,A1 : disable(A1,A2), _parallel = 4; - -1,A2 : disable(A1,A2), _parallel = 4} > 0. +disable :- _parallel = 4, #sum{1,A1 : disable(A1,A2); -1,A2 : disable(A1,A2)} > 0. scope(X,V) :- active(A), precondition(A,X,V), _parallel = 2. @@ -97,15 +96,17 @@ single(X,t) :- occurs(A,t), selfdefeat(A,X). :- single(X,t), #count{A : occurs(A,t), postcondition(A,X,V), not precondition(A,X,V)} > 1. proceed(X,V,t) :- holds(X,V,t-1), scope(X,V). -proceed(X,V,t) :- occurs(A,t), postcondition(A,X,V), scope(X,V), not precondition(A,X,V), - perform(A,t). +proceed(X,V,t) :- perform(A,t), scope(X,V), postcondition(A,X,V), not precondition(A,X,V), + occurs(A,t). -perform(A1,t) :- active(A1), 1 < _parallel, _parallel < 4, not occurs(A1,t). -perform(A1,t) :- active(A1), 1 < _parallel, _parallel < 4, - proceed(X,V,t) : precondition(A1,X,V), _parallel = 2; - perform(A2,t) : disable(A1,A2). +perform(A,t) :- active(A), 1 < _parallel, _parallel < 4, + proceed(X,V,t) : precondition(A,X,V), _parallel = 2; + alright(A1,t) : disable(A,A1). -:- 1 < _parallel, _parallel < 4, active(A), not perform(A,t). +alright(A,t) :- active(A), 1 < _parallel, _parallel < 4, not occurs(A,t). +alright(A,t) :- perform(A,t). + +:- 1 < _parallel, _parallel < 4, active(A), not alright(A,t). #edge((A1,t),(A2,t)) : disable(A1,A2), occurs(A1,t), _parallel = 4, not disable. #edge((A1,t),(A2,t)) : disable(A1,A2), occurs(A2,t), disable. From 1b940535421adb54c224d6deda58ec0d701e6ad6 Mon Sep 17 00:00:00 2001 From: gebser Date: Wed, 18 Jan 2017 10:12:52 +0100 Subject: [PATCH 6/7] revised redundant rules --- encodings/strips/redundancy.lp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp index 7d420ce..d2089bb 100644 --- a/encodings/strips/redundancy.lp +++ b/encodings/strips/redundancy.lp @@ -12,11 +12,11 @@ compatible(A) :- compatible(A,A1). compatible(A) :- active(A), active(A1), A != A1, _parallel = 1, not selfdefeat(A), not diverge(A,A1), not exclude(A,A1), not disjoin(A,A1). -disable(A,A1,A2) :- compatible(A,A1), compatible(A,A2), not disable(A1,A), - disable(A1,A2), not disable(A2,A1). +disable(A,A1,A2) :- compatible(A,A1), compatible(A,A2), compatible(A1,A2), + disable(A1,A2), not disable(A1,A). disabled(A,A2) :- disable(A,A1,A2). -disabled(A,A2) :- disable(A,A2). +disabled(A,A1) :- compatible(A), disable(A,A1). % STEP PROGRAM @@ -33,12 +33,14 @@ proceed(A,X,V,t) :- compatible(A), holds(X,V,t-1), scope(X,V). proceed(A,X,V,t) :- compatible(A,A1), not disable(A1,A), perform(A,A1,t), occurs(A1,t), scope(X,V), postcondition(A1,X,V), not precondition(A1,X,V). -perform(A,A1,t) :- disabled(A,A1), not occurs(A1,t). perform(A,A1,t) :- compatible(A,A1), not disable(A1,A), proceed(A,X,V,t) : precondition(A1,X,V), _parallel = 2; - perform(A,A2,t) : disable(A,A1,A2). + alright(A,A2,t) : disable(A,A1,A2). + +alright(A,A1,t) :- disabled(A,A1), not occurs(A1,t). +alright(A,A1,t) :- perform(A,A1,t). defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t), _parallel = 2. -defeated(A,t) :- compatible(A), disable(A,A1), not perform(A,A1,t). +defeated(A,t) :- compatible(A), disable(A,A1), not alright(A,A1,t). :- compatible(A), not occurs(A,t), not defeated(A,t), 0 < _parallel, _parallel < 4. From ff8dc0e85f9e055793d507ed8bed0c08072c5188 Mon Sep 17 00:00:00 2001 From: mgebser Date: Wed, 18 Jan 2017 15:45:12 +0100 Subject: [PATCH 7/7] just stylistic change --- encodings/strips/strips-incremental.lp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index 6d54966..060077e 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -73,7 +73,7 @@ change(X,t) :- holds(X,V,t-1), not holds(X,V,t). % Generate actions -{occurs(A,t) : active(A)}. +{occurs(A,t)} :- active(A). :- planner_on = 0, not occurs(A,t) : active(A).