Moved search algorithms to folder

This commit is contained in:
Brandon Rozek 2023-11-02 17:11:12 -04:00
parent 967b859ecc
commit 135852b74b
No known key found for this signature in database
GPG key ID: 26E457DA82C9F480
9 changed files with 33 additions and 30 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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";

View file

@ -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;

View file

@ -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.*;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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.