Skip to content

Commit

Permalink
Moved search algorithms to folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-Rozek committed Nov 2, 2023
1 parent 967b859 commit 135852b
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/rairlab/planner/ContextNormPlanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/rairlab/planner/GoalTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down
37 changes: 14 additions & 23 deletions src/main/java/org/rairlab/planner/Py4JServer.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -14,24 +12,20 @@
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 {
Expand All @@ -49,29 +43,26 @@ public static void main(String[] args) throws UnknownHostException {

}

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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/rairlab/planner/utils/Runner.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/rairlab/planner/utils/Sandbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
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.
Expand Down

0 comments on commit 135852b

Please sign in to comment.