-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from pellierd/devel
Release PDDL4J 3.7.1
- Loading branch information
Showing
13 changed files
with
516 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/bin/bash | ||
|
||
pause(){ | ||
read -p "Press [Enter] key to continue..." fackEnterKey | ||
} | ||
|
||
build(){ | ||
./gradlew jar | ||
pause | ||
} | ||
|
||
solveHSP(){ | ||
read -p "Enter domain file [path to the file]: " domainFile | ||
read -p "Enter problem file [path to the file]: " problemFile | ||
read -p "Timeout [int]: " timeOut | ||
|
||
show_heuristic | ||
|
||
read -p "Choose heuristic [0 - 8]: " heuristic | ||
|
||
java -javaagent:build/libs/pddl4j-3.7.1.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -p 0 -o $domainFile -f $problemFile -t $timeOut -u $heuristic | ||
|
||
pause | ||
} | ||
|
||
solveFF(){ | ||
read -p "Enter domain file [path to the file]: " domainFile | ||
read -p "Enter problem file [path to the file]: " problemFile | ||
read -p "Timeout [int]: " timeOut | ||
|
||
show_heuristic | ||
|
||
read -p "Choose heuristic [0 - 8]: " heuristic | ||
|
||
java -javaagent:build/libs/pddl4j-3.7.1.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -p 1 -o $domainFile -f $problemFile -t $timeOut -u $heuristic | ||
|
||
pause | ||
} | ||
|
||
about() { | ||
show_title | ||
echo "" | ||
echo "PDDL4J is an open source library under LGPL license." | ||
echo "" | ||
echo "The purpose of PDDL4J is to facilitate the development of JAVA tools for Automated Planning based on PDDL language (Planning Domain Description Language). Automated planning and scheduling, in the relevant literature often denoted as simply planning, is a branch of artificial intelligence that concerns the realization of strategies or action sequences, typically for execution by intelligent agents, autonomous robots and unmanned vehicles." | ||
echo "" | ||
echo "PDDL was originally developed by Drew McDermott and the 1998 planning competition committee. It was inspired by the need to encourage the empirical comparison of planning systems and the exchange of planning benchmarks within the community. Its development improved the communication of research results and triggered an explosion in performance, expressivity and robustness of planning systems." | ||
echo "" | ||
echo "PDDL has become a de facto standard language for describing planning domains, not only for the competition but more widely, as it offers an opportunity to carry out empirical evaluation of planning systems on a growing collection of generally adopted standard benchmark domains. The emergence of a language standard will have an impact on the entire field, influencing what is seen as central and what peripheral in the development of planning systems." | ||
pause | ||
} | ||
|
||
clean() { | ||
./gradlew clean | ||
pause | ||
} | ||
|
||
show_title() { | ||
clear | ||
echo " _____ ____ ____ __ ___ __ " | ||
echo "| _ | \| \| | | | |__| |" | ||
echo "| __| | | | | |__|_ | | |" | ||
echo "|__| |____/|____/|_____| |_|_____|" | ||
} | ||
|
||
show_status() { | ||
echo "|" | ||
echo "| PDDL4J `awk '/^version/' build.gradle`" | ||
if [ -d build/libs ]; then | ||
echo -e "| PDDL4J status [\e[92mBuilt\e[39m]" | ||
echo "|" | ||
echo " ----------" | ||
else | ||
echo -e "| PDDL4J status [\e[91mNot built\e[39m]" | ||
echo "|" | ||
echo " ----------" | ||
fi | ||
} | ||
|
||
show_menus_l() { | ||
echo "| 0. Build jar" | ||
echo "| ..." | ||
echo "| 4. About" | ||
echo "| 5. Exit" | ||
echo " ----------" | ||
} | ||
|
||
read_options_l(){ | ||
local choice | ||
read -p "Enter choice [0 - 5] : " choice | ||
case $choice in | ||
0) build ;; | ||
4) about ;; | ||
5) exit 0;; | ||
*) echo "Error..." && sleep 1 | ||
esac | ||
} | ||
|
||
show_menus() { | ||
echo "| 0. Build jar" | ||
echo "| 1. Solve with HSP" | ||
echo "| 2. Solve with FF" | ||
echo "| 3. Clean" | ||
echo "| 4. About" | ||
echo "| 5. Exit" | ||
echo " ----------" | ||
} | ||
|
||
show_heuristic() { | ||
echo "0. ff heuristic" | ||
echo "1. sum heuristic" | ||
echo "2. sum mutex heuristic" | ||
echo "3. djusted sum heuristic" | ||
echo "4. adjusted sum 2 heuristic" | ||
echo "5. adjusted sum 2M heuristic" | ||
echo "6. combo heuristic" | ||
echo "7. max heuristic" | ||
echo "8. set-level heuristic" | ||
} | ||
|
||
read_options(){ | ||
local choice | ||
read -p "Enter choice [0 - 5] : " choice | ||
case $choice in | ||
0) build ;; | ||
1) solveHSP ;; | ||
2) solveFF ;; | ||
3) clean ;; | ||
4) about ;; | ||
5) exit 0;; | ||
*) echo "Error..." && sleep 1 | ||
esac | ||
} | ||
|
||
# ---------------------------------------------- | ||
# Trap CTRL+C, CTRL+Z and quit singles | ||
# ---------------------------------------------- | ||
trap '' SIGINT SIGQUIT SIGTSTP | ||
|
||
# ----------------------------------- | ||
# Main logic - infinite loop | ||
# ------------------------------------ | ||
while true | ||
do | ||
show_title | ||
show_status | ||
if [ -d build/libs ]; then | ||
show_menus | ||
read_options | ||
else | ||
show_menus_l | ||
read_options_l | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/main/java/fr/uga/pddl4j/planners/statespace/search/strategy/BreadthFirstSearch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* Copyright (c) 2016 by Damien Pellier <Damien.Pellier@imag.fr>. | ||
* | ||
* This file is part of PDDL4J library. | ||
* | ||
* PDDL4J is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* PDDL4J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with PDDL4J. If not, see | ||
* <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
package fr.uga.pddl4j.planners.statespace.search.strategy; | ||
|
||
import fr.uga.pddl4j.encoding.CodedProblem; | ||
import fr.uga.pddl4j.util.BitOp; | ||
import fr.uga.pddl4j.util.BitState; | ||
import fr.uga.pddl4j.util.MemoryAgent; | ||
|
||
import java.util.LinkedList; | ||
import java.util.Objects; | ||
|
||
/** | ||
* This class implements Breadth First Search strategy. | ||
* | ||
* @author E. Hermellin | ||
* @version 1.0 - 22.06.2018 | ||
*/ | ||
public final class BreadthFirstSearch extends AbstractStateSpaceStrategy { | ||
|
||
/** | ||
* The serial id of the class. | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* Creates a new Greedy best First Search search strategy with default parameters. | ||
*/ | ||
public BreadthFirstSearch() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Creates a new Greedy best First Search search strategy. | ||
* | ||
* @param timeout the time out of the planner. | ||
*/ | ||
public BreadthFirstSearch(int timeout) { | ||
super(timeout); | ||
} | ||
|
||
/** | ||
* The greedy best first search algorithm. Solves the planning problem and returns the first solution plan found. | ||
* This method must be completed. | ||
* | ||
* @param codedProblem the problem to be solved. The problem cannot be null. | ||
* @return a solution plan or null if it does not exist. | ||
*/ | ||
public Node search(final CodedProblem codedProblem) { | ||
Objects.requireNonNull(codedProblem); | ||
final long begin = System.currentTimeMillis(); | ||
|
||
final LinkedList<Node> closeSet = new LinkedList<>(); | ||
final LinkedList<Node> openSet = new LinkedList<>(); | ||
final int timeout = getTimeout(); | ||
|
||
BitState init = new BitState(codedProblem.getInit()); | ||
Node root = new Node(init, null, 0, 0, 0); | ||
root.setDepth(0); | ||
openSet.add(root); | ||
|
||
this.resetNodesStatistics(); | ||
Node solution = null; | ||
long searchingTime = 0; | ||
while (!openSet.isEmpty() && solution == null && searchingTime < timeout) { | ||
// Pop the first node in the pending list open | ||
final Node current = openSet.pollFirst(); | ||
|
||
if (current.satisfy(codedProblem.getGoal())) { | ||
solution = current; | ||
} else { | ||
closeSet.add(current); | ||
int index = 0; | ||
for (BitOp op : codedProblem.getOperators()) { | ||
|
||
// Test if a specified operator is applicable in the current state | ||
if (op.isApplicable(current)) { | ||
final BitState nextState = new BitState(current); | ||
nextState.or(op.getCondEffects().get(0).getEffects().getPositive()); | ||
nextState.andNot(op.getCondEffects().get(0).getEffects().getNegative()); | ||
|
||
// Apply the effect of the applicable operator | ||
final Node successor = new Node(nextState); | ||
this.setCreatedNodes(this.getCreatedNodes() + 1); | ||
successor.setCost(current.getCost() + op.getCost()); | ||
successor.setHeuristic(0); | ||
successor.setParent(current); | ||
successor.setOperator(index); | ||
successor.setDepth(current.getDepth() + 1); | ||
|
||
if (!closeSet.contains(successor) && !openSet.contains(successor)) { | ||
openSet.addLast(successor); | ||
} | ||
} | ||
index++; | ||
} | ||
} | ||
// Take time to compute the searching time | ||
long end = System.currentTimeMillis(); | ||
searchingTime = end - begin; | ||
} | ||
|
||
this.setExploredNodes(closeSet.size()); | ||
this.setPendingNodes(openSet.size()); | ||
this.setMemoryUsed(MemoryAgent.getDeepSizeOf(closeSet) + MemoryAgent.getDeepSizeOf(openSet)); | ||
this.setSearchingTime(searchingTime); | ||
|
||
return solution; | ||
} | ||
} |
Oops, something went wrong.