From 5ec5169ae5099591a03c3b0c4a4ecabbe6272969 Mon Sep 17 00:00:00 2001 From: Naveen Sundar Govindarajulu Date: Tue, 24 Jan 2017 15:24:08 -0600 Subject: [PATCH] some more edits. --- src/main/java/edu/rpi/rair/utils/RunDemo.java | 11 +- .../edu/rpi/rair/goal_management_1.clj | 2 +- .../edu/rpi/rair/goal_management_6.clj | 173 ++++++++++++++++++ 3 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/edu/rpi/rair/goal_management_6.clj diff --git a/src/main/java/edu/rpi/rair/utils/RunDemo.java b/src/main/java/edu/rpi/rair/utils/RunDemo.java index 89f5d58..971a971 100644 --- a/src/main/java/edu/rpi/rair/utils/RunDemo.java +++ b/src/main/java/edu/rpi/rair/utils/RunDemo.java @@ -38,7 +38,7 @@ public class RunDemo { } }); - planningProblemWarmUp(); + // planningProblemWarmUp(); System.out.println("\nWARM UP DONE"); } catch (Reader.ParsingException e) { e.printStackTrace(); @@ -53,7 +53,7 @@ public class RunDemo { System.out.println(); - List goalTrackingProblemList = (GoalTrackingProblem.readFromFile(Planner.class.getResourceAsStream("goal_management_1.clj"))); + List goalTrackingProblemList = (GoalTrackingProblem.readFromFile(Planner.class.getResourceAsStream("goal_management_6.clj"))); GoalTrackingProblem goalTrackingProblem = goalTrackingProblemList.get(0); @@ -65,14 +65,17 @@ public class RunDemo { long start = System.currentTimeMillis(); Goal g1 = goalTrackingProblem.getGoalNamed("G1"); - Goal g2 = goalTrackingProblem.getGoalNamed("G2"); + Goal g2a = goalTrackingProblem.getGoalNamed("G2a"); + Goal g2b = goalTrackingProblem.getGoalNamed("G2b"); + Goal g3 = goalTrackingProblem.getGoalNamed("G3"); Goal g4 = goalTrackingProblem.getGoalNamed("G4"); tryAndAddGoal(g1, goalTracker); - tryAndAddGoal(g2, goalTracker); + tryAndAddGoal(g2a, goalTracker); + tryAndAddGoal(g2b, goalTracker); tryAndAddGoal(g3, goalTracker); diff --git a/src/main/resources/edu/rpi/rair/goal_management_1.clj b/src/main/resources/edu/rpi/rair/goal_management_1.clj index 8790842..1557fad 100644 --- a/src/main/resources/edu/rpi/rair/goal_management_1.clj +++ b/src/main/resources/edu/rpi/rair/goal_management_1.clj @@ -79,7 +79,7 @@ G4 {:priority 1.0 :state [(in prisoner room2) (in self room2)]} - G5 {:priority 3 + G5 {:priority 3.0 :state [(interrogates commander prisoner)]}} diff --git a/src/main/resources/edu/rpi/rair/goal_management_6.clj b/src/main/resources/edu/rpi/rair/goal_management_6.clj new file mode 100644 index 0000000..e0e5304 --- /dev/null +++ b/src/main/resources/edu/rpi/rair/goal_management_6.clj @@ -0,0 +1,173 @@ +{:definitions + {:name "demo 1" + :background [] + :start [ + (person prisoner) + (prisoner prisoner) + (person commander) + (commander commander) + (robot guard) + (robot guide) + + (not (= prisoner commander)) + (not (= prisoner guard)) + (not (= prisoner guide)) + (not (= commander guard)) + (not (= commander guide)) + (not (= guard guide)) + + (room room1) + (room room2) + (room hallway) + (not (= room1 room2)) + (not (= room1 hallway)) + (not (= room2 hallway)) + + (in prisoner room1) + (in commander room2) + (in guard room1) + (in guide hallway) + + (not (open (door room1))) + (open (door room2)) + (open (door hallway)) + + (forall (?robot ?prisoner ?commander) + (implies (and (and (robot ?robot) (prisoner ?prisoner)) (commander ?commander)) + (can accompany ?robot ?prisoner ?commander))) + + (forall (?commander ?prisoner ?person) + (implies (and (and (commander ?commander) (prisoner ?prisoner)) (person ?person)) + (can accompany ?commander ?prisoner ?person))) + + (forall (?robot ?commander ?person) + (implies (and (and (and (robot ?robot) (commander ?commander)) (person ?person)) + (needs ?commander (interrogate ?person))) + (can accompany ?robot ?commander ?person))) + + (forall (?room ?x ?y) + (implies (and (in ?x ?room) (and (in ?y ?room) (not (= ?x ?y)))) + (sameroom ?x ?y))) + + (forall (?room2 ?x ?room1) + (implies (and (not (= ?room1 ?room2)) (in ?x ?room1)) + (not (in ?x ?room2)))) + + (forall (?room ?x ?y) + (implies (and (sameroom ?x ?y) (in ?x ?room)) + (in ?y ?room))) + + + (needs commander (interrogate prisoner)) + ] + + :goal [] + + :actions + [ + + (define-action move [?actor ?room1 ?room2] + {:preconditions [(robot ?actor) + (room ?room1) + (room ?room2) + (in ?actor ?room1) + (open (door ?room1)) + (open (door ?room2)) + (not (= ?room1 ?room2))] + :additions [(in ?actor ?room2)] + :deletions [(in ?actor ?room1)] + }) + + (define-action keepDoorClosed [?actor ?room] + {:preconditions [(robot ?actor) + (room ?room) + (in ?actor ?room) + (not (open (door ?room)))] + :additions [] + :deletions [(open (door ?room))] + }) + + (define-action accompany [?actor ?person1 ?person2 ?room1 ?room2] + {:preconditions [(robot ?actor) + (person ?person1) + (person ?person2) + (can accompany ?actor ?person1 ?person2) + (room ?room1) + (room ?room2) + (in ?actor ?room1) + (in ?person1 ?room1) + (in ?person2 ?room2) + (open (door ?room1)) + (open (door ?room2)) + (not (= ?actor ?person1)) + (not (= ?actor ?person2)) + (not (= ?person1 ?person2)) + (not (= ?room1 ?room2))] + :additions [(accompanies ?person1 ?person2) + (in ?actor ?room2) + (in ?person1 ?room2)] + :deletions [(in ?actor ?room1) + (in ?person1 ?room1)] + }) + + (define-action accompany2 [?actor ?person1 ?person2 ?room] + {:preconditions [(robot ?actor) + (person ?person1) + (person ?person2) + (can accompany ?actor ?person1 ?person2) + (room ?room) + (in ?actor ?room) + (in ?person1 ?room) + (in ?person2 ?room) + (not (= ?actor ?person1)) + (not (= ?actor ?person2)) + (not (= ?person1 ?person2))] + :additions [(accompanies ?person1 ?person2)] + :deletions [] + }) + + (define-action openDoor [?actor ?room] + {:preconditions [(robot ?actor) + (room ?room) + (in ?actor ?room) + (not (open (door ?room)))] + :additions [(open (door ?room))] + :deletions [(not (open (door ?room)))] + }) + (define-action stayInRoom [?actor ?room] + {:preconditions [(in ?actor ?room) + (room ?room)] + :additions [(in ?actor ?room)] + :deletions [] + }) + (define-action staySameRoom [?actor ?person] + {:preconditions [(robot ?actor) + (sameroom ?actor ?person) + (person ?person) + (in ?actor ?room) + (in ?person ?room) + (room ?room)] + :additions [(sameroom ?actor ?person)] + :deletions [] + }) + + ] + } + + :goals {G1 {:priority 1.0 + :state [(not (open (door room1)))]} + + G2a {:priority 1.0 + :state [(in prisoner room1)]} + + G2b {:priority 1.0 + :state [(in guard room1)]} + + G3 {:priority 1.0 + :state [(sameroom guard prisoner)]} + + G4 {:priority 2.1 + :state [(accompanies prisoner commander)]} + } + + } \ No newline at end of file