Skip to content

Commit

Permalink
Merge pull request #2 from whitemech/fix/pddl-generation
Browse files Browse the repository at this point in the history
Fix: Remove PDDL4J dependency
  • Loading branch information
francescofuggitti committed Dec 27, 2021
2 parents 46b496d + 6d92366 commit 51d5734
Show file tree
Hide file tree
Showing 25 changed files with 722 additions and 2,566 deletions.
8 changes: 1 addition & 7 deletions app/src/main/java/trace_alignment/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,7 @@ public void run() {
default:
throw new IllegalStateException("Unexpected value: " + Encoding.get(e));
}
List<?> res;
if (Encoding.get(e).equals(Encoding.STRIPS_CONJ)) {
res = enc.generateString(trace_nb);
}
else {
res = enc.generate(trace_nb);
}
List<?> res = enc.generateString(trace_nb);
File problem_f = new File(output_location, String.format("p-%d.pddl", trace_nb));
if (res.size() > 1) {
File domain_f = new File(output_location, String.format("domain-%d.pddl", trace_nb));
Expand Down
115 changes: 51 additions & 64 deletions app/src/main/resources/domain-general-conj-share.pddl
Original file line number Diff line number Diff line change
@@ -1,66 +1,53 @@
(define (domain alignment)
(:requirements :typing :conditional-effects :action-costs)
(:types
dummy_act - ACTIVITY
activity - OBJECT
automaton - OBJECT
automaton_state - STATE
trace_state - STATE
)
(:predicates
(trace_trans ?t1 - TRACE_STATE ?e - ACTIVITY ?t2 - TRACE_STATE)
(cur_state ?a - AUTOMATON ?s - AUTOMATON_STATE)
(cur_state_trace ?t - TRACE_STATE)
(automaton_trans ?a - AUTOMATON ?s1 - AUTOMATON_STATE ?e - ACTIVITY ?s2 - AUTOMATON_STATE)
(final_state ?s - AUTOMATON_STATE)
(dummy_trans ?a - AUTOMATON ?s1 - AUTOMATON_STATE ?de - DUMMY_ACT ?s2 - AUTOMATON_STATE)
)
(:functions
(total-cost)
)
(:action sync
:parameters (?t1 - TRACE_STATE ?e - ACTIVITY ?t2 - TRACE_STATE)
:precondition
(and (cur_state ?t1)
(trace_trans ?t1 ?e ?t2))
:effect
(and (not (cur_state_trace ?t1))
(cur_state_trace ?t2)
(forall (?a - AUTOMATON ?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?a ?s1)
(automaton_trans ?a ?s1 ?e ?s2)) (and (not (cur_state ?a ?s1))
(cur_state ?a ?s2)))))
)
(:action add
:parameters (?e - ACTIVITY)
:precondition
(and)
:effect
(and (increase (total-cost) 1.0)
(forall (?a - AUTOMATON ?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?a ?s1)
(automaton_trans ?a ?s1 ?e ?s2)) (and (not (cur_state ?a ?s1))
(cur_state ?a ?s2)))))
)
(:action del
:parameters (?t1 - TRACE_STATE ?e - ACTIVITY ?t2 - TRACE_STATE)
:precondition
(and (cur_state_trace ?t1)
(trace_trans ?t1 ?e ?t2))
:effect
(and (increase (total-cost) 1.0)
(not (cur_state_trace ?t1))
(cur_state_trace ?t2))
)
(:action goto-goal
:parameters (?t1 - TRACE_STATE ?de - DUMMY_ACT)
:precondition
(and (cur_state_trace ?t1)
(final_state ?t1))
:effect
(forall (?a - AUTOMATON ?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?a ?s1)
(dummy_trans ?a ?s1 ?de ?s2)) (and (not (cur_state ?a ?s1))
(cur_state ?a ?s2))))
)
(:requirements :typing :disjunctive-preconditions :conditional-effects :universal-preconditions :action-costs)
(:types trace_state automaton_state - state act dummy_act - activity automaton)
(:predicates
(trace_trans ?t1 - trace_state ?e - act ?t2 - trace_state)
(cur_state ?a - automaton ?s - automaton_state)
(cur_state_trace ?t - trace_state)
(automaton_trans ?a - automaton ?s1 - automaton_state ?e - act ?s2 - automaton_state)
(final_state ?s - trace_state)
(dummy_trans ?a - automaton ?s1 - automaton_state ?de - dummy_act ?s2 - automaton_state)
)
(:functions (total-cost))

(:action sync
:parameters (?t1 - trace_state ?e - act ?t2 - trace_state)
:precondition (and (cur_state_trace ?t1) (trace_trans ?t1 ?e ?t2))
:effect (and
(not (cur_state_trace ?t1)) (cur_state_trace ?t2)
(forall (?a - automaton ?s1 ?s2 - automaton_state)
(when (and (cur_state ?a ?s1) (automaton_trans ?a ?s1 ?e ?s2))
(and (not (cur_state ?a ?s1)) (cur_state ?a ?s2)))
)
)
)
(:action add
:parameters (?e - act)
:effect (and
(increase (total-cost) 1)
(forall (?a - automaton ?s1 ?s2 - automaton_state)
(when (and (cur_state ?a ?s1) (automaton_trans ?a ?s1 ?e ?s2))
(and (not (cur_state ?a ?s1)) (cur_state ?a ?s2)))
)
)
)
(:action del
:parameters (?t1 - trace_state ?e - act ?t2 - trace_state)
:precondition (and (cur_state_trace ?t1) (trace_trans ?t1 ?e ?t2))
:effect (and
(increase (total-cost) 1)
(not (cur_state_trace ?t1)) (cur_state_trace ?t2)
)
)
(:action goto-goal
:parameters (?t1 - trace_state ?de - dummy_act)
:precondition (and (cur_state_trace ?t1) (final_state ?t1))
:effect
(forall (?a - automaton ?s1 ?s2 - automaton_state)
(when (and (cur_state ?a ?s1) (dummy_trans ?a ?s1 ?de ?s2))
(and (not (cur_state ?a ?s1)) (cur_state ?a ?s2))
)
)
)
)
111 changes: 49 additions & 62 deletions app/src/main/resources/domain-general-conj.pddl
Original file line number Diff line number Diff line change
@@ -1,64 +1,51 @@
(define (domain alignment)
(:requirements :typing :conditional-effects :action-costs)
(:types
dummy_act - ACTIVITY
act - ACTIVITY
automaton_state - STATE
trace_state - STATE
)
(:predicates
(trace ?t1 - TRACE_STATE ?e - ACT ?t2 - TRACE_STATE)
(cur_state ?s - STATE)
(automaton ?s1 - AUTOMATON_STATE ?e - ACT ?s2 - AUTOMATON_STATE)
(final_state ?s - STATE)
(dummy_trans ?s1 - AUTOMATON_STATE ?de - DUMMY_ACT ?s2 - AUTOMATON_STATE)
)
(:functions
(total-cost)
)
(:action sync
:parameters (?t1 - TRACE_STATE ?e - ACT ?t2 - TRACE_STATE)
:precondition
(and (cur_state ?t1)
(trace ?t1 ?e ?t2))
:effect
(and (not (cur_state ?t1))
(cur_state ?t2)
(forall (?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?s1)
(automaton ?s1 ?e ?s2)) (and (not (cur_state ?s1))
(cur_state ?s2)))))
)
(:action add
:parameters (?e - ACT)
:precondition
(and)
:effect
(and (increase (total-cost) 1.0)
(forall (?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?s1)
(automaton ?s1 ?e ?s2)) (and (not (cur_state ?s1))
(cur_state ?s2)))))
)
(:action del
:parameters (?t1 - TRACE_STATE ?e - ACT ?t2 - TRACE_STATE)
:precondition
(and (cur_state ?t1)
(trace ?t1 ?e ?t2))
:effect
(and (increase (total-cost) 1.0)
(not (cur_state ?t1))
(cur_state ?t2))
)
(:action goto-goal
:parameters (?t1 - TRACE_STATE ?de - DUMMY_ACT)
:precondition
(and (cur_state ?t1)
(final_state ?t1))
:effect
(forall (?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?s1)
(dummy_trans ?s1 ?de ?s2)) (and (not (cur_state ?s1))
(cur_state ?s2))))
)
(:requirements :typing :disjunctive-preconditions :conditional-effects :universal-preconditions :action-costs)
(:types trace_state automaton_state - state act dummy_act - activity)
(:predicates
(trace ?t1 - trace_state ?e - act ?t2 - trace_state)
(cur_state ?s - state)
(automaton ?s1 - automaton_state ?e - act ?s2 - automaton_state)
(final_state ?s - state)
(dummy_trans ?s1 - automaton_state ?de - dummy_act ?s2 - automaton_state)
)
(:functions (total-cost))

(:action sync
:parameters (?t1 - trace_state ?e - act ?t2 - trace_state)
:precondition (and (cur_state ?t1) (trace ?t1 ?e ?t2))
:effect (and
(not (cur_state ?t1)) (cur_state ?t2)
(forall (?s1 ?s2 - automaton_state)
(when (and (cur_state ?s1) (automaton ?s1 ?e ?s2))
(and (not (cur_state ?s1)) (cur_state ?s2)))
)
)
)
(:action add
:parameters (?e - act)
:effect (and
(increase (total-cost) 1)
(forall (?s1 ?s2 - automaton_state)
(when (and (cur_state ?s1) (automaton ?s1 ?e ?s2))
(and (not (cur_state ?s1)) (cur_state ?s2)))
)
)
)
(:action del
:parameters (?t1 - trace_state ?e - act ?t2 - trace_state)
:precondition (and (cur_state ?t1) (trace ?t1 ?e ?t2))
:effect (and
(increase (total-cost) 1)
(not (cur_state ?t1)) (cur_state ?t2)
)
)
(:action goto-goal
:parameters (?t1 - trace_state ?de - dummy_act)
:precondition (and (cur_state ?t1) (final_state ?t1))
:effect
(forall (?s1 ?s2 - automaton_state)
(when (and (cur_state ?s1) (dummy_trans ?s1 ?de ?s2))
(and (not (cur_state ?s1)) (cur_state ?s2)))
)
)
)
92 changes: 40 additions & 52 deletions app/src/main/resources/domain-general-share.pddl
Original file line number Diff line number Diff line change
@@ -1,54 +1,42 @@
(define (domain alignment)
(:requirements :typing :conditional-effects :universal-preconditions :action-costs)
(:types
automaton_state - STATE
trace_state - STATE
state - OBJECT
automaton - OBJECT
activity - OBJECT
)
(:predicates
(trace_trans ?t1 - TRACE_STATE ?e - ACTIVITY ?t2 - TRACE_STATE)
(cur_state ?a - AUTOMATON ?s - AUTOMATON_STATE)
(cur_state_trace ?t - TRACE_STATE)
(automaton_trans ?a - AUTOMATON ?s1 - AUTOMATON_STATE ?e - ACTIVITY ?s2 - AUTOMATON_STATE)
(final_state ?a - AUTOMATON ?s - AUTOMATON_STATE)
)
(:functions
(total-cost)
)
(:action sync
:parameters (?t1 - TRACE_STATE ?e - ACTIVITY ?t2 - TRACE_STATE)
:precondition
(and (cur_state_trace ?t1)
(trace_trans ?t1 ?e ?t2))
:effect
(and (not (cur_state_trace ?t1))
(cur_state_trace ?t2)
(forall (?a - AUTOMATON ?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?a ?s1)
(automaton_trans ?a ?s1 ?e ?s2)) (and (not (cur_state ?a ?s1))
(cur_state ?a ?s2)))))
)
(:action add
:parameters (?e - ACTIVITY)
:precondition
(and)
:effect
(and (increase (total-cost) 1.0)
(forall (?a - AUTOMATON ?s1 ?s2 - AUTOMATON_STATE)
(when (and (cur_state ?a ?s1)
(automaton_trans ?a ?s1 ?e ?s2)) (and (not (cur_state ?a ?s1))
(cur_state ?a ?s2)))))
)
(:action del
:parameters (?t1 - TRACE_STATE ?e - ACTIVITY ?t2 - TRACE_STATE)
:precondition
(and (cur_state_trace ?t1)
(trace_trans ?t1 ?e ?t2))
:effect
(and (increase (total-cost) 1.0)
(not (cur_state_trace ?t1))
(cur_state_trace ?t2))
)
(:requirements :typing :disjunctive-preconditions :conditional-effects :universal-preconditions :action-costs)
(:types trace_state automaton_state - state activity automaton)
(:predicates
(trace_trans ?t1 - trace_state ?e - activity ?t2 - trace_state)
(cur_state ?a - automaton ?s - automaton_state)
(cur_state_trace ?t - trace_state)
(automaton_trans ?a - automaton ?s1 - automaton_state ?e - activity ?s2 - automaton_state)
(final_state ?a - automaton ?s - state)
)
(:functions (total-cost))

(:action sync
:parameters (?t1 - trace_state ?e - activity ?t2 - trace_state)
:precondition (and (cur_state_trace ?t1) (trace_trans ?t1 ?e ?t2))
:effect (and
(not (cur_state_trace ?t1)) (cur_state_trace ?t2)
(forall (?a - automaton ?s1 ?s2 - automaton_state)
(when (and (cur_state ?a ?s1) (automaton_trans ?a ?s1 ?e ?s2))
(and (not (cur_state ?a ?s1)) (cur_state ?a ?s2)))
)
)
)
(:action add
:parameters (?e - activity)
:effect (and
(increase (total-cost) 1)
(forall (?a - automaton ?s1 ?s2 - automaton_state)
(when (and (cur_state ?a ?s1) (automaton_trans ?a ?s1 ?e ?s2))
(and (not (cur_state ?a ?s1)) (cur_state ?a ?s2)))
)
)
)
(:action del
:parameters (?t1 - trace_state ?e - act ?t2 - trace_state)
:precondition (and (cur_state_trace ?t1) (trace_trans ?t1 ?e ?t2))
:effect (and
(increase (total-cost) 1)
(not (cur_state_trace ?t1)) (cur_state_trace ?t2)
)
)
)
Loading

0 comments on commit 51d5734

Please sign in to comment.