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.shadow.prover.representations.formula.Formula;
import org.rairlab.planner.search.DepthFirstPlanner;
import java.util.Optional;
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.utils.CollectionUtils;
import org.rairlab.shadow.prover.utils.Sets;
import org.rairlab.planner.search.DepthFirstPlanner;
import java.util.Comparator;
import java.util.Optional;

View file

@ -1,11 +1,9 @@
package org.rairlab.planner;
import org.rairlab.planner.utils.PlanningProblem;
import org.rairlab.shadow.prover.core.ccprovers.CognitiveCalculusProver;
import org.rairlab.shadow.prover.core.proof.Justification;
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.planner.heuristics.ConstantHeuristic;
import org.rairlab.planner.search.AStarPlanner;
import org.rairlab.shadow.prover.utils.Reader;
import py4j.GatewayServer;
@ -14,24 +12,20 @@ import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import java.util.stream.Collectors;
public final class Py4JServer {
private DepthFirstPlanner depthFirstPlanner;
private AStarPlanner astarplanner;
public Py4JServer(){
depthFirstPlanner = new DepthFirstPlanner();
astarplanner = new AStarPlanner();
}
public Planner getPlanner(){
return depthFirstPlanner;
public AStarPlanner getPlanner(){
return astarplanner;
}
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){
try {
List<PlanningProblem> planningProblemList = (PlanningProblem.readFromFile(new ByteArrayInputStream(fileString.getBytes())));
Planner depthFirstPlanner = new DepthFirstPlanner();
AStarPlanner astarplanner = new AStarPlanner();
PlanningProblem planningProblem = planningProblemList.get(0);
Optional<Set<Plan>> optionalPlans = depthFirstPlanner.plan(
Set<Plan> plans = astarplanner.plan(
planningProblem.getBackground(),
planningProblem.getActions(),
planningProblem.getStart(),
planningProblem.getGoal());
planningProblem.getGoal(),
ConstantHeuristic::h
);
if(optionalPlans.isPresent()) {
return optionalPlans.get().toString();
if(plans.size() > 0) {
return plans.toString();
}
else {
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.planner.State;
import org.rairlab.planner.Action;
import org.rairlab.planner.Plan;
import org.rairlab.planner.Operations;
import java.util.*;
import java.util.function.Function;
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.planner.Action;
import org.rairlab.planner.State;
import org.rairlab.planner.Plan;
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.PlanningProblem;
import org.rairlab.planner.utils.Visualizer;
import org.rairlab.planner.*;
import org.rairlab.shadow.prover.core.proof.Justification;
import org.rairlab.shadow.prover.representations.formula.Formula;
import org.rairlab.shadow.prover.utils.CollectionUtils;

View file

@ -1,7 +1,7 @@
package org.rairlab.planner.utils;
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.Plan;
import org.rairlab.planner.Planner;

View file

@ -1,6 +1,6 @@
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.heuristics.ConstantHeuristic;
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.api.Ansi;
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.List;
import java.util.stream.Collectors;
import static org.rairlab.shadow.prover.utils.Reader.readFormulaFromString;
/**
* Created by naveensundarg on 12/22/17.