mirror of
https://github.com/RAIRLab/Spectra.git
synced 2024-11-09 11:10:34 -05:00
Moved search algorithms to folder
This commit is contained in:
parent
967b859ecc
commit
135852b74b
9 changed files with 33 additions and 30 deletions
|
@ -2,6 +2,7 @@ package org.rairlab.planner;
|
||||||
|
|
||||||
import org.rairlab.planner.utils.PlanningProblem;
|
import org.rairlab.planner.utils.PlanningProblem;
|
||||||
import org.rairlab.shadow.prover.representations.formula.Formula;
|
import org.rairlab.shadow.prover.representations.formula.Formula;
|
||||||
|
import org.rairlab.planner.search.DepthFirstPlanner;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.rairlab.planner.utils.PlanningProblem;
|
||||||
import org.rairlab.shadow.prover.representations.formula.Formula;
|
import org.rairlab.shadow.prover.representations.formula.Formula;
|
||||||
import org.rairlab.shadow.prover.utils.CollectionUtils;
|
import org.rairlab.shadow.prover.utils.CollectionUtils;
|
||||||
import org.rairlab.shadow.prover.utils.Sets;
|
import org.rairlab.shadow.prover.utils.Sets;
|
||||||
|
import org.rairlab.planner.search.DepthFirstPlanner;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package org.rairlab.planner;
|
package org.rairlab.planner;
|
||||||
|
|
||||||
import org.rairlab.planner.utils.PlanningProblem;
|
import org.rairlab.planner.utils.PlanningProblem;
|
||||||
import org.rairlab.shadow.prover.core.ccprovers.CognitiveCalculusProver;
|
import org.rairlab.planner.heuristics.ConstantHeuristic;
|
||||||
import org.rairlab.shadow.prover.core.proof.Justification;
|
import org.rairlab.planner.search.AStarPlanner;
|
||||||
import org.rairlab.shadow.prover.representations.formula.Formula;
|
|
||||||
import org.rairlab.shadow.prover.utils.Problem;
|
|
||||||
import org.rairlab.shadow.prover.utils.ProblemReader;
|
|
||||||
import org.rairlab.shadow.prover.utils.Reader;
|
import org.rairlab.shadow.prover.utils.Reader;
|
||||||
import py4j.GatewayServer;
|
import py4j.GatewayServer;
|
||||||
|
|
||||||
|
@ -14,24 +12,20 @@ import java.net.Inet4Address;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
public final class Py4JServer {
|
public final class Py4JServer {
|
||||||
|
|
||||||
|
private AStarPlanner astarplanner;
|
||||||
private DepthFirstPlanner depthFirstPlanner;
|
|
||||||
|
|
||||||
|
|
||||||
public Py4JServer(){
|
public Py4JServer(){
|
||||||
|
astarplanner = new AStarPlanner();
|
||||||
depthFirstPlanner = new DepthFirstPlanner();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Planner getPlanner(){
|
public AStarPlanner getPlanner(){
|
||||||
return depthFirstPlanner;
|
return astarplanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws UnknownHostException {
|
public static void main(String[] args) throws UnknownHostException {
|
||||||
|
@ -49,29 +43,26 @@ public final class Py4JServer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList newEmptyList(){
|
|
||||||
|
|
||||||
return new ArrayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String proveFromDescription(String fileString){
|
public String proveFromDescription(String fileString){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
List<PlanningProblem> planningProblemList = (PlanningProblem.readFromFile(new ByteArrayInputStream(fileString.getBytes())));
|
List<PlanningProblem> planningProblemList = (PlanningProblem.readFromFile(new ByteArrayInputStream(fileString.getBytes())));
|
||||||
|
|
||||||
Planner depthFirstPlanner = new DepthFirstPlanner();
|
AStarPlanner astarplanner = new AStarPlanner();
|
||||||
|
|
||||||
PlanningProblem planningProblem = planningProblemList.get(0);
|
PlanningProblem planningProblem = planningProblemList.get(0);
|
||||||
|
|
||||||
|
|
||||||
Optional<Set<Plan>> optionalPlans = depthFirstPlanner.plan(
|
Set<Plan> plans = astarplanner.plan(
|
||||||
planningProblem.getBackground(),
|
planningProblem.getBackground(),
|
||||||
planningProblem.getActions(),
|
planningProblem.getActions(),
|
||||||
planningProblem.getStart(),
|
planningProblem.getStart(),
|
||||||
planningProblem.getGoal());
|
planningProblem.getGoal(),
|
||||||
|
ConstantHeuristic::h
|
||||||
|
);
|
||||||
|
|
||||||
if(optionalPlans.isPresent()) {
|
if(plans.size() > 0) {
|
||||||
return optionalPlans.get().toString();
|
return plans.toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "FAILED";
|
return "FAILED";
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package org.rairlab.planner;
|
package org.rairlab.planner.search;
|
||||||
|
|
||||||
import org.rairlab.shadow.prover.representations.formula.Formula;
|
import org.rairlab.shadow.prover.representations.formula.Formula;
|
||||||
|
|
||||||
|
import org.rairlab.planner.State;
|
||||||
|
import org.rairlab.planner.Action;
|
||||||
|
import org.rairlab.planner.Plan;
|
||||||
|
import org.rairlab.planner.Operations;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
|
@ -1,7 +1,11 @@
|
||||||
package org.rairlab.planner;
|
package org.rairlab.planner.search;
|
||||||
|
|
||||||
import org.rairlab.shadow.prover.representations.formula.Formula;
|
import org.rairlab.shadow.prover.representations.formula.Formula;
|
||||||
|
|
||||||
import org.rairlab.planner.Action;
|
import org.rairlab.planner.Action;
|
||||||
|
import org.rairlab.planner.State;
|
||||||
|
import org.rairlab.planner.Plan;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.rairlab.planner;
|
package org.rairlab.planner.search;
|
||||||
|
|
||||||
import org.rairlab.planner.utils.Commons;
|
import org.rairlab.planner.utils.Commons;
|
||||||
import org.rairlab.planner.utils.PlanningProblem;
|
import org.rairlab.planner.utils.PlanningProblem;
|
||||||
import org.rairlab.planner.utils.Visualizer;
|
import org.rairlab.planner.utils.Visualizer;
|
||||||
|
import org.rairlab.planner.*;
|
||||||
|
|
||||||
import org.rairlab.shadow.prover.core.proof.Justification;
|
import org.rairlab.shadow.prover.core.proof.Justification;
|
||||||
import org.rairlab.shadow.prover.representations.formula.Formula;
|
import org.rairlab.shadow.prover.representations.formula.Formula;
|
||||||
import org.rairlab.shadow.prover.utils.CollectionUtils;
|
import org.rairlab.shadow.prover.utils.CollectionUtils;
|
|
@ -1,7 +1,7 @@
|
||||||
package org.rairlab.planner.utils;
|
package org.rairlab.planner.utils;
|
||||||
|
|
||||||
import com.diogonunes.jcdp.color.ColoredPrinter;
|
import com.diogonunes.jcdp.color.ColoredPrinter;
|
||||||
import org.rairlab.planner.DepthFirstPlanner;
|
import org.rairlab.planner.search.DepthFirstPlanner;
|
||||||
import org.rairlab.planner.GoalTracker;
|
import org.rairlab.planner.GoalTracker;
|
||||||
import org.rairlab.planner.Plan;
|
import org.rairlab.planner.Plan;
|
||||||
import org.rairlab.planner.Planner;
|
import org.rairlab.planner.Planner;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.rairlab.planner.utils;
|
package org.rairlab.planner.utils;
|
||||||
|
|
||||||
import org.rairlab.planner.AStarPlanner;
|
import org.rairlab.planner.search.AStarPlanner;
|
||||||
import org.rairlab.planner.Plan;
|
import org.rairlab.planner.Plan;
|
||||||
import org.rairlab.planner.heuristics.ConstantHeuristic;
|
import org.rairlab.planner.heuristics.ConstantHeuristic;
|
||||||
import org.rairlab.shadow.prover.utils.Reader;
|
import org.rairlab.shadow.prover.utils.Reader;
|
||||||
|
|
|
@ -3,13 +3,12 @@ package org.rairlab.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 org.rairlab.planner.*;
|
import org.rairlab.planner.*;
|
||||||
import org.rairlab.shadow.prover.representations.formula.Predicate;
|
import org.rairlab.planner.search.DepthFirstPlanner;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.rairlab.shadow.prover.utils.Reader.readFormulaFromString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by naveensundarg on 12/22/17.
|
* Created by naveensundarg on 12/22/17.
|
||||||
|
|
Loading…
Reference in a new issue