-
Notifications
You must be signed in to change notification settings - Fork 68
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 #36 from pellierd/devel
Release PDDL4J 3.6.0
- Loading branch information
Showing
52 changed files
with
5,262 additions
and
965 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
##PDDL4J library | ||
## PDDL4J library | ||
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.45971.svg)](http://dx.doi.org/10.5281/zenodo.45971) | ||
[![Build Status](http://pddl4j.imag.fr/jenkins/job/pddl4j-base/badge/icon)](http://pddl4j.imag.fr/jenkins/job/pddl4j-base) | ||
|
||
###1. Contact | ||
### 1. Contact | ||
|
||
- Damien Pellier ([email protected]) | ||
- http://lig-membres.imag.fr/pellier/ | ||
|
||
###2. Description | ||
### 2. Description | ||
|
||
PDDL4J is an open source library under LGPL license. | ||
|
||
|
@@ -31,20 +32,20 @@ standard will have an impact on the entire field, influencing what is seen as | |
central and what peripheral in the development of planning systems. | ||
|
||
The library contains: | ||
* a PDDL 3.1 parser and all the classes need to manipulate its | ||
* A PDDL 3.1 parser and all the classes need to manipulate its | ||
concepts. The parser can be configured to accept only specified requirements of | ||
PDDL language. | ||
* a set of useful pre-processing mechanisms in order to instantiate and | ||
* A set of useful pre-processing mechanisms in order to instantiate and | ||
simply operators into ground actions based on inertia properties. | ||
* a set of already implemented classical heuristics, e.g., h_ff, h_max, etc. | ||
* several examples of planners using PDDL4J. | ||
* A set of already implemented classical heuristics, e.g., h_ff, h_max, etc. | ||
* Several examples of planners using PDDL4J. | ||
|
||
###3. How to use the PDDL4J library? | ||
### 3. How to use the PDDL4J library? | ||
|
||
The pddl4j library is package with "gradle". If ant is not installed on your computer, | ||
go to https://gradle.org/ and install it. | ||
|
||
####3.1 How to build PDDL4J? | ||
#### 3.1 How to build PDDL4J? | ||
|
||
Type at the root of the PDDL4J distribution: | ||
> ./gradlew build | ||
|
@@ -54,21 +55,21 @@ if you want to build the project with findbug: | |
The jar "pddl4j-VERSION.jar" is available in the build/libs directory. | ||
|
||
####3.3 How to use binary distribution? | ||
#### 3.3 How to use binary distribution? | ||
|
||
The pddl4j library can be used as a jar file called "pddl4j-VERSION.jar" in the "libs" | ||
directory of the release. Therefore, include the jar in our classpath and enjoy | ||
it. | ||
|
||
####3.4 How to access the documentation? | ||
#### 3.4 How to access the documentation? | ||
|
||
All the documentations are contained in the doc directory. | ||
|
||
To generate the javadoc just type: | ||
> ./gradlew javadoc | ||
|
||
####3.5 How to run existing planner? | ||
#### 3.5 How to run existing planner? | ||
|
||
Planners are available in the "planners" package of the distribution. For | ||
instance, this archive contains a simple planner based on A* search strategy | ||
|
@@ -81,3 +82,28 @@ Or use the gradle run command: | |
Note: A set of planning problems is available in the web site of the international | ||
planning competition: http://ipc.icaps-conference.org. | ||
|
||
### 4. Changelog | ||
|
||
**PDDL4J v3.6.0** | ||
|
||
*Planner* | ||
* Adding Fast Forward planner | ||
* Adding Enforced Hill Climbing planner | ||
* Adding depth attibute in Node class | ||
* Converting cost and heuristic in double | ||
* Fix bugs | ||
|
||
*Parser* | ||
* Adding parseFromString method (it's is now possible to parse a string containing a pddl domain and/or problem) | ||
* Refactor Parser class and fix bugs | ||
|
||
*JUnit tests* | ||
* Adding tests for all the planners, CodedProblem, Encoder, Parser, Plan, etc. | ||
* Refactor and fix bugs | ||
|
||
*Global* | ||
* Change AdaptatorJavaJson to JsonAdapter | ||
* Fix logger and standard outputs | ||
* Throws uncatched exceptions | ||
* Fix bugs |
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
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 |
---|---|---|
@@ -1,3 +1,22 @@ | ||
/* | ||
* Copyright (c) 2016 by Damien Pellier <[email protected]>. | ||
* | ||
* 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.encoding; | ||
|
||
import fr.uga.pddl4j.util.BitExp; | ||
|
@@ -18,16 +37,16 @@ | |
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
|
||
/** | ||
* This class is used to convert Java plan into its JSON representation. | ||
* Its also provide methods to save the JSON String into a file. | ||
* | ||
* @author Samy Ouastani | ||
* @author Cedric Gerard | ||
* @author Damien Pellier | ||
* @version 1.0 - 07.19.2016 | ||
*/ | ||
public class AdapterPlanJavaJson { | ||
public class JsonAdapter { | ||
|
||
/** | ||
* The current coded problem the plan is based on. | ||
|
@@ -40,17 +59,18 @@ public class AdapterPlanJavaJson { | |
private JSONObject jsonPlan; | ||
|
||
/** | ||
* Adapter constructor. | ||
* @param codedProblem the pddl4j problem representation | ||
* Create a new adapter. | ||
* | ||
* @param codedProblem the pddl4j problem representation. | ||
*/ | ||
public AdapterPlanJavaJson(CodedProblem codedProblem) { | ||
public JsonAdapter(CodedProblem codedProblem) { | ||
this.codedProblem = new CodedProblem(codedProblem); | ||
} | ||
|
||
/** | ||
* Save the current jsonPlan into a file. | ||
* | ||
* @param name the name of the saved file | ||
* @param name the name of the saved file. | ||
*/ | ||
public void saveInFile(String name) { | ||
if (jsonPlan == null) { | ||
|
@@ -59,7 +79,7 @@ public void saveInFile(String name) { | |
// Creation of the json files | ||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(name), "UTF-8")) { | ||
// Editing the first json file | ||
writer.write(jsonPlan.toJSONString()); | ||
writer.write(this.jsonPlan.toJSONString()); | ||
} catch (IOException exception) { | ||
exception.printStackTrace(); | ||
} | ||
|
@@ -68,11 +88,11 @@ public void saveInFile(String name) { | |
/** | ||
* Return a string of the plan in a json format. | ||
* | ||
* @param plan to convert into json string | ||
* @return the plan in a json string format | ||
* @param plan to convert into json string. | ||
* @return the plan in a json string format. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public final String toStringJ(final Plan plan) { | ||
public final String toJsonString(final Plan plan) { | ||
|
||
JSONObject planJson = new JSONObject(); | ||
|
||
|
@@ -89,12 +109,12 @@ public final String toStringJ(final Plan plan) { | |
for (int j = 0; j < action.getArity(); j++) { | ||
final int index = action.getValueOfParameter(j); | ||
if (index != -1) { | ||
parameters.add(codedProblem.getConstants().get(index)); | ||
parameters.add(this.codedProblem.getConstants().get(index)); | ||
} | ||
} | ||
|
||
// Preconditions | ||
ArrayList<ArrayList<String>> preconds = this.toStringJ(action.getPreconditions()); | ||
ArrayList<ArrayList<String>> preconds = this.toJsonString(action.getPreconditions()); | ||
JSONObject precondJson = new JSONObject(); | ||
|
||
ArrayList<String> positives = preconds.get(0); | ||
|
@@ -119,7 +139,7 @@ public final String toStringJ(final Plan plan) { | |
JSONObject expJsonEffects = new JSONObject(); | ||
|
||
ArrayList<ArrayList<String>> condExpElementsCondition = | ||
this.toStringJ(condExp.get(k).getCondition()); | ||
this.toJsonString(condExp.get(k).getCondition()); | ||
|
||
JSONArray positivesConditionJson = listToJson(condExpElementsCondition.get(0)); | ||
JSONArray negativesConditionJson = listToJson(condExpElementsCondition.get(1)); | ||
|
@@ -128,7 +148,7 @@ public final String toStringJ(final Plan plan) { | |
expJsonCondition.put("Positives", positivesConditionJson); | ||
expJsonCondition.put("Negatives", negativesConditionJson); | ||
|
||
ArrayList<ArrayList<String>> condExpElementsEffect = this.toStringJ(condExp.get(k).getEffects()); | ||
ArrayList<ArrayList<String>> condExpElementsEffect = this.toJsonString(condExp.get(k).getEffects()); | ||
|
||
JSONArray positivesEffectJson = listToJson(condExpElementsEffect.get(0)); | ||
JSONArray negativesEffectJson = listToJson(condExpElementsEffect.get(1)); | ||
|
@@ -159,35 +179,38 @@ public final String toStringJ(final Plan plan) { | |
} | ||
} | ||
|
||
jsonPlan = planJson; | ||
this.jsonPlan = planJson; | ||
return planJson.toJSONString(); | ||
} | ||
|
||
/** | ||
* Convert a BitExp into a String collection. | ||
* | ||
* @param exp the BitExp instance to convert | ||
* @return an 2D collection of Strings | ||
* @param exp the BitExp instance to convert. | ||
* @return an 2D collection of Strings. | ||
*/ | ||
private ArrayList<ArrayList<String>> toStringJ(BitExp exp) { | ||
return AdapterPlanJavaJson.toStringJ(exp, codedProblem.getConstants(), codedProblem.getTypes(), | ||
codedProblem.getPredicates(), codedProblem.getFunctions(), codedProblem.getRelevantFacts()); | ||
private ArrayList<ArrayList<String>> toJsonString(final BitExp exp) { | ||
return JsonAdapter.toJsonString(exp, this.codedProblem.getConstants(), this.codedProblem.getTypes(), | ||
this.codedProblem.getPredicates(), this.codedProblem.getFunctions(), this.codedProblem.getRelevantFacts()); | ||
} | ||
|
||
/** | ||
* Convert a BitExp into a String collection. | ||
* | ||
* @param exp the BitExp instance to convert | ||
* @param constants the constants of the problem | ||
* @param types the types of the problem | ||
* @param predicates the predicates of the problem | ||
* @param functions the functions of the problem | ||
* @param relevants the facts of the problem | ||
* @return an 2D collection of Strings | ||
* @param exp the BitExp instance to convert. | ||
* @param constants the constants of the problem. | ||
* @param types the types of the problem. | ||
* @param predicates the predicates of the problem. | ||
* @param functions the functions of the problem. | ||
* @param relevants the facts of the problem. | ||
* @return an 2D collection of Strings. | ||
*/ | ||
private static ArrayList<ArrayList<String>> toStringJ(BitExp exp, final List<String> constants, | ||
final List<String> types, final List<String> predicates, | ||
final List<String> functions, final List<IntExp> relevants) { | ||
private static ArrayList<ArrayList<String>> toJsonString(final BitExp exp, | ||
final List<String> constants, | ||
final List<String> types, | ||
final List<String> predicates, | ||
final List<String> functions, | ||
final List<IntExp> relevants) { | ||
ArrayList<String> fluentsPos = new ArrayList<>(); | ||
ArrayList<String> fluentsNeg = new ArrayList<>(); | ||
ArrayList<ArrayList<String>> fluents = new ArrayList<>(); | ||
|
@@ -208,10 +231,10 @@ private static ArrayList<ArrayList<String>> toStringJ(BitExp exp, final List<Str | |
} | ||
|
||
/** | ||
* Method that transform an ArrayList into a JSONArray. | ||
* Transform an ArrayList into a JSONArray. | ||
* | ||
* @param list an ArrayList that we want to convert into a List. | ||
* @return list the list parameter | ||
* @return list the list parameter. | ||
*/ | ||
private static JSONArray listToJson(List<String> list) { | ||
return list.stream().collect(Collectors.toCollection(JSONArray::new)); | ||
|
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
Oops, something went wrong.