From b8357629a2cf5dcbdee430fe7ea00eb833e96283 Mon Sep 17 00:00:00 2001 From: mgebser Date: Mon, 14 Nov 2016 12:00:14 +0100 Subject: [PATCH 01/11] started to develop STRIPS encoding variants --- encodings/strips/preprocess.lp | 48 +++++++++++++++ encodings/strips/strips-incremental.lp | 84 ++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 encodings/strips/preprocess.lp create mode 100644 encodings/strips/strips-incremental.lp diff --git a/encodings/strips/preprocess.lp b/encodings/strips/preprocess.lp new file mode 100644 index 0000000..bd60246 --- /dev/null +++ b/encodings/strips/preprocess.lp @@ -0,0 +1,48 @@ +% Constant '_closure' to (de)activate analysis of potentially relevant actions +% - 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 + +#const _closure = 3. + +% Check feature requirements + +:- requires(feature(actionCosts)). +:- requires(feature(axiomRules)). +:- requires(feature(conditionalEffects)). + +% Basic redundancy check for actions + +postcondition(A,X,V) :- postcondition(A,E,X,V). + +has_condition(A,X,0) :- action(A), precondition(A,X,V). +has_condition(A,X,1) :- action(A), postcondition(A,X,V). + +inconsistent(A) :- has_condition(A,X,P), + #count{V : precondition(A,X,V), P = 0; + V : postcondition(A,X,V), P = 1} > 1. +consistent(A) :- action(A), not inconsistent(A). +irredundant(A) :- consistent(A), postcondition(A,X,V), not precondition(A,X,V). + +% Forward chaining of effects w.r.t. initial variable values + +feasible(X,V) :- initialState(X,V). +feasible(X,V) :- possible(A), postcondition(A,X,V). + +possible(A) :- irredundant(A), feasible(X,V) : precondition(A,X,V). +possible(A) :- irredundant(A), _closure != 1, _closure != 3. + +:- goal(X,V), not feasible(X,V). + +% Backward regression of effects w.r.t. goal variable values + +produce(X,V) :- goal(X,V), not initialState(X,V). +produce(X,V) :- active(A), precondition(A,X,V), not initialState(X,V). +produce(X,V) :- persist(X,V), active(A), has_condition(A,X,1), not postcondition(A,X,V). + +persist(X,V) :- goal(X,V), initialState(X,V). +persist(X,V) :- active(A), precondition(A,X,V), initialState(X,V). + +active(A) :- possible(A), postcondition(A,X,V), produce(X,V). +active(A) :- possible(A), _closure != 2, _closure != 3. diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp new file mode 100644 index 0000000..a128717 --- /dev/null +++ b/encodings/strips/strips-incremental.lp @@ -0,0 +1,84 @@ +#include . + +#const _parallel = 0. + +% BASE PROGRAM + +% Define relevant fluents w.r.t. parallel mode + +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. +diverge(A1,A2) :- diverge(A1,A2,X), _parallel = 1. + +exclude(A1,A2) :- diverge(A1,A2), precondition(A1,X,V), + has_condition(A2,X,0), not precondition(A2,X,V). + +fluent(X,V) :- produce(X,V). +fluent(X,V) :- persist(X,V). +fluent(X,V) :- initialState(X,V), fluent(X). +fluent(X,V) :- active(A), postcondition(A,X,V), fluent(X). +fluent(X) :- fluent(X,V). +fluent(X) :- diverge(A1,A2,X), not exclude(A1,A2). + +% Define unsubsumed mutexes + +mutex(G,V) :- mutexGroup(G), contains(G,X,V), fluent(X,V). +mutex(G) :- mutexGroup(G), #count{V : mutex(G,V)} > 1. + +% Define initial state + +holds(X,V,0) :- initialState(X,V), fluent(X). + +:- fluent(X), #count{V : holds(X,V,0) } > 1. +:- mutex(G), #count{X,V : holds(X,V,0), contains(G,X,V) } > 1. + +% STEP PROGRAM + +#program step(t). + +% Generate successor state + +1 {holds(X,V,t) : fluent(X,V)} 1 :- fluent(X). + +:- mutex(G), #count{X,V : holds(X,V,t), contains(G,X,V) } > 1. + +change(X,t) :- holds(X,V,t), not holds(X,V,t-1). + +% Generate actions + +1 {occurs(A,t) : active(A)}. + +:- occurs(A,t), postcondition(A,X,V), fluent(X), not holds(X,V,t). + +effect(X,t) :- occurs(A,t), postcondition(A,X,V), fluent(X), not precondition(A,X,V). + +:- change(X,t), not effect(X,t). + +% Check w.r.t. parallel mode + +:- _parallel != 1, _parallel != 2, #count{A : occurs(A,t)} > 1. + +:- _parallel != 2, occurs(A,t), precondition(A,X,V), not holds(X,V,t-1). + +invariant(X,t) :- occurs(A,t), precondition(A,X,V), _parallel = 1, + not has_condition(A,X,1). + +:- invariant(X,t), effect(X,t). + +singleton(X,t) :- occurs(A,t), precondition(A,X,V), _parallel = 1, + has_condition(A,X,1), not postcondition(A,X,V). + +:- singleton(X,t), #count{A : occurs(A,t), postcondition(A,X,V), not precondition(A,X,V) } > 1. + +% CHECK PROGRAM + +#program check(t). + +% Check goal conditions + +:- query(t), goal(X,V), not holds(X,V,t). + +% DISPLAY PART + +#show occurs/2. From 888f12d88d65044282dcd5a6ebf58b432701d258 Mon Sep 17 00:00:00 2001 From: mgebser Date: Mon, 14 Nov 2016 16:56:51 +0100 Subject: [PATCH 02/11] completed main parallel planning encodings for STRIPS instances --- encodings/strips/strips-incremental.lp | 54 ++++++++++++++++++-------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/encodings/strips/strips-incremental.lp b/encodings/strips/strips-incremental.lp index a128717..8f26060 100644 --- a/encodings/strips/strips-incremental.lp +++ b/encodings/strips/strips-incremental.lp @@ -1,19 +1,32 @@ -#include . +% 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 +% - otherwise: sequential actions #const _parallel = 0. +#include . + % BASE PROGRAM -% Define relevant fluents w.r.t. parallel mode +% Define auxiliary predicates for actions w.r.t. parallel mode 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. -diverge(A1,A2) :- diverge(A1,A2,X), _parallel = 1. +diverge(A1,A2) :- diverge(A1,A2,X). -exclude(A1,A2) :- diverge(A1,A2), precondition(A1,X,V), +exclude(A1,A2) :- diverge(A1,A2), precondition(A1,X,V), _parallel = 1, 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). + +scope(X,V) :- active(A), precondition(A,X,V), _parallel = 2. + +% Define relevant fluents w.r.t. parallel mode + fluent(X,V) :- produce(X,V). fluent(X,V) :- persist(X,V). fluent(X,V) :- initialState(X,V), fluent(X). @@ -23,15 +36,15 @@ fluent(X) :- diverge(A1,A2,X), not exclude(A1,A2). % Define unsubsumed mutexes -mutex(G,V) :- mutexGroup(G), contains(G,X,V), fluent(X,V). -mutex(G) :- mutexGroup(G), #count{V : mutex(G,V)} > 1. +mutex(G,X) :- mutexGroup(G), contains(G,X,V), fluent(X,V). +mutex(G) :- mutexGroup(G), #count{X : mutex(G,X)} > 1. % Define initial state holds(X,V,0) :- initialState(X,V), fluent(X). -:- fluent(X), #count{V : holds(X,V,0) } > 1. -:- mutex(G), #count{X,V : holds(X,V,0), contains(G,X,V) } > 1. +:- fluent(X), #count{V : holds(X,V,0)} > 1. +:- mutex(G), #count{X,V : holds(X,V,0), contains(G,X,V)} > 1. % STEP PROGRAM @@ -41,9 +54,9 @@ holds(X,V,0) :- initialState(X,V), fluent(X). 1 {holds(X,V,t) : fluent(X,V)} 1 :- fluent(X). -:- mutex(G), #count{X,V : holds(X,V,t), contains(G,X,V) } > 1. +:- mutex(G), #count{X,V : holds(X,V,t), contains(G,X,V)} > 1. -change(X,t) :- holds(X,V,t), not holds(X,V,t-1). +change(X,t) :- holds(X,V,t-1), not holds(X,V,t). % Generate actions @@ -55,21 +68,28 @@ effect(X,t) :- occurs(A,t), postcondition(A,X,V), fluent(X), not precondition(A, :- change(X,t), not effect(X,t). -% Check w.r.t. parallel mode +% Checks w.r.t. parallel mode :- _parallel != 1, _parallel != 2, #count{A : occurs(A,t)} > 1. :- _parallel != 2, occurs(A,t), precondition(A,X,V), not holds(X,V,t-1). -invariant(X,t) :- occurs(A,t), precondition(A,X,V), _parallel = 1, - not has_condition(A,X,1). +:- _parallel = 1, occurs(A,t), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t). -:- invariant(X,t), effect(X,t). +single(X,t) :- occurs(A,t), precondition(A,X,V), _parallel = 1, + has_condition(A,X,1), not postcondition(A,X,V). -singleton(X,t) :- occurs(A,t), precondition(A,X,V), _parallel = 1, - has_condition(A,X,1), not postcondition(A,X,V). +:- single(X,t), #count{A : occurs(A,t), postcondition(A,X,V), not precondition(A,X,V)} > 1. -:- singleton(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). + +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). + +:- _parallel = 2, active(A), not perform(A,t). % CHECK PROGRAM From e1e9efde25de42557b613b3319c99ca5fd85e6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 14 Nov 2016 17:11:05 +0100 Subject: [PATCH 03/11] Added contributor. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1638658..108deae 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ See [building instructions](doc/building-instructions.md) for more details. ## Contributors * [Patrick Lühne](https://www.luehne.de) +* Martin Gebser (encodings) * Torsten Schaub (encodings) ### Earlier Versions From 7f62503237804979d5cd2c334a8eada3afa685ab Mon Sep 17 00:00:00 2001 From: mgebser Date: Mon, 14 Nov 2016 18:36:01 +0100 Subject: [PATCH 04/11] first version of postprocessing program to check plans and represent them sequentially --- encodings/strips/postprocess.lp | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 encodings/strips/postprocess.lp diff --git a/encodings/strips/postprocess.lp b/encodings/strips/postprocess.lp new file mode 100644 index 0000000..2aa3fac --- /dev/null +++ b/encodings/strips/postprocess.lp @@ -0,0 +1,61 @@ +% Convert a plan (possibly with parallel actions), given by atoms over occurs/2, +% to a sequential plan, expressed by atoms over sequence/2 + +time(T) :- occurs(A,T). +time :- time(T). + +:- goal(X,V), not initialState(X,V), not time. + +next(T1,T2) :- time(T1), time(T2), T1 < T2, T <= T1 : time(T), T < T2. +init(T2) :- time(T2), #false : next(T1,T2). +stop(T1) :- time(T1), #false : next(T1,T2). + +offset(T2,M) :- time(T2), M = #count{A,T1 : occurs(A,T1), T1 < T2}. +actions(T,N) :- time(T), N = #count{A : occurs(A,T)}. +index(T,M+1..M+N) :- offset(T,M), actions(T,N). + +postcondition(A,X,V) :- postcondition(A,E,X,V), occurs(A,T). +postcondition(A,X) :- postcondition(A,X,V). + +before(A1,A2,T) :- occurs(A1,T), occurs(A2,T), A1 != A2, + precondition(A1,X,V1), postcondition(A2,X,V2), V1 != V2. + +order(A1,A2,T) :- occurs(A1,T), occurs(A2,T), A1 < A2, A <= A1 : occurs(A,T), A < A2. +first(A2,T) :- occurs(A2,T), #false : order(A1,A2,T). + +undone(A,T,M) :- occurs(A,T), offset(T,M). +undone(A,T,N) :- undone(A,T,N-1), select(A1,T,N), A != A1, index(T,N+1). + +done(A,T,N) :- select(A,T,N). +done(A,T,N) :- done(A,T,N-1), index(T,N). + +:- offset(T,M), actions(T,N), occurs(A,T), not done(A,T,M+N). + +holds(X,V,0) :- initialState(X,V), time. +holds(X,V,N) :- select(A,T,N), postcondition(A,X,V). +holds(X,V,N) :- select(A,T,N), holds(X,V,N-1), not postcondition(A,X). + +:- stop(T), offset(T,M), actions(T,N), goal(X,V), not holds(X,V,M+N). + +holds(X,N) :- holds(X,V,N). + +:- holds(X,N), #count{V : holds(X,V,N) } > 1. + +preconditions(A,T,N) :- undone(A,T,N), holds(X,V,N) : precondition(A,X,V). +applicable(A,T,N) :- preconditions(A,T,N), done(A1,T,N) : before(A1,A,T). + +inapplicable(A,T,N) :- done(A,T,N), index(T,N+1). +inapplicable(A,T,N) :- undone(A,T,N), precondition(A,X,V1), holds(X,V2,N), V1 != V2. +inapplicable(A,T,N) :- undone(A1,T,N), before(A1,A,T). + +continue(A2,T,N) :- order(A1,A2,T), inapplicable(A1,T,N), first(A1,T). +continue(A2,T,N) :- order(A1,A2,T), inapplicable(A1,T,N), continue(A1,T,N). + +select(A,T,N+1) :- applicable(A,T,N), first(A,T). +select(A,T,N+1) :- applicable(A,T,N), continue(A,T,N). + +sequence(A,N) :- select(A,T,N). + +% DISPLAY PART + +#show sequence/2. From 03c83702ad525e37fabaa51e850af3f8ec10f8b5 Mon Sep 17 00:00:00 2001 From: gebser Date: Tue, 15 Nov 2016 09:07:36 +0100 Subject: [PATCH 05/11] postprocessing encoding checked --- encodings/strips/postprocess.lp | 35 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/encodings/strips/postprocess.lp b/encodings/strips/postprocess.lp index 2aa3fac..3c24305 100644 --- a/encodings/strips/postprocess.lp +++ b/encodings/strips/postprocess.lp @@ -6,19 +6,17 @@ time :- time(T). :- goal(X,V), not initialState(X,V), not time. -next(T1,T2) :- time(T1), time(T2), T1 < T2, T <= T1 : time(T), T < T2. -init(T2) :- time(T2), #false : next(T1,T2). -stop(T1) :- time(T1), #false : next(T1,T2). +last(T2) :- time, T2 = #max{T1 : time(T1)}. -offset(T2,M) :- time(T2), M = #count{A,T1 : occurs(A,T1), T1 < T2}. -actions(T,N) :- time(T), N = #count{A : occurs(A,T)}. -index(T,M+1..M+N) :- offset(T,M), actions(T,N). +offset(T2,M) :- time(T2), M = #count{A,T1 : occurs(A,T1), T1 < T2}. +finish(T,M+N) :- offset(T,M), N = #count{A : occurs(A,T)}. +index(T,M+1..N) :- offset(T,M), finish(T,N). postcondition(A,X,V) :- postcondition(A,E,X,V), occurs(A,T). postcondition(A,X) :- postcondition(A,X,V). before(A1,A2,T) :- occurs(A1,T), occurs(A2,T), A1 != A2, - precondition(A1,X,V1), postcondition(A2,X,V2), V1 != V2. + precondition(A1,X,V), postcondition(A2,X), not postcondition(A2,X,V). order(A1,A2,T) :- occurs(A1,T), occurs(A2,T), A1 < A2, A <= A1 : occurs(A,T), A < A2. first(A2,T) :- occurs(A2,T), #false : order(A1,A2,T). @@ -29,23 +27,23 @@ undone(A,T,N) :- undone(A,T,N-1), select(A1,T,N), A != A1, index(T,N+1). done(A,T,N) :- select(A,T,N). done(A,T,N) :- done(A,T,N-1), index(T,N). -:- offset(T,M), actions(T,N), occurs(A,T), not done(A,T,M+N). +:- finish(T,N), occurs(A,T), not done(A,T,N). -holds(X,V,0) :- initialState(X,V), time. -holds(X,V,N) :- select(A,T,N), postcondition(A,X,V). -holds(X,V,N) :- select(A,T,N), holds(X,V,N-1), not postcondition(A,X). +hold(X,V,0) :- initialState(X,V). +hold(X,V,N) :- select(A,T,N), postcondition(A,X,V). +hold(X,V,N) :- select(A,T,N), hold(X,V,N-1), not postcondition(A,X). -:- stop(T), offset(T,M), actions(T,N), goal(X,V), not holds(X,V,M+N). +:- last(T), finish(T,N), goal(X,V), not hold(X,V,N). -holds(X,N) :- holds(X,V,N). +hold(X,N) :- hold(X,V,N). -:- holds(X,N), #count{V : holds(X,V,N) } > 1. +:- hold(X,N), #count{V : hold(X,V,N)} > 1. -preconditions(A,T,N) :- undone(A,T,N), holds(X,V,N) : precondition(A,X,V). +preconditions(A,T,N) :- undone(A,T,N), hold(X,V,N) : precondition(A,X,V). applicable(A,T,N) :- preconditions(A,T,N), done(A1,T,N) : before(A1,A,T). inapplicable(A,T,N) :- done(A,T,N), index(T,N+1). -inapplicable(A,T,N) :- undone(A,T,N), precondition(A,X,V1), holds(X,V2,N), V1 != V2. +inapplicable(A,T,N) :- undone(A,T,N), precondition(A,X,V1), hold(X,V2,N), V1 != V2. inapplicable(A,T,N) :- undone(A1,T,N), before(A1,A,T). continue(A2,T,N) :- order(A1,A2,T), inapplicable(A1,T,N), first(A1,T). @@ -54,8 +52,7 @@ continue(A2,T,N) :- order(A1,A2,T), inapplicable(A1,T,N), continue(A1,T,N). select(A,T,N+1) :- applicable(A,T,N), first(A,T). select(A,T,N+1) :- applicable(A,T,N), continue(A,T,N). -sequence(A,N) :- select(A,T,N). - % DISPLAY PART -#show sequence/2. +#show. +#show sequence(A,N) : select(A,T,N). From f12ac1c83983b258ced0c758906577d88cf2813b Mon Sep 17 00:00:00 2001 From: mgebser Date: Tue, 15 Nov 2016 18:57:52 +0100 Subject: [PATCH 06/11] optional redundant rules to reduce the number of parallel plans --- encodings/strips/redundancy.lp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 encodings/strips/redundancy.lp diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp new file mode 100644 index 0000000..3a9cf91 --- /dev/null +++ b/encodings/strips/redundancy.lp @@ -0,0 +1,24 @@ +% Additional rules for enforcing the inclusion of parallel actions in plans, +% whenever such 'redundant' actions are compatible with states and other actions + +#program step(t). + +defeated(A,t) :- active(A), postcondition(A,X,V), fluent(X), not holds(X,V,t), + _parallel = 1 : _parallel != 2. + +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). + +proceed(A,X,V,t) :- active(A), holds(X,V,t-1), scope(X,V). +proceed(A,X,V,t) :- active(A), occurs(A1,t), perform(A,A1,t), A != A1, + postcondition(A1,X,V), scope(X,V), not precondition(A1,X,V). + +perform(A,A1,t) :- active(A), active(A1), A != A1, _parallel = 2, not occurs(A1,t). +perform(A,A1,t) :- active(A), active(A1), _parallel = 2, + proceed(A,X,V,t) : precondition(A1,X,V); perform(A,A2,t) : disable(A1,A2). + +defeated(A,t) :- _parallel = 2, active(A), not perform(A,A,t). + +:- active(A), not occurs(A,t), not defeated(A,t), _parallel = 1 : _parallel != 2. From 6f1a64a7050874429c2b642f200c78b553867f77 Mon Sep 17 00:00:00 2001 From: mgebser Date: Tue, 15 Nov 2016 19:34:07 +0100 Subject: [PATCH 07/11] some restriction of instantiation --- encodings/strips/redundancy.lp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp index 3a9cf91..ad8b891 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 +compatible(A,A1) :- active(A), active(A1), A != A1, _parallel = 2, + not diverge(A,A1), not diverge(A1,A). +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), _parallel = 2. + #program step(t). defeated(A,t) :- active(A), postcondition(A,X,V), fluent(X), not holds(X,V,t), @@ -12,12 +18,14 @@ defeated(A,t) :- _parallel = 1, active(A), postcondition(A,X,V), not preconditio single(X,t). proceed(A,X,V,t) :- active(A), holds(X,V,t-1), scope(X,V). -proceed(A,X,V,t) :- active(A), occurs(A1,t), perform(A,A1,t), A != A1, +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) :- active(A), active(A1), A != A1, _parallel = 2, not occurs(A1,t). -perform(A,A1,t) :- active(A), active(A1), _parallel = 2, - proceed(A,X,V,t) : precondition(A1,X,V); perform(A,A2,t) : disable(A1,A2). +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). +perform(A,A,t) :- active(A), _parallel = 2, + proceed(A,X,V,t) : precondition(A,X,V); perform(A,A2,t) : disable(A,A2). defeated(A,t) :- _parallel = 2, active(A), not perform(A,A,t). From 367f49253e9b8498c3fccba9ea659ef3b060ade9 Mon Sep 17 00:00:00 2001 From: gebser Date: Tue, 15 Nov 2016 21:16:01 +0100 Subject: [PATCH 08/11] finalizing redundant rules to restrict number of parallel plans --- encodings/strips/redundancy.lp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/encodings/strips/redundancy.lp b/encodings/strips/redundancy.lp index ad8b891..ef67f92 100644 --- a/encodings/strips/redundancy.lp +++ b/encodings/strips/redundancy.lp @@ -1,11 +1,13 @@ % 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). -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), _parallel = 2. +compatible(A,A1) :- active(A), active(A1), A != A1, _parallel = 2, + not diverge(A,A1), not diverge(A1,A). +compatible(A) :- compatible(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). #program step(t). @@ -17,16 +19,15 @@ 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). -proceed(A,X,V,t) :- active(A), holds(X,V,t-1), scope(X,V). +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). -perform(A,A,t) :- active(A), _parallel = 2, - proceed(A,X,V,t) : precondition(A,X,V); perform(A,A2,t) : disable(A,A2). -defeated(A,t) :- _parallel = 2, active(A), not perform(A,A,t). +defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t). +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. From b1e98bd09121577410241be352d3be329a7b7c6b Mon Sep 17 00:00:00 2001 From: gebser Date: Tue, 15 Nov 2016 22:48:24 +0100 Subject: [PATCH 09/11] README file summarizing functionalities and example invocations --- encodings/strips/README | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 encodings/strips/README diff --git a/encodings/strips/README b/encodings/strips/README new file mode 100644 index 0000000..3bb77f0 --- /dev/null +++ b/encodings/strips/README @@ -0,0 +1,49 @@ +This suite of incremental STRIPS planning encodings implements diverse methods. +The included encoding files provide the following functionalities: + +- preprocess.lp: static analysis of potentially relevant actions + + Parameters: _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: sequential and parallel planning encoding variants + + 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 + * Otherwise: sequential actions + +- redundancy.lp: enforcement of 'redundant' actions to constrain parallel plans + + Remarks: + * Only relevant together with parallel actions + * Encoded constraints seem rather ineffective though + * Heavy space overhead in combination with "exists" parallel actions + +- postprocess.lp: plan feasibility checking and conversion to sequential plan + +================================================================================ + +Some example invocations (using clingo 5.1.0) are as follows: + +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 - 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 - 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 - 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=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 --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) From c80688b2413df650f556dc463188683e253d7eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 16 Nov 2016 23:27:45 +0100 Subject: [PATCH 10/11] Changed format of readme file for STRIPS encodings to Markdown. --- encodings/strips/{README => README.md} | 45 +++++++++++++++----------- 1 file changed, 26 insertions(+), 19 deletions(-) rename encodings/strips/{README => README.md} (69%) diff --git a/encodings/strips/README b/encodings/strips/README.md similarity index 69% rename from encodings/strips/README rename to encodings/strips/README.md index 3bb77f0..037ce05 100644 --- a/encodings/strips/README +++ b/encodings/strips/README.md @@ -1,31 +1,37 @@ +# Incremental STRIPS Planning Encodings + This suite of incremental STRIPS planning encodings implements diverse methods. The included encoding files provide the following functionalities: -- preprocess.lp: static analysis of potentially relevant actions - + Parameters: _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) +## Encodings -- strips-incremental.lp: sequential and parallel planning encoding variants - + 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 - * Otherwise: sequential actions +### [preprocess.lp](preprocess.lp): static analysis of potentially relevant actions -- redundancy.lp: enforcement of 'redundant' actions to constrain parallel plans - + Remarks: - * Only relevant together with parallel actions - * Encoded constraints seem rather ineffective though - * Heavy space overhead in combination with "exists" parallel actions +* Parameters: `_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) -- postprocess.lp: plan feasibility checking and conversion to sequential plan +### [strips-incremental.lp](strips-incremental.lp): sequential and parallel planning encoding variants +* 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 + * Otherwise: sequential actions -================================================================================ +### [redundancy.lp](redundancy.lp): enforcement of ‘redundant’ actions to constrain parallel plans +* Remarks: + * Only relevant together with parallel actions + * Encoded constraints seem rather ineffective though + * Heavy space overhead in combination with “exists” parallel actions -Some example invocations (using clingo 5.1.0) are as follows: +### [postprocess.lp](postprocess.lp): plan feasibility checking and conversion to sequential plan +## Usage Examples + +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 - preprocess.lp strips-incremental.lp -c _closure=0 @@ -47,3 +53,4 @@ 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 --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) +``` From 8bab1e19cbc3c5789ed16588de7b4d226969045a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 16 Nov 2016 23:53:21 +0100 Subject: [PATCH 11/11] Made readme file sections and documentation more consistent. --- README.md | 2 +- doc/{building-instructions.md => building.md} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename doc/{building-instructions.md => building.md} (97%) diff --git a/README.md b/README.md index 108deae..def6fc1 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ If you want to write your own meta encoding for `plasp`’s output, this [simple `plasp` requires `boost` and is built via CMake and a C++ compiler. -See [building instructions](doc/building-instructions.md) for more details. +See [building](doc/building.md) for more details. ## Contributors diff --git a/doc/building-instructions.md b/doc/building.md similarity index 97% rename from doc/building-instructions.md rename to doc/building.md index 3f56a48..b895a78 100644 --- a/doc/building-instructions.md +++ b/doc/building.md @@ -1,4 +1,4 @@ -# Building Instructions +# Building `plasp` requires a C++14 compiler (preferrably GCC ≥ 6.1 or clang ≥ 3.8), the `boost` libraries (≥ 1.55), and CMake for building.