mirror of
https://github.com/RAIRLab/Spectra.git
synced 2025-05-23 09:50:23 +00:00
Fixes
This commit is contained in:
parent
e6cfb3e654
commit
fc1cbfb5ab
50 changed files with 377 additions and 155 deletions
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>edu.rpi.rair</groupId>
|
<groupId>com.naveensundarg</groupId>
|
||||||
<artifactId>planner</artifactId>
|
<artifactId>planner</artifactId>
|
||||||
<version>0.01</version>
|
<version>0.01</version>
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
(snark:initialize :verbose verbose)
|
(snark:initialize :verbose verbose)
|
||||||
(if (not verbose) (snark-deverbose) )
|
(if (not verbose) (snark-deverbose) )
|
||||||
(temp-sorts)
|
(temp-sorts)
|
||||||
(snark:run-time-limit 0.05)
|
(snark:run-time-limit 0.5)
|
||||||
(snark:assert-supported t)
|
(snark:assert-supported t)
|
||||||
(snark:assume-supported t)
|
(snark:assume-supported t)
|
||||||
(snark:prove-supported t)
|
(snark:prove-supported t)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.core.Logic;
|
import com.naveensundarg.shadow.prover.core.Logic;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.And;
|
import com.naveensundarg.shadow.prover.representations.formula.And;
|
||||||
|
@ -32,7 +32,7 @@ public class Action {
|
||||||
|
|
||||||
private final Compound shorthand;
|
private final Compound shorthand;
|
||||||
|
|
||||||
private Action(String name, Set<Formula> preconditions, Set<Formula> additions, Set<Formula> deletions, List<Variable> freeVariables) {
|
public Action(String name, Set<Formula> preconditions, Set<Formula> additions, Set<Formula> deletions, List<Variable> freeVariables) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.preconditions = preconditions;
|
this.preconditions = preconditions;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class Action {
|
||||||
this.trivial = computeTrivialOrNot();
|
this.trivial = computeTrivialOrNot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action(String name, Set<Formula> preconditions, Set<Formula> additions,
|
public Action(String name, Set<Formula> preconditions, Set<Formula> additions,
|
||||||
Set<Formula> deletions, List<Variable> freeVariables,
|
Set<Formula> deletions, List<Variable> freeVariables,
|
||||||
Compound shorthand
|
Compound shorthand
|
||||||
) {
|
) {
|
23
src/main/java/com/naveensundarg/planner/Context.java
Normal file
23
src/main/java/com/naveensundarg/planner/Context.java
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Context {
|
||||||
|
|
||||||
|
private final List<PlanMethod> planMethods;
|
||||||
|
private final boolean workFromScratch;
|
||||||
|
|
||||||
|
|
||||||
|
public Context(List<PlanMethod> planMethods, boolean workFromScratch) {
|
||||||
|
this.planMethods = planMethods;
|
||||||
|
this.workFromScratch = workFromScratch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlanMethod> getPlanMethods() {
|
||||||
|
return planMethods;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWorkFromScratch() {
|
||||||
|
return workFromScratch;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -19,7 +18,22 @@ public class ContextNormPlanner implements Planner {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Set<Plan>> plan(PlanningProblem problem, Set<Formula> background, Set<Action> actions, State start, State goal) {
|
public Optional<Set<Plan>> plan(PlanningProblem problem, Set<Formula> background, Set<Action> actions, State start, State goal) {
|
||||||
List<Plan> methods = problem.getPlanMethods();
|
|
||||||
|
Optional<Context> contextOpt = problem.getContextOpt();
|
||||||
|
|
||||||
|
if(contextOpt.isPresent()){
|
||||||
|
|
||||||
|
|
||||||
|
depthFirstPlanner.setWORK_FROM_SCRATCH(contextOpt.get().isWorkFromScratch());
|
||||||
|
|
||||||
|
|
||||||
|
return depthFirstPlanner.plan(problem, background, actions, start, goal);
|
||||||
|
|
||||||
|
|
||||||
|
} else{
|
||||||
|
|
||||||
|
return depthFirstPlanner.plan(problem, background, actions, start, goal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.Commons;
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
|
import com.naveensundarg.planner.utils.Visualizer;
|
||||||
import com.naveensundarg.shadow.prover.core.proof.Justification;
|
import com.naveensundarg.shadow.prover.core.proof.Justification;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Pair;
|
import com.naveensundarg.shadow.prover.utils.Pair;
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
import com.naveensundarg.shadow.prover.utils.Sets;
|
||||||
import edu.rpi.rair.utils.Commons;
|
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
import edu.rpi.rair.utils.Visualizer;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -22,7 +22,21 @@ public class DepthFirstPlanner implements Planner {
|
||||||
private static int MAX_DEPTH = 5;
|
private static int MAX_DEPTH = 5;
|
||||||
private static boolean EXHAUSTIVE_TILL_MAX_DEPTH = true;
|
private static boolean EXHAUSTIVE_TILL_MAX_DEPTH = true;
|
||||||
|
|
||||||
private static boolean USE_METHODS = true;
|
private boolean USE_METHODS, WORK_FROM_SCRATCH;
|
||||||
|
|
||||||
|
public DepthFirstPlanner(){
|
||||||
|
USE_METHODS = true;
|
||||||
|
WORK_FROM_SCRATCH = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWORK_FROM_SCRATCH() {
|
||||||
|
return WORK_FROM_SCRATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWORK_FROM_SCRATCH(boolean WORK_FROM_SCRATCH) {
|
||||||
|
this.WORK_FROM_SCRATCH = WORK_FROM_SCRATCH;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getMaxDepth() {
|
public static int getMaxDepth() {
|
||||||
return MAX_DEPTH;
|
return MAX_DEPTH;
|
||||||
|
@ -79,6 +93,10 @@ public class DepthFirstPlanner implements Planner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!WORK_FROM_SCRATCH){
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!EXHAUSTIVE_TILL_MAX_DEPTH) {
|
if (!EXHAUSTIVE_TILL_MAX_DEPTH) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Pair;
|
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
import com.naveensundarg.shadow.prover.utils.Sets;
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import edu.rpi.rair.Plan;
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 12/19/17.
|
* Created by naveensundarg on 12/19/17.
|
|
@ -1,5 +1,6 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.Visualizer;
|
||||||
import com.naveensundarg.shadow.prover.core.Prover;
|
import com.naveensundarg.shadow.prover.core.Prover;
|
||||||
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
||||||
import com.naveensundarg.shadow.prover.core.proof.Justification;
|
import com.naveensundarg.shadow.prover.core.proof.Justification;
|
||||||
|
@ -13,7 +14,6 @@ import com.naveensundarg.shadow.prover.utils.ImmutablePair;
|
||||||
import com.naveensundarg.shadow.prover.utils.Pair;
|
import com.naveensundarg.shadow.prover.utils.Pair;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
import com.naveensundarg.shadow.prover.utils.Sets;
|
||||||
import edu.rpi.rair.utils.Visualizer;
|
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,8 +23,6 @@ import java.util.Set;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static edu.rpi.rair.State.FALSE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/13/17.
|
* Created by naveensundarg on 1/13/17.
|
||||||
*/
|
*/
|
||||||
|
@ -314,7 +312,7 @@ public class Operations {
|
||||||
public static boolean conflicts(Set<Formula> background, State state1, State state2) {
|
public static boolean conflicts(Set<Formula> background, State state1, State state2) {
|
||||||
|
|
||||||
|
|
||||||
return proveCached(Sets.union(background, Sets.union(state1.getFormulae(), state2.getFormulae())), FALSE).isPresent();
|
return proveCached(Sets.union(background, Sets.union(state1.getFormulae(), state2.getFormulae())), State.FALSE).isPresent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.Visualizer;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import edu.rpi.rair.utils.Visualizer;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -1,5 +1,6 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.And;
|
import com.naveensundarg.shadow.prover.representations.formula.And;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
||||||
|
@ -8,16 +9,8 @@ import com.naveensundarg.shadow.prover.representations.value.Variable;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
import com.naveensundarg.shadow.prover.utils.Sets;
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
import us.bpsm.edn.Keyword;
|
|
||||||
import us.bpsm.edn.Symbol;
|
|
||||||
import us.bpsm.edn.parser.Parseable;
|
|
||||||
import us.bpsm.edn.parser.Parser;
|
|
||||||
import us.bpsm.edn.parser.Parsers;
|
|
||||||
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collector;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,8 +1,7 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -1,9 +1,8 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.core.Prover;
|
import com.naveensundarg.shadow.prover.core.Prover;
|
||||||
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.And;
|
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/13/17.
|
* Created by naveensundarg on 1/13/17.
|
|
@ -1,14 +1,13 @@
|
||||||
package edu.rpi.rair.inducers;
|
package com.naveensundarg.planner.inducers;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.*;
|
||||||
|
import com.naveensundarg.planner.utils.Commons;
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Value;
|
import com.naveensundarg.shadow.prover.representations.value.Value;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
||||||
import com.naveensundarg.shadow.prover.utils.Pair;
|
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
import com.naveensundarg.shadow.prover.utils.Sets;
|
||||||
import edu.rpi.rair.*;
|
|
||||||
import edu.rpi.rair.utils.Commons;
|
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
|
@ -1,23 +1,17 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import clojure.lang.Obj;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
|
import com.diogonunes.jcdp.color.api.Ansi;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.And;
|
import com.naveensundarg.shadow.prover.representations.formula.And;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Existential;
|
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Universal;
|
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Value;
|
import com.naveensundarg.shadow.prover.representations.value.Value;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
|
||||||
import edu.rpi.rair.State;
|
|
||||||
import us.bpsm.edn.parser.Parseable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,8 +69,12 @@ public class Commons {
|
||||||
return combinedMap;
|
return combinedMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ColoredPrinter cp = new ColoredPrinter.Builder(1, false).build();
|
||||||
|
|
||||||
public static<U, V, W> Object runAndTime(BiFunction<U, V, W> function, U u, V v, String message){
|
public static<U, V, W> Object runAndTime(BiFunction<U, V, W> function, U u, V v, String message){
|
||||||
|
|
||||||
|
cp.setAttribute(Ansi.Attribute.BOLD);
|
||||||
|
|
||||||
long start, end;
|
long start, end;
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
|
@ -86,8 +84,18 @@ public class Commons {
|
||||||
end = System.currentTimeMillis();
|
end = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Timing for: " + message + (end - start)/1000 + " s");
|
cp.println("Timing for: " + message + (end - start)/1000 + " s");
|
||||||
|
|
||||||
|
if(w!=null){
|
||||||
|
cp.println(w);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
cp.setForegroundColor(Ansi.FColor.RED);
|
||||||
|
cp.println("COULD NOT PLAN");
|
||||||
|
}
|
||||||
|
|
||||||
|
cp.clear();
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import com.diogonunes.jcdp.color.api.AbstractColoredPrinter;
|
import com.diogonunes.jcdp.color.api.AbstractColoredPrinter;
|
|
@ -1,23 +1,22 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import edu.rpi.rair.Goal;
|
import com.naveensundarg.planner.Goal;
|
||||||
import edu.rpi.rair.PlanMethod;
|
import com.naveensundarg.planner.PlanMethod;
|
||||||
import edu.rpi.rair.State;
|
import com.naveensundarg.planner.State;
|
||||||
import us.bpsm.edn.Keyword;
|
import us.bpsm.edn.Keyword;
|
||||||
import us.bpsm.edn.parser.Parseable;
|
import us.bpsm.edn.parser.Parseable;
|
||||||
import us.bpsm.edn.parser.Parser;
|
import us.bpsm.edn.parser.Parser;
|
||||||
import us.bpsm.edn.parser.Parsers;
|
import us.bpsm.edn.parser.Parsers;
|
||||||
import us.bpsm.edn.parser.Token;
|
import us.bpsm.edn.parser.Token;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static edu.rpi.rair.utils.Reader.readPlanMethodsFrom;
|
import static com.naveensundarg.planner.utils.Reader.readPlanMethodsFrom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/13/17.
|
* Created by naveensundarg on 1/13/17.
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.Action;
|
||||||
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
|
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class IndefiniteAction extends Action {
|
||||||
|
|
||||||
|
private IndefiniteAction(String name, Set<Formula> preconditions, Set<Formula> additions, Set<Formula> deletions, List<Variable> freeVariables) {
|
||||||
|
super(name, preconditions, additions, deletions, freeVariables);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +1,18 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import com.diogonunes.jcdp.color.api.Ansi;
|
import com.naveensundarg.planner.DepthFirstPlanner;
|
||||||
import com.google.common.collect.Sets;
|
import com.naveensundarg.planner.GoalTracker;
|
||||||
import com.naveensundarg.shadow.prover.core.Prover;
|
import com.naveensundarg.planner.Plan;
|
||||||
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
import com.naveensundarg.planner.Planner;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import edu.rpi.rair.*;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
import edu.rpi.rair.inducers.SimpleInducer;
|
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/15/17.
|
* Created by naveensundarg on 1/15/17.
|
||||||
|
@ -37,7 +32,7 @@ public class LearningSystem {
|
||||||
|
|
||||||
RunDemo.planningProblemWarmUp();
|
RunDemo.planningProblemWarmUp();
|
||||||
|
|
||||||
Visualizer.setShouldVisualize(false);
|
Visualizer.setShouldVisualize(true);
|
||||||
|
|
||||||
List<GoalTrackingProblem> goalTrackingProblemList1 = (GoalTrackingProblem.readFromFiles(Sandbox.class.getResourceAsStream("../problems/seriated/seriated_challenge_1.clj"),
|
List<GoalTrackingProblem> goalTrackingProblemList1 = (GoalTrackingProblem.readFromFiles(Sandbox.class.getResourceAsStream("../problems/seriated/seriated_challenge_1.clj"),
|
||||||
Sandbox.class.getResourceAsStream("../problems/seriated/methods.clj")));
|
Sandbox.class.getResourceAsStream("../problems/seriated/methods.clj")));
|
||||||
|
@ -69,10 +64,25 @@ public class LearningSystem {
|
||||||
// Plan plan1 = goalTracker1.adoptGoal(goalTrackingProblem1.getGoalNamed("G1")).get();
|
// Plan plan1 = goalTracker1.adoptGoal(goalTrackingProblem1.getGoalNamed("G1")).get();
|
||||||
//Plan plan2 = goalTracker2.adoptGoal(goalTrackingProblem2.getGoalNamed("G1")).get();
|
//Plan plan2 = goalTracker2.adoptGoal(goalTrackingProblem2.getGoalNamed("G1")).get();
|
||||||
|
|
||||||
BiFunction<GoalTracker, GoalTrackingProblem, Plan> run = (goalTracker, goalTrackingProblem) -> goalTracker.adoptGoal(goalTrackingProblem.getGoalNamed("G1")).get();
|
BiFunction<GoalTracker, GoalTrackingProblem, Plan> run = (goalTracker, goalTrackingProblem) -> {
|
||||||
|
Optional<Plan> planOptional = goalTracker.adoptGoal(goalTrackingProblem.getGoalNamed("G1"));
|
||||||
|
|
||||||
System.out.println(Commons.runAndTime(run, goalTracker1, goalTrackingProblem1, "Problem 1"));
|
if(planOptional.isPresent()){
|
||||||
System.out.println(Commons.runAndTime(run, goalTracker2, goalTrackingProblem2, "Problem 2"));
|
return planOptional.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
System.out.println("Could not find a plan");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Object plan1 = (Commons.runAndTime(run, goalTracker1, goalTrackingProblem1, "Problem 1"));
|
||||||
|
|
||||||
|
Object plan2 = (Commons.runAndTime(run, goalTracker2, goalTrackingProblem2, "Problem 2"));
|
||||||
|
|
||||||
|
|
||||||
|
Visualizer.unspool(10);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import clojure.lang.Obj;
|
import com.naveensundarg.planner.Context;
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Value;
|
import com.naveensundarg.shadow.prover.representations.value.Value;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import com.naveensundarg.shadow.prover.utils.Sets;
|
import com.naveensundarg.shadow.prover.utils.Sets;
|
||||||
import edu.rpi.rair.Action;
|
import com.naveensundarg.planner.Action;
|
||||||
import edu.rpi.rair.PlanMethod;
|
import com.naveensundarg.planner.PlanMethod;
|
||||||
import edu.rpi.rair.State;
|
import com.naveensundarg.planner.State;
|
||||||
import us.bpsm.edn.Keyword;
|
import us.bpsm.edn.Keyword;
|
||||||
import us.bpsm.edn.Symbol;
|
import us.bpsm.edn.Symbol;
|
||||||
import us.bpsm.edn.parser.Parseable;
|
import us.bpsm.edn.parser.Parseable;
|
||||||
|
@ -21,10 +20,11 @@ import us.bpsm.edn.parser.Token;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.security.Key;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.naveensundarg.planner.utils.Reader.readPlanMethodFrom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/13/17.
|
* Created by naveensundarg on 1/13/17.
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +41,13 @@ public class PlanningProblem {
|
||||||
private Set<Value> avoidIfPossible;
|
private Set<Value> avoidIfPossible;
|
||||||
private final List<PlanMethod> planMethods;
|
private final List<PlanMethod> planMethods;
|
||||||
|
|
||||||
|
private final Optional<Context> contextOpt;
|
||||||
|
|
||||||
|
private static final Keyword CONTEXT = Keyword.newKeyword("context");
|
||||||
|
private static final Keyword WORK_FROM_SCRATCH = Keyword.newKeyword("work-from-scratch");
|
||||||
|
private static final Keyword PLAN_METHODS = Keyword.newKeyword("plan-methods");
|
||||||
|
|
||||||
|
|
||||||
private static final Keyword BACKGROUND = Keyword.newKeyword("background");
|
private static final Keyword BACKGROUND = Keyword.newKeyword("background");
|
||||||
private static final Keyword START = Keyword.newKeyword("start");
|
private static final Keyword START = Keyword.newKeyword("start");
|
||||||
private static final Keyword GOAL = Keyword.newKeyword("goal");
|
private static final Keyword GOAL = Keyword.newKeyword("goal");
|
||||||
|
@ -67,6 +74,22 @@ public class PlanningProblem {
|
||||||
this.avoidIfPossible = avoidIfPossible;
|
this.avoidIfPossible = avoidIfPossible;
|
||||||
this.planMethods = CollectionUtils.newEmptyList();
|
this.planMethods = CollectionUtils.newEmptyList();
|
||||||
this.expectedActionSequencesOpt = Optional.empty();
|
this.expectedActionSequencesOpt = Optional.empty();
|
||||||
|
this.contextOpt = Optional.empty();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlanningProblem(Optional<Context> contextOpt, String name, Set<Formula> background, State start, State goal, Set<Action> actions, Set<Value> avoidIfPossible) {
|
||||||
|
|
||||||
|
this.background = background;
|
||||||
|
this.start = start;
|
||||||
|
this.actions = actions;
|
||||||
|
this.goal = goal;
|
||||||
|
this.name = name;
|
||||||
|
this.actionMap = CollectionUtils.newMap();
|
||||||
|
this.avoidIfPossible = avoidIfPossible;
|
||||||
|
this.planMethods = CollectionUtils.newEmptyList();
|
||||||
|
this.expectedActionSequencesOpt = Optional.empty();
|
||||||
|
this.contextOpt = contextOpt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +105,31 @@ public class PlanningProblem {
|
||||||
this.planMethods = CollectionUtils.newEmptyList();
|
this.planMethods = CollectionUtils.newEmptyList();
|
||||||
|
|
||||||
this.expectedActionSequencesOpt = Optional.of(expectedActionSequences);
|
this.expectedActionSequencesOpt = Optional.of(expectedActionSequences);
|
||||||
|
|
||||||
|
this.contextOpt = Optional.empty();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<PlanningProblem> readFromString(String input) throws Reader.ParsingException {
|
||||||
|
|
||||||
|
|
||||||
|
Parseable parseable = Parsers.newParseable(new StringReader(input));
|
||||||
|
Parser parser = Parsers.newParser(Parsers.defaultConfiguration());
|
||||||
|
|
||||||
|
List<PlanningProblem> planningProblems = CollectionUtils.newEmptyList();
|
||||||
|
|
||||||
|
Object nextValue = parser.nextValue(parseable);
|
||||||
|
|
||||||
|
while (!nextValue.equals(Token.END_OF_INPUT)) {
|
||||||
|
|
||||||
|
planningProblems.add(readFromObject(nextValue));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
nextValue = parser.nextValue(parseable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return planningProblems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<PlanningProblem> readFromFile(InputStream inputStream) throws Reader.ParsingException {
|
public static List<PlanningProblem> readFromFile(InputStream inputStream) throws Reader.ParsingException {
|
||||||
|
@ -118,7 +166,9 @@ public class PlanningProblem {
|
||||||
|
|
||||||
List<?> actionDefinitions = (List<?>) planningProblemSpec.get(ACTION);
|
List<?> actionDefinitions = (List<?>) planningProblemSpec.get(ACTION);
|
||||||
|
|
||||||
|
System.out.println(planningProblemSpec.get(NAME));
|
||||||
String name = planningProblemSpec.get(NAME).toString();
|
String name = planningProblemSpec.get(NAME).toString();
|
||||||
|
|
||||||
Set<Action> actions = readActionsFrom(actionDefinitions);
|
Set<Action> actions = readActionsFrom(actionDefinitions);
|
||||||
Map<String, Action> actionMap = CollectionUtils.newMap();
|
Map<String, Action> actionMap = CollectionUtils.newMap();
|
||||||
|
|
||||||
|
@ -126,6 +176,25 @@ public class PlanningProblem {
|
||||||
actionMap.put(action.getName(), action);
|
actionMap.put(action.getName(), action);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Optional<Context> contextOpt = Optional.empty();
|
||||||
|
if(planningProblemSpec.containsKey(CONTEXT)){
|
||||||
|
Map<?, ?> contextSpec = (Map<?, ?>) planningProblemSpec.get(CONTEXT);
|
||||||
|
boolean workFromScratch = contextSpec.get(WORK_FROM_SCRATCH).toString().equals("true");
|
||||||
|
List<?> planMethodSpecs = (List<?> )contextSpec.get(PLAN_METHODS);
|
||||||
|
List<PlanMethod> planMethods = CollectionUtils.newEmptyList();
|
||||||
|
|
||||||
|
if(planMethodSpecs!=null){
|
||||||
|
|
||||||
|
for(Object planMethodSpec: (List<?>) planMethodSpecs){
|
||||||
|
planMethods.add(readPlanMethodFrom((List<?>) planMethodSpec));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
contextOpt = Optional.of(new Context(planMethods, workFromScratch));
|
||||||
|
|
||||||
|
}
|
||||||
if(planningProblemSpec.containsKey(EXPECTED_PLANS)){
|
if(planningProblemSpec.containsKey(EXPECTED_PLANS)){
|
||||||
List<?> plans = (List<?>) planningProblemSpec.get(EXPECTED_PLANS);
|
List<?> plans = (List<?>) planningProblemSpec.get(EXPECTED_PLANS);
|
||||||
|
|
||||||
|
@ -150,11 +219,12 @@ public class PlanningProblem {
|
||||||
}).collect(Collectors.toSet());
|
}).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new PlanningProblem(name, background, State.initializeWith(start),
|
return new PlanningProblem(name, background, State.initializeWith(start),
|
||||||
State.initializeWith(goal), actions, avoidIfPossible, expectedActions);
|
State.initializeWith(goal), actions, avoidIfPossible, expectedActions);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return new PlanningProblem(name, background, State.initializeWith(start),
|
return new PlanningProblem(contextOpt, name, background, State.initializeWith(start),
|
||||||
State.initializeWith(goal),actions, avoidIfPossible);
|
State.initializeWith(goal),actions, avoidIfPossible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,6 +413,9 @@ public class PlanningProblem {
|
||||||
return avoidIfPossible;
|
return avoidIfPossible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Context> getContextOpt() {
|
||||||
|
return contextOpt;
|
||||||
|
}
|
||||||
|
|
||||||
public List<PlanMethod> getPlanMethods() {
|
public List<PlanMethod> getPlanMethods() {
|
||||||
return planMethods;
|
return planMethods;
|
|
@ -1,4 +1,4 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
import com.naveensundarg.shadow.prover.representations.formula.Formula;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
import com.naveensundarg.shadow.prover.representations.value.Compound;
|
||||||
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
import com.naveensundarg.shadow.prover.representations.value.Variable;
|
||||||
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
|
||||||
import edu.rpi.rair.PlanMethod;
|
import com.naveensundarg.planner.PlanMethod;
|
||||||
import us.bpsm.edn.Keyword;
|
import us.bpsm.edn.Keyword;
|
||||||
import us.bpsm.edn.Symbol;
|
import us.bpsm.edn.Symbol;
|
||||||
import us.bpsm.edn.parser.Parseable;
|
import us.bpsm.edn.parser.Parseable;
|
||||||
|
@ -17,7 +17,6 @@ import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class Reader {
|
public class Reader {
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import com.diogonunes.jcdp.color.api.Ansi;
|
import com.diogonunes.jcdp.color.api.Ansi;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.naveensundarg.shadow.prover.core.Prover;
|
import com.naveensundarg.planner.Goal;
|
||||||
|
import com.naveensundarg.planner.GoalTracker;
|
||||||
|
import com.naveensundarg.planner.Inducer;
|
||||||
|
import com.naveensundarg.planner.Plan;
|
||||||
|
import com.naveensundarg.shadow.prover.core.Prover;
|
||||||
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
import com.naveensundarg.shadow.prover.core.SnarkWrapper;
|
||||||
import com.naveensundarg.shadow.prover.utils.Problem;
|
|
||||||
import com.naveensundarg.shadow.prover.utils.ProblemReader;
|
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import edu.rpi.rair.*;
|
import com.naveensundarg.planner.inducers.SimpleInducer;
|
||||||
import edu.rpi.rair.inducers.SimpleInducer;
|
|
||||||
import edu.rpi.rair.utils.GoalTrackingProblem;
|
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +57,7 @@ public class RunDemo {
|
||||||
|
|
||||||
Visualizer.setShouldVisualize(false);
|
Visualizer.setShouldVisualize(false);
|
||||||
|
|
||||||
runProblem("../problems/seriated/seriated_challenge_1.clj");
|
runProblem("../problems/heroism/setup.clj");
|
||||||
// runProblem("seriated_challenge_2.clj");
|
// runProblem("seriated_challenge_2.clj");
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,9 +76,11 @@ public class RunDemo {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
Goal g1 = goalTrackingProblem.getGoalNamed("G1");
|
Goal g1 = goalTrackingProblem.getGoalNamed("G1");
|
||||||
|
Goal g2 = goalTrackingProblem.getGoalNamed("G2");
|
||||||
|
|
||||||
|
|
||||||
tryAndAddGoal(g1, goalTracker);
|
tryAndAddGoal(g1, goalTracker);
|
||||||
|
tryAndAddGoal(g2, goalTracker);
|
||||||
|
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
|
@ -1,7 +1,6 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import edu.rpi.rair.PlanMethod;
|
import com.naveensundarg.planner.PlanMethod;
|
||||||
import edu.rpi.rair.Planner;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package edu.rpi.rair.utils;
|
package com.naveensundarg.planner.utils;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import com.diogonunes.jcdp.color.api.Ansi;
|
import com.diogonunes.jcdp.color.api.Ansi;
|
|
@ -0,0 +1,27 @@
|
||||||
|
{:definitions
|
||||||
|
{:name "heroism"
|
||||||
|
:background [(forall [?x ?y]
|
||||||
|
(iff (and (Inside ?x ?y) (OnFire ?y))
|
||||||
|
(not (Safe ?x))))
|
||||||
|
(forall [?x ?y]
|
||||||
|
(iff (not (Inside ?x ?y))
|
||||||
|
(Outside ?x ?y)))
|
||||||
|
(not (= self stranger))]
|
||||||
|
:start [(Inside stranger building)
|
||||||
|
(Outside self building)]
|
||||||
|
|
||||||
|
:actions [(define-action movePersonFrom [?person ?building]
|
||||||
|
{:preconditions [(Inside self ?building)]
|
||||||
|
:additions [(Outside stranger ?building) (Outside self ?building)]
|
||||||
|
:deletions [(Inside stranger ?building) (Inside self ?building)]})
|
||||||
|
|
||||||
|
(define-action moveInside [?building]
|
||||||
|
{:preconditions [(Outside self ?building)]
|
||||||
|
:additions [(Inside self ?building)]
|
||||||
|
:deletions [(Outside self ?building)]})]}
|
||||||
|
|
||||||
|
:goals {G1 {:priority 5.0
|
||||||
|
:state [(Safe self)]}
|
||||||
|
|
||||||
|
G2 {:priority 1.0
|
||||||
|
:state [(Safe stranger)]}}}
|
|
@ -20,7 +20,9 @@
|
||||||
;;; Sizes of cups
|
;;; Sizes of cups
|
||||||
(< (size a) (size b))
|
(< (size a) (size b))
|
||||||
(< (size b) (size c))
|
(< (size b) (size c))
|
||||||
(< (size c) (size d))]
|
(< (size c) (size d))
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
:start [(In a b)
|
:start [(In a b)
|
||||||
|
@ -30,6 +32,13 @@
|
||||||
|
|
||||||
:goal [ ]
|
:goal [ ]
|
||||||
|
|
||||||
|
:context { :work-from-scratch false
|
||||||
|
:plan-methods
|
||||||
|
[(define-method planMethod [?b ?d ?c]
|
||||||
|
{:goal [(In ?b ?c) (In ?c ?d)]
|
||||||
|
:while [(< (size ?c) (size ?d)) (< (size ?b) (size ?c)) (In ?b ?d) (Empty ?c)]
|
||||||
|
:actions [(removeFrom ?b ?d) (placeInside ?b ?c) (placeInside ?c ?d)]})]}
|
||||||
|
|
||||||
:actions [(define-action placeInside [?x ?y]
|
:actions [(define-action placeInside [?x ?y]
|
||||||
{:preconditions [(< (size ?x) (size ?y))
|
{:preconditions [(< (size ?x) (size ?y))
|
||||||
(Empty ?y)]
|
(Empty ?y)]
|
||||||
|
@ -41,13 +50,10 @@
|
||||||
:additions [(Empty ?y)]
|
:additions [(Empty ?y)]
|
||||||
:deletions [(In ?x ?y)]})]}
|
:deletions [(In ?x ?y)]})]}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:goals {G1 {:priority 1.0
|
:goals {G1 {:priority 1.0
|
||||||
:context { :work-from-scratch false
|
|
||||||
:plan-methods
|
|
||||||
(define-method planMethod [?b ?d ?c]
|
|
||||||
{:goal [(In ?b ?c) (In ?c ?d)]
|
|
||||||
:while [(< (size ?c) (size ?d)) (< (size ?b) (size ?c)) (In ?b ?d) (Empty ?c)]
|
|
||||||
:actions [(removeFrom ?b ?d) (placeInside ?b ?c) (placeInside ?c ?d)]})}
|
|
||||||
:state [(In a b)
|
:state [(In a b)
|
||||||
(In b c)
|
(In b c)
|
||||||
(In c d)]}}
|
(In c d)]}}
|
|
@ -49,11 +49,14 @@
|
||||||
:additions [(Empty ?y)]
|
:additions [(Empty ?y)]
|
||||||
:deletions [(In ?x ?y)]} )]
|
:deletions [(In ?x ?y)]} )]
|
||||||
|
|
||||||
|
:context { :work-from-scratch false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:goals {G1 {:priority 1.0
|
:goals {G1 {:priority 1.0
|
||||||
|
|
||||||
|
|
||||||
:state [(In a b)
|
:state [(In a b)
|
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
:background [
|
||||||
|
|
||||||
|
;;; Sizes of cups
|
||||||
|
(< (size (cup 1)) (size (cup 1)))
|
||||||
|
(< (size (cup 1)) (size (cup 2)))
|
||||||
|
(< (size (cup 1)) (size (cup 3)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(< (size (cup 99)) (size (cup 100)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
(exist [?y] (and (isColor ?y PURPLE)
|
||||||
|
(isShape ?y CUBE)))
|
||||||
|
|
||||||
|
(cup 1)
|
||||||
|
(cup 2)
|
||||||
|
|
||||||
|
|
||||||
|
(cup 100)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:background [ ;; Transitivity of <
|
||||||
|
(forall [?x ?y ?z]
|
||||||
|
(if (and (< (size ?x) (size ?y))
|
||||||
|
(< (size ?y) (size ?z)))
|
||||||
|
(< (size ?x) (size ?z))))
|
||||||
|
;; Asymmetry of <
|
||||||
|
(forall [?x ?y]
|
||||||
|
(iff (< (size ?x) (size ?y))
|
||||||
|
(not (< (size ?y) (size ?x)))))
|
||||||
|
|
||||||
|
;; If there is something inside a cup, it is not empty.
|
||||||
|
(forall [?y]
|
||||||
|
(if (exists [?x] (In ?x ?y))
|
||||||
|
(not (Empty ?y))))
|
||||||
|
|
||||||
|
;;; Sizes of cups
|
||||||
|
:ARITHMETIC_AXIOMS
|
||||||
|
|
||||||
|
(forall [?number] (= number? (size (cup ?number))))
|
||||||
|
|
||||||
|
]
|
||||||
|
|
20
src/main/resources/com/naveensundarg/planner/temp.clj
Normal file
20
src/main/resources/com/naveensundarg/planner/temp.clj
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
;; j is an A
|
||||||
|
;; all A are afraid of B
|
||||||
|
;; what is j afraid of?
|
||||||
|
|
||||||
|
(seq P 2 3 A)
|
||||||
|
(seq Q 2 3 B)
|
||||||
|
(seq all A are afraid of M)
|
||||||
|
(seq all B are afraid of N)
|
||||||
|
(Goal (seq What is P afraid of?))
|
||||||
|
;;;
|
||||||
|
(action A)
|
||||||
|
|
||||||
|
(if (and (seq ?individual is a ?class1)
|
||||||
|
(seq all ?class1 are afraid of ?class2)
|
||||||
|
(Goal (seq what is ?individual afraid of)))
|
||||||
|
(Action ?class2))
|
||||||
|
|
||||||
|
;;; given background B, goal G and plan P=>
|
||||||
|
;; let sub(B) be all the formulae containing individuals in G and P. And let it be closed wrt to inviduals.
|
||||||
|
;; then (if (and sub(B) G) variablize(P)) is a hypothesis.
|
|
@ -1,7 +0,0 @@
|
||||||
;; (removeFrom ?x ?y) => "Remove ?x from ?y"
|
|
||||||
;; (placeInside ?x ?y) ==> "Place ?x inside ?y"
|
|
||||||
|
|
||||||
(define-method planMethod [?b ?d ?c]
|
|
||||||
{:goal [(In ?b ?c) (In ?c ?d)]
|
|
||||||
:while [(< (size ?c) (size ?d)) (< (size ?b) (size ?c)) (In ?b ?d) (Empty ?c)]
|
|
||||||
:actions [(removeFrom ?b ?d) (placeInside ?b ?c) (placeInside ?c ?d)]})
|
|
|
@ -1,16 +0,0 @@
|
||||||
{G1 {:priority 6.0
|
|
||||||
:state [(not (open (door room1)))]}
|
|
||||||
|
|
||||||
G2 {:priority 6.0
|
|
||||||
:state [(in prisoner room1)]}
|
|
||||||
|
|
||||||
G3 {:priority 6.0
|
|
||||||
:state [(forall [?room]
|
|
||||||
(if (in prisoner ?room)
|
|
||||||
(in self ?room)))]}
|
|
||||||
G4 {:priority 3.0
|
|
||||||
:state [(in prisoner room2)
|
|
||||||
(in self room2)]}
|
|
||||||
G5 {:priority 2.0
|
|
||||||
|
|
||||||
:state [(interrogates commander prisoner)]}}
|
|
|
@ -1,7 +1,7 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
|
import com.naveensundarg.planner.utils.PlanningProblem;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import edu.rpi.rair.utils.PlanningProblem;
|
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
|
@ -12,8 +12,6 @@ import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.testng.Assert.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/13/17.
|
* Created by naveensundarg on 1/13/17.
|
||||||
*/
|
*/
|
|
@ -1,14 +1,12 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import com.diogonunes.jcdp.color.api.Ansi;
|
import com.diogonunes.jcdp.color.api.Ansi;
|
||||||
|
import com.naveensundarg.planner.utils.GoalTrackingProblem;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import edu.rpi.rair.utils.GoalTrackingProblem;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.testng.Assert.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 1/15/17.
|
* Created by naveensundarg on 1/15/17.
|
||||||
*/
|
*/
|
|
@ -1,9 +1,9 @@
|
||||||
package edu.rpi.rair;
|
package com.naveensundarg.planner;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import com.diogonunes.jcdp.color.api.Ansi;
|
import com.diogonunes.jcdp.color.api.Ansi;
|
||||||
|
import com.naveensundarg.planner.utils.GoalTrackingProblem;
|
||||||
import com.naveensundarg.shadow.prover.utils.Reader;
|
import com.naveensundarg.shadow.prover.utils.Reader;
|
||||||
import edu.rpi.rair.utils.GoalTrackingProblem;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
Loading…
Add table
Reference in a new issue