From d6bc88566f6dbc2a9ffa655f43e8fed3d4c82e41 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Wed, 29 Mar 2023 21:17:09 -0400 Subject: [PATCH] Runner CLI Script --- run_spectra.sh | 8 +++ snark-20120808r02/snark-interface.lisp | 2 +- .../naveensundarg/planner/utils/Runner.java | 65 +++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 run_spectra.sh create mode 100644 src/main/java/com/naveensundarg/planner/utils/Runner.java diff --git a/run_spectra.sh b/run_spectra.sh new file mode 100755 index 0000000..4d2de45 --- /dev/null +++ b/run_spectra.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# TODO: Argument check and show usage + +mvn -q exec:java -Dexec.mainClass="com.naveensundarg.planner.utils.Runner" -Dexec.args="$1" + +#mvn exec:java -Dexec.mainClass="com.naveensundarg.planner.utils.Runner" -Dexec.args="$PWD/src/main/resources/com/naveensundarg/planner/problems/ai2thor/FloorPlan28.clj" + diff --git a/snark-20120808r02/snark-interface.lisp b/snark-20120808r02/snark-interface.lisp index 5e60524..12866e9 100644 --- a/snark-20120808r02/snark-interface.lisp +++ b/snark-20120808r02/snark-interface.lisp @@ -89,7 +89,7 @@ (defun setup-snark (&key (time-limit 5) (verbose nil)) (snark:initialize :verbose verbose) -;; (if (not verbose) (snark-deverbose) ) + (if (not verbose) (snark-deverbose) ) (snark:run-time-limit 5) (snark:assert-supported t) (snark:assume-supported t) diff --git a/src/main/java/com/naveensundarg/planner/utils/Runner.java b/src/main/java/com/naveensundarg/planner/utils/Runner.java new file mode 100644 index 0000000..4b31bfd --- /dev/null +++ b/src/main/java/com/naveensundarg/planner/utils/Runner.java @@ -0,0 +1,65 @@ +package com.naveensundarg.planner.utils; + +import com.naveensundarg.planner.BreadthFirstPlanner; +import com.naveensundarg.planner.Plan; +import com.naveensundarg.planner.Planner; +import com.naveensundarg.shadow.prover.utils.Reader; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.*; + + +public final class Runner { + + public static void main(String[] args) { + + System.out.println("--------------- Starting Spectra --------------- "); + + + // Grab filename from argument list + if (args.length < 1) { + System.out.println("Need to include filename with planning problem and description."); + return; + } + String fileName = args[0]; + + + // Read File + FileInputStream fileStream; + try { + fileStream = new FileInputStream(fileName); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return; + } + + // Parse File + List planningProblemList; + try { + planningProblemList = PlanningProblem.readFromFile(fileStream); + + } catch (Reader.ParsingException e) { + e.printStackTrace(); + return; + } + + Planner breadthFirstPlanner = new BreadthFirstPlanner(); + + for (PlanningProblem planningProblem : planningProblemList) { + Optional> optionalPlans = breadthFirstPlanner.plan( + planningProblem.getBackground(), + planningProblem.getActions(), + planningProblem.getStart(), + planningProblem.getGoal()); + + if(optionalPlans.isPresent()) { + System.out.println(optionalPlans.get().toString()); + } + else { + System.out.println("FAILED"); + } + } + + } +} \ No newline at end of file