Skip to content

Commit

Permalink
Merge pull request #59 from pellierd/devel
Browse files Browse the repository at this point in the history
Release PDDL4J v3.8.3
  • Loading branch information
Emmanuel Hermellin authored Mar 19, 2019
2 parents 6a3a37f + 84795fc commit 405b12e
Show file tree
Hide file tree
Showing 22 changed files with 180 additions and 579 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Planners are available in the "planners" package of the distribution. For
instance, this archive contains a simple planner based on A* search strategy
called HSP. To launch this planner use the following command line:

> java -javaagent:build/libs/pddl4j-3.8.2.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -o pddl/blocksworld/domain.pddl -f pddl/blocksworld/p15.pddl
> java -javaagent:build/libs/pddl4j-3.8.3.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -o pddl/blocksworld/domain.pddl -f pddl/blocksworld/p15.pddl
> java -jar build/libs/pddl4j-3.8.2.jar -o pddl/blocksworld/domain.pddl -f pddl/blocksworld/p15.pddl
> java -jar build/libs/pddl4j-3.8.3.jar -o pddl/blocksworld/domain.pddl -f pddl/blocksworld/p15.pddl
Or use the gradle run command:
> gradle run -PArgs=-o,pddl/blocksworld/domain.pddl,-f,pddl/blocksworld/p15.pddl
Expand All @@ -109,6 +109,14 @@ https://doi.org/10.1080/0952813X.2017.1409278

**PDDL4J v3.8.2**

*Search strategy*
* Improve structure: add StateSpaceStrategyAnytime interface

*Planner*
* Improve structure: add StateSpacePlannerAnytime interface

**PDDL4J v3.8.2**

*Search strategy*
* Fix issue with anytime solution
* Fix issue with SolutionListener
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'findbugs'
apply plugin: 'checkstyle'

group 'fr.uga'
version '3.8.2'
version '3.8.3'
sourceCompatibility = 1.8

repositories {
Expand Down
4 changes: 2 additions & 2 deletions pddl4j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ solveHSP(){

read -p "Choose heuristic [0 - 8]: " heuristic

java -javaagent:build/libs/pddl4j-3.8.2.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -p 0 -o $domainFile -f $problemFile -t $timeOut -u $heuristic
java -javaagent:build/libs/pddl4j-3.8.3.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -p 0 -o $domainFile -f $problemFile -t $timeOut -u $heuristic

pause
}
Expand All @@ -32,7 +32,7 @@ solveFF(){

read -p "Choose heuristic [0 - 8]: " heuristic

java -javaagent:build/libs/pddl4j-3.8.2.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -p 1 -o $domainFile -f $problemFile -t $timeOut -u $heuristic
java -javaagent:build/libs/pddl4j-3.8.3.jar -server -Xms2048m -Xmx2048m fr.uga.pddl4j.planners.statespace.StateSpacePlannerFactory -p 1 -o $domainFile -f $problemFile -t $timeOut -u $heuristic

pause
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@

import fr.uga.pddl4j.encoding.CodedProblem;
import fr.uga.pddl4j.planners.statespace.search.strategy.Node;
import fr.uga.pddl4j.planners.statespace.search.strategy.StateSpaceStrategyAnytime;
import fr.uga.pddl4j.util.Plan;

import java.util.Objects;
import java.util.Vector;

public abstract class AbstractStateSpacePlannerAnytime extends AbstractStateSpacePlanner {
public abstract class AbstractStateSpacePlannerAnytime extends AbstractStateSpacePlanner
implements StateSpacePlannerAnytime {

/**
* The serial id of the class.
Expand All @@ -52,16 +55,27 @@ public AbstractStateSpacePlannerAnytime(final boolean statisticState, final int
}

/**
* Returns the list containing all solution plans found.
* Returns the list containing all solution nodes found.
*
* @return the list containing all solution plans found.
* @return the list containing all solution nodes found.
*/
public abstract Vector<Plan> getSolutionPlans(final CodedProblem codedProblem);
@Override
public Vector<Node> getSolutionNodes() {
final StateSpaceStrategyAnytime stateSpaceStrategyAnytime =
(StateSpaceStrategyAnytime) this.getStateSpaceStrategies().get(0);
return stateSpaceStrategyAnytime.getSolutionNodes();
}

/**
* Returns the list containing all solution nodes found.
* Returns the list containing all solution plans found.
*
* @return the list containing all solution nodes found.
* @return the list containing all solution plans found.
*/
public abstract Vector<Node> getSolutionNodes();
@Override
public Vector<Plan> getSolutionPlans(final CodedProblem codedProblem) {
Objects.requireNonNull(codedProblem);
final StateSpaceStrategyAnytime stateSpaceStrategyAnytime =
(StateSpaceStrategyAnytime) this.getStateSpaceStrategies().get(0);
return stateSpaceStrategyAnytime.getSolutionPlans(codedProblem);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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;

import fr.uga.pddl4j.encoding.CodedProblem;
import fr.uga.pddl4j.planners.statespace.search.strategy.Node;
import fr.uga.pddl4j.util.Plan;

import java.util.Vector;

/**
* This interface defines the main methods to access a state space planner anytime.
*
* @author E. Hermellin
* @version 1.0 - 18.03.2019
* @since 3.8
*/
public interface StateSpacePlannerAnytime extends StateSpacePlanner {

/**
* Returns the list containing all solution plans found.
*
* @return the list containing all solution plans found.
*/
Vector<Plan> getSolutionPlans(final CodedProblem codedProblem);

/**
* Returns the list containing all solution nodes found.
*
* @return the list containing all solution nodes found.
*/
Vector<Node> getSolutionNodes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import fr.uga.pddl4j.planners.statespace.AbstractStateSpacePlannerAnytime;
import fr.uga.pddl4j.planners.statespace.search.strategy.AbstractStateSpaceStrategyAnytime;
import fr.uga.pddl4j.planners.statespace.search.strategy.Node;
import fr.uga.pddl4j.util.Plan;
import fr.uga.pddl4j.util.SequentialPlan;
import org.apache.logging.log4j.Logger;

import java.util.Objects;
import java.util.Vector;

/**
* This class implements a simple generic anytime planner.
Expand All @@ -49,27 +47,6 @@ public final class GenericAnytimePlanner extends AbstractStateSpacePlannerAnytim
*/
private final AbstractStateSpaceStrategyAnytime searchStrategy;

/**
* Returns the list containing all solution nodes found.
*
* @return the list containing all solution nodes found.
*/
@Override
public Vector<Node> getSolutionNodes() {
return searchStrategy.getSolutionNodes();
}

/**
* Returns the list containing all solution plans found.
*
* @return the list containing all solution plans found.
*/
@Override
public Vector<Plan> getSolutionPlans(final CodedProblem codedProblem) {
Objects.requireNonNull(codedProblem);
return searchStrategy.getSolutionPlans(codedProblem);
}

/**
* Creates a new planner with default parameters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@
import fr.uga.pddl4j.planners.statespace.AbstractStateSpacePlannerAnytime;
import fr.uga.pddl4j.planners.statespace.search.strategy.HillClimbingAnytime;
import fr.uga.pddl4j.planners.statespace.search.strategy.Node;
import fr.uga.pddl4j.util.Plan;
import fr.uga.pddl4j.util.SequentialPlan;
import org.apache.logging.log4j.Logger;

import java.util.Objects;
import java.util.Vector;
import org.apache.logging.log4j.Logger;

public class HCAnytime extends AbstractStateSpacePlannerAnytime {

Expand All @@ -43,27 +40,6 @@ public class HCAnytime extends AbstractStateSpacePlannerAnytime {
*/
private HillClimbingAnytime hillClimbingAnytime;

/**
* Returns the list containing all solution nodes found.
*
* @return the list containing all solution nodes found.
*/
@Override
public Vector<Node> getSolutionNodes() {
return hillClimbingAnytime.getSolutionNodes();
}

/**
* Returns the list containing all solution plans found.
*
* @return the list containing all solution plans found.
*/
@Override
public Vector<Plan> getSolutionPlans(final CodedProblem codedProblem) {
Objects.requireNonNull(codedProblem);
return hillClimbingAnytime.getSolutionPlans(codedProblem);
}

/**
* Creates a new planner with default parameters.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
import fr.uga.pddl4j.util.BitState;
import fr.uga.pddl4j.util.MemoryAgent;
import fr.uga.pddl4j.util.SolutionEvent;
import fr.uga.pddl4j.util.SolutionListener;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.PriorityQueue;
import javax.swing.event.EventListenerList;

/**
* This class implements A* search strategy.
Expand All @@ -43,11 +41,6 @@ public final class AStar extends AbstractStateSpaceStrategy {
*/
private static final long serialVersionUID = 1L;

/**
* The list of SolutionListener.
*/
private EventListenerList solutionListenerList = new EventListenerList();

/**
* Creates a new AStar search strategy with default parameters.
*
Expand Down Expand Up @@ -168,39 +161,4 @@ public Node search(final CodedProblem codedProblem) {
// return the search computed or null if no search was found
return solution;
}

/**
* Adds SolutionListener to the list of SolutionListener.
*
* @param listener the SolutionListener to add.
*/
@Override
public void addSolutionListener(SolutionListener listener) {
solutionListenerList.add(SolutionListener.class, listener);
}

/**
* Removes SolutionListener to the list of SolutionListener.
*
* @param listener the SolutionListener to remove.
*/
@Override
public void removeSolutionListener(SolutionListener listener) {
solutionListenerList.remove(SolutionListener.class, listener);
}

/**
* Processes SolutionEvent when one is fired.
*
* @param evt the solution event to process.
*/
@Override
public void fireSolution(SolutionEvent evt) {
Object[] listeners = solutionListenerList.getListenerList();
for (int i = 0; i < listeners.length; i = i + 2) {
if (listeners[i] == SolutionListener.class) {
((SolutionListener) listeners[i + 1]).newSolutionFound(evt);
}
}
}
}
Loading

0 comments on commit 405b12e

Please sign in to comment.