diff --git a/.config/deploy-artifacts.sh b/.config/deploy-artifacts.sh
old mode 100644
new mode 100755
index 2db58d2..8bb702a
--- a/.config/deploy-artifacts.sh
+++ b/.config/deploy-artifacts.sh
@@ -1,16 +1,12 @@
#!/bin/bash
-echo "Auto-deploying Hipster artifacts..."
+echo "Auto-deploying Hipster4j snapshots..."
echo "Current branch: $TRAVIS_BRANCH"
-
-if [ "$TRAVIS_REPO_SLUG" == "citiususc/hipster" ] && [ "$TRAVIS_JDK_VERSION" == "oraclejdk7" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
- echo "Running mvn deploy, current directory: `pwd`"
- # Deploy to CITIUS
- #mvn --settings .config/maven-settings.xml -P citius-snapshot-deploy deploy -DskipTests=true
- # Deploy to Sonatype Nexus OSS
- mvn --settings .config/maven-settings.xml -P sonatype-nexus-snapshots deploy -DskipTests=true
-else
- echo "Skipping deployment for this build..."
+if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
+ echo "Skipping snapshot deployment for pull request"
+ exit
fi
-
+echo "Running mvn deploy, current directory: `pwd`"
+# Deploy to Sonatype Nexus OSS
+mvn --settings .config/maven-settings.xml deploy -DskipTests=true
echo "Deployment script finished."
diff --git a/.config/deploy-site.sh b/.config/deploy-site.sh
deleted file mode 100644
index 107e740..0000000
--- a/.config/deploy-site.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/bash
-
-#TRAVIS_REPO_SLUG="citiususc/hipster"
-#TRAVIS_JDK_VERSION="oraclejdk7"
-#TRAVIS_PULL_REQUEST="false"
-#TRAVIS_BRANCH="master"
-#HOME=`pwd`
-
-echo "Preparing Hipster site for auto-deploy"
-echo "TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG - TRAVIS_JDK_VERSION=$TRAVIS_JDK_VERSION - TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
-
-if [ "$TRAVIS_REPO_SLUG" == "citiususc/hipster" ] && [ "$TRAVIS_JDK_VERSION" == "oraclejdk7" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
-
- # Decide the documentation version folder name depending on the branch and the version in the pom.xml
- # wget https://raw.githubusercontent.com/citiususc/hipster/$TRAVIS_BRANCH/pom.xml > /dev/null 2>&1
- # Take the version from the main pom.xml
- # grep -m 1 -E '[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+(-[0-9]+)?)?' pom.xml
- VERSION=`grep -m 1 "" pom.xml | cut -d ">" -f 2 | cut -d "<" -f 1`
- # rm pom.xml
-
- # Validate if the version is correct (example 1.0.0-SNAPSHOT, or 1.0.0-alpha-1)
- VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+(-[0-9]+)?)?$'
- if [[ $VERSION =~ $VERSION_REGEX ]]; then
- echo "Current version is $VERSION"
- else
- echo "Version error. Unrecognized version $VERSION"
- exit 1
- fi
-
- echo "Deploying Hipster [$VERSION] site and documentation to GitHub gh-pages"
- echo "Current directory is: `pwd`"
-
-
- echo "Building javadocs..."
- mvn javadoc:aggregate
-
- # Build site only if this is the development branch.
- if [ "$TRAVIS_BRANCH" == "master" ]; then
- echo "Building site..."
- mvn site:site
- fi
-
- # First, copy the generated site to the new folder
- mkdir $HOME/site
- cp -Rf target/site/* $HOME/site
- # Remove the apidocs site and use the aggregated javadoc instead
- rm -rf $HOME/site/apidocs
- # Copy the apidocs to the site folder
- mkdir $HOME/site/documentation
- mkdir $HOME/site/documentation/javadoc
- mkdir $HOME/site/documentation/javadoc/$VERSION
- cp -Rf target/apidocs/* $HOME/site/documentation/javadoc/$VERSION
-
- # Now prepare for uploading the site to gh-pages
-
- cd $HOME
- git clone --quiet --branch=gh-pages https://github.com/citiususc/hipster.git gh-pages > /dev/null
-
- # Copy and overwrite the site with the new content
- cp -Rf $HOME/site/* gh-pages/
- cd gh-pages
-
- # Config git user and credentials
- git config --global user.email "travis@travis-ci.org"
- git config --global user.name "travis-ci"
- git config credential.helper "store --file=.git/credentials"
- echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
-
- git add -A
- git commit -a -m "auto-commit $TRAVIS_BRANCH Hipster site updated (build $TRAVIS_BUILD_NUMBER)"
- git push -q origin gh-pages > /dev/null
- echo "Published $TRAVIS_BRANCH Hipster site to gh-pages."
-
-fi
diff --git a/.config/maven-settings.xml b/.config/maven-settings.xml
index 8ab720f..d0d68a9 100644
--- a/.config/maven-settings.xml
+++ b/.config/maven-settings.xml
@@ -15,19 +15,48 @@
~ limitations under the License.
-->
-
+
-
+
- citius-nexus-snapshots
- ${env.NEXUS_SNAPSHOT_USERNAME}
- ${env.NEXUS_SNAPSHOT_PASSWORD}
-
-
- sonatype-nexus-snapshots${env.SONATYPE_SNAPSHOT_USERNAME}${env.SONATYPE_SNAPSHOT_PASSWORD}
+
+ bintray-hipster4j-maven
+ ${env.BINTRAY_USER}
+ ${env.BINTRAY_API_KEY}
+
+
+
+
+
+
+
+ false
+
+ bintray-hipster4j-maven
+ bintray
+ http://dl.bintray.com/hipster4j/maven
+
+
+
+
+
+ false
+
+ bintray-hipster4j-maven
+ bintray-plugins
+ http://dl.bintray.com/hipster4j/maven
+
+
+ bintray
+
+
+
+ bintray
+
diff --git a/.config/publish-javadocs.sh b/.config/publish-javadocs.sh
new file mode 100755
index 0000000..8739b2b
--- /dev/null
+++ b/.config/publish-javadocs.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
+ echo "Skipping Javadoc publication for pull request"
+ exit
+fi
+
+if [ "$TRAVIS_TAG" == "" ]; then
+ echo "Current version is not a release, skipping Javadoc publication"
+ exit
+fi
+
+echo "Auto publishing latest javadocs..."
+echo "TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG - TRAVIS_JDK_VERSION=$TRAVIS_JDK_VERSION - TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
+
+# Decide the documentation version folder name depending on the branch and the version in the pom.xml
+VERSION=`grep -m 1 "" pom.xml | cut -d ">" -f 2 | cut -d "<" -f 1`
+
+# Validate if the version is correct (example 1.0.0-SNAPSHOT, or 1.0.0-alpha-1)
+VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+(-[0-9]+)?)?$'
+if [[ $VERSION =~ $VERSION_REGEX ]]; then
+ echo "Current version is $VERSION"
+else
+ echo "Version error. Unrecognized version $VERSION"
+ exit 1
+fi
+
+echo "Deploying Hipster [$VERSION] javadocs to GitHub gh-pages"
+echo "Current directory is: `pwd`"
+
+echo "Building javadocs..."
+# Generate Javadocs in target/apidocs
+mvn javadoc:aggregate
+
+# Clone Hipster4j GitHub gh-pages for Javadocs
+git clone --quiet --branch=gh-pages https://github.com/hipster4j/hipster-javadocs.git gh-pages > /dev/null
+
+# Overwrite the previous version with the new one
+cp -Rf target/apidocs/* gh-pages/
+
+# Create a new folder with the version number and copy the latest version to it
+mkdir gh-pages/$VERSION
+cp -Rf target/apidocs/* gh-pages/$VERSION/
+
+# Now prepare for uploading the site to gh-pages
+cd gh-pages
+
+# Config git user and credentials
+git config --global user.email "travis@travis-ci.org"
+git config --global user.name "travis-ci"
+git config credential.helper "store --file=.git/credentials"
+echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
+
+git add -A
+git commit -a -m "auto-commit $TRAVIS_BRANCH Hipster4j Javadocs v$VERSION (build $TRAVIS_BUILD_NUMBER)"
+git push -q origin gh-pages > /dev/null
+echo "Finished"
+
diff --git a/.gitignore b/.gitignore
index 1d6dfdc..57b8f19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,7 @@ nb-configuration.xml
# Idea specific #
*.iml
.idea
+
+# Eclipse specific #
+.metadata/
+
diff --git a/.travis.yml b/.travis.yml
index c20c2e9..7927dfe 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,22 +1,13 @@
language: java
jdk:
- oraclejdk7
-- oraclejdk8
-- openjdk7
branches:
except:
- /^(?i:wip).*$/
sudo: false
+before_install:
+ - pip install --user codecov
after_success:
-#- chmod +x .config/deploy-site.sh
-#- .config/deploy-site.sh
-- chmod +x .config/deploy-artifacts.sh
-- .config/deploy-artifacts.sh
-- mvn clean cobertura:cobertura coveralls:report
-env:
- global:
- - secure: ILdOYjPt+8g5rlexXBYAhECtn5Zm26FRf0/nwCxUU303qtzFQyMcxinIC93aun880OnINjA7fzQeBkG4P+LSVOAXbmGTGhtyPBzMOGcnZouJM/RyXHUft6tAXPimXQ7JjDFjyv7EzSeStk/4WEp0mkxheIryZS3X1pbED1TqgUM=
- - secure: cwV1rA8+CUHonJg40dRHCcd8KmYl9EzpCUcnS8vm/1qNkXpRmEAvwNKjZct0sZ8ZFKjKEUEzhyG0+cZVRzvEhi108/WZ5pIxp01EdtSFZTlIg73llALb2P8HClHuy4XSBDz0G4nTLES11usUGpCsLckSudNtb7bdUAH356NxFvQ=
- - secure: XNFSHaGHiJfj4TvW6Oud1Z1dKnkXYk0njX2xjfljfFlHf4eCSIUxO9giad4xq2sE7vrjk+JpLLj/te7qjug91Ih7KH0i9T56d57q9vfu8juW49NBQxRnfhlvYWyrto5rmnKEa8Mcs/smgER6dllsURz10AqLKM32mkijG4VgdcM=
- - secure: VFkAqPydQ9NTxXkp/gNzNUoaYd/xvryKy+ARXJhbvgUkpO2VMyo2D2wU1G6ECVzitqpO+gaUn2mu7fO1M0KjpeKp5Si7HG3fUVb4sXg6Sim563iot2rJUfiXpu6FOqPfUwQHpyUXqUfAPOA6bI9ZNKNBAurGxgLgt4AP2PjObV4=
- - secure: Q5UXkBKvrqcC09peZa/U/XilT4q32fm2tWEu/0Pq0JquKS+BmOevEmntW0zMBe8R5K5AzbuDKurAyelCqXDNj3W8Tjg/xreIqR3ccnfo202wkLiIAtko8oUXzyiLgeMjjyge76lHIkaGxWXNGzsDUZmq5qUQW2YEQ5vGiv0vc5A=
+ - .config/deploy-artifacts.sh
+ - .config/publish-javadocs.sh
+ - codecov
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e69de29..516e23f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -0,0 +1,113 @@
+# Contributing to Hipster4j
+
+First of all, thank you so much for being interested in contributing to Hipster4j!. This document will guide you through this process. You can contribute in different ways:
+
+- Reporting issues
+- Fixing bugs or developing new features
+- Creating new examples
+- Sending a motivating email telling us how do you like the library (or dislike) :)
+
+## Issues
+Feel free to open new issues or participating in the discussion of the existing ones on
+[this repository](https://github.com/citiususc/hipster/issues), but before doing so, please make sure that the issue is not duplicated and/or the discussion is related to the topic of the issue.
+
+## Pull requests
+Code contributions are welcome following a process which guarantees the long-term maintainability of the project.
+You can contribute either with bugfixes or new features. Before submitting a new feature, we highly encourage you to first open a new issue describing its motivation and details and discuss it with one of the project mantainers. This will ensure that the feature fits well in the project.
+
+### Step 1: Open a new issue (if not opened yet)
+Before starting to code, it is desirable to first open an issue describing the bug or the new feature. Please be sure the issue is not duplicated.
+
+### Step 2: Fork the repository
+Fork the project https://github.com/citiususc/hipster into your account. Then, check out your copy of the project locally.
+```
+git clone git@github.com:username/hipster.git
+cd hipster
+git remote add upstream https://github.com/citiususc/hipster.git
+```
+
+### Step 3: Create a new feature branch `contrib/issue-number`
+Put your code in a new feature branch. The name of the new branch should start with `contrib/`. This convention will help us to keep track of future changes from pull requests.
+```
+git checkout -b contrib/issue-number origin/branch
+```
+Note that origin/‘branch’ would correspond with any of the current development branches (for example 1.0.X) but never the origin/master branch. For example, suppose that the latest version of the project is v1.0.0 and you want to fix a new bug that you discovered in this version. If the new reported issue has an id, say, #186, then you would create your feature branch in this way:
+```
+git checkout -b contrib/issue-186 origin/1.0.X
+```
+
+### Step 4: Committing your changes
+First of all, make sure that git is configured with your complete name and email address. It is desirable to use the same email of your Github account, this will help to identify the contributions:
+```
+git config --global user.name "Your Name"
+git config --global user.email "your@email.com"
+```
+Write a good commit message. It should describe the changes you made and its motivation. Be sure to reference the issue you are working in the commit that finishes your contribution using one the [keywords to close issues in Github](https://help.github.com/articles/closing-issues-via-commit-messages/).
+If your commit message is too long, try to summarize the changes in the header of the message, like this:
+```
+fix #xx : summarize your commit in one line
+
+If needed, explain more in detail the changes introduced in your
+commit and the motivation. You could introduce some background
+about the issue you worked in.
+
+This message can contain several paragraphs and be as long as
+you need, but try to do a good indentation: the columns should
+be shorter than 72 characters and with a proper word-wrap.
+The command `git log` will print this complete text in a nice
+way if you format it properly.
+```
+The header and the body of the commit message must be separated by a line in blank. The header is the message shown when running the command `git shortlog`.
+
+#### Keep your branch in sync
+Remember to keep in sync your version. Use git rebase instead of git merge to bring all the changes from the upstream branch to your feature branch:
+
+```
+git fetch upstream
+git rebase upstream/branch #where branch would be 1.0.X, 1.1.X etc
+```
+
+#### Test your code
+Verify that your changes are actually working by adding the required unit tests. It is desirable to include unit test covering all new features you implement. Also, if you find a bug which is not currently detected by the unit tests you might consider to implement a new one or modify the current implementation. After this, you can verify that everything works fine after your changes with:
+
+```
+mvn clean test
+```
+
+### Step 5: Push your changes
+
+Push your changes to your forked project with:
+```
+git push origin my-feature-branch
+```
+
+### Step 6: Create and submit a pull request
+Go to your forked project on GitHub, select your feature branch and click the “Compare, review, create a pull request button”. After that, we will review your pull request in a few days (hopefully!), but if we delay please be patient :). We do our best in our spare time to keep the project updated, but unfortunately there may be some periods of time in which we simply can’t work in the project.
+
+
+
+### License Agreement
+By contributing your code, you agree to license your contribution under the terms of the [Apache 2.0 license](https://raw.githubusercontent.com/citiususc/hipster/4ca93e681ad7335acbd0bea9e49fe678d56f3519/LICENSE).
+
+Also, remember to add this header to each new file that you’ve created:
+
+```
+/*
+* Copyright 2015 Centro de Investigación en Tecnoloxías da Información (CITIUS),
+* University of Santiago de Compostela (USC).
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+```
+
+That’s all!
diff --git a/README.md b/README.md
index 9042a27..27cfc33 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,9 @@
![Hipster](src/main/doclava/custom/assets/hipster-template/assets/images/header-logo.png?raw=true)
+[![SonarQube Tech Debt](https://img.shields.io/sonar/http/nemo.sonarqube.org/es.usc.citius.hipster:hipster-pom/tech_debt.svg)](http://nemo.sonarqube.org/dashboard/index/es.usc.citius.hipster:hipster-pom)
+[![Coverage](https://img.shields.io/sonar/http/nemo.sonarqube.org/es.usc.citius.hipster:hipster-pom/coverage.svg)]()
+![Build Status](https://api.travis-ci.org/citiususc/hipster.svg?branch=development)
+
A powerful and friendly heuristic search library implemented in Java.
## What's Hipster?
@@ -11,7 +15,7 @@ You can use Hipster to solve from simple graph search problems to more advanced
## Features
-The current version of the library comes with some very well-known and wide used search algorithms. Note that this list may not be exhaustive:
+The current version of the library comes with some very well-known and wide used search algorithms. We're working to add more algorithms soon:
* Search algorithms:
* Uninformed search:
@@ -26,8 +30,8 @@ The current version of the library comes with some very well-known and wide used
* Local search:
* Hill-Climbing.
* Enforced-Hill-Climbing.
- * Other (experimental implementations)
- * Multiobjective LS algorithm. Original paper: Martins, E. D. Q. V., & Santos, J. L. E. (1999). *"The labeling algorithm for the multiobjective shortest path problem"*. Departamento de Matematica, Universidade de Coimbra, Portugal, Tech. Rep. TR-99/005
+ * Multiobjective search
+ * Multiobjective LS algorithm. Original paper: Martins, E. D. Q. V., & Santos, J. L. E. (1999). *"The labeling algorithm for the multiobjective shortest path problem"*. Departamento de Matematica, Universidade de Coimbra, Portugal, Tech. Rep. TR-99/005 ([see an example](https://github.com/citiususc/hipster/wiki/Multiobjective-Search-with-Hipster-and-TinkerPop-Blueprints))
* 3rd party adapters:
* [Java Universal/Graph (JUNG)](http://jung.sourceforge.net/) adapter.
@@ -38,7 +42,7 @@ If you don't find the algorithm or the feature you are looking for, please consi
The easiest way to use Hipster is adding it as a dependency with your favourite dependency manager.
Maven users can include the library using the following snippet:
-#### Snapshots ![Build Status](https://api.travis-ci.org/citiususc/hipster.svg?branch=development)
+#### Snapshots
You can use the latest (unstable) version of Hipster under development. Just add the following dependency into your pom.xml:
@@ -68,21 +72,21 @@ You can use the latest (unstable) version of Hipster under development. Just add
```
-#### Releases [![Stories in Ready](https://badge.waffle.io/citiususc/hipster.png?label=ready&title=Ready)](http://waffle.io/citiususc/hipster)
+#### Releases
-Current stable release is v1.0.0-rc1. See the [milestones](https://github.com/citiususc/hipster/milestones) to check the current development status.
+Current stable release is v1.0.0-rc2. See the [milestones](https://github.com/citiususc/hipster/milestones) to check the current development status.
```xml
es.usc.citius.hipsterhipster-all
- 1.0.0-rc1
+ 1.0.0-rc2
```
@@ -127,11 +131,11 @@ System.out.println(Hipster.createDijkstra(p).search("F"));
Output result: `Total number of iterations: 7. States: [A, B, C, E, D, F], Actions: [2.0, 1.0, 3.0, 2.0, 2.0], Search information: WeightedNode{state=F, cost=10.0, estimation=0.0, score=10.0}`
But that's not all. Hipster comes with different problem examples
-that illustrate how Hipster can be used to solve a [wide variety of problems](https://github.com/citiususc/hipster/tree/development/hipster-examples/src/main/java/es/usc/citius/hipster/examples) (not only graph search).
+that illustrate how Hipster can be used to solve a [wide variety of problems](https://github.com/citiususc/hipster/tree/0c0ec9cb5087fede9930a6efbd5126afd69896ac/hipster-examples/src/main/java/es/usc/citius/hipster/examples) (not only graph search).
## What's next?
-If you want to learn how to solve a problem by searching with Hipster, check the wiki to [learn the basics](https://github.com/citiususc/hipster/wiki/Getting-Started) and the [JavaDoc documentation](http://www.hipster4j.org/javadocs/latest).
+If you want to learn how to solve a problem by searching with Hipster, check the [wiki](https://github.com/citiususc/hipster/wiki) and the [JavaDoc documentation](http://www.hipster4j.org/hipster-javadocs).
We also suggest you to check [this presentation](https://speakerdeck.com/pablormier/hipster-an-open-source-java-library-for-heuristic-search) for a quick introduction.
## License & Citation
diff --git a/hipster-all/pom.xml b/hipster-all/pom.xml
index 0e6902f..dc9eed4 100644
--- a/hipster-all/pom.xml
+++ b/hipster-all/pom.xml
@@ -21,7 +21,7 @@
es.usc.citius.hipsterhipster-pom
- 1.0.0-rc2
+ 1.0.0-SNAPSHOT4.0.0hipster-all
diff --git a/hipster-core/pom.xml b/hipster-core/pom.xml
index 5d17218..dc0d5bf 100644
--- a/hipster-core/pom.xml
+++ b/hipster-core/pom.xml
@@ -5,7 +5,7 @@
es.usc.citius.hipsterhipster-pom
- 1.0.0-rc2
+ 1.0.0-SNAPSHOT4.0.0hipster-core
diff --git a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/Algorithm.java b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/Algorithm.java
index bd3667c..fefdc5e 100644
--- a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/Algorithm.java
+++ b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/Algorithm.java
@@ -97,7 +97,7 @@ public String toString() {
final String ls = System.getProperty("line.separator");
StringBuilder builder = new StringBuilder();
builder.append("Total solutions: ").append(goalNodes.size()).append(ls);
- builder.append("Total time: ").append(getElapsed()).append(ls);
+ builder.append("Total time: ").append(getElapsed()).append(" ms").append(ls);
builder.append("Total number of iterations: ").append(getIterations()).append(ls);
// Take solutions
int solution=1;
@@ -216,7 +216,6 @@ public static > List recoverActionPath(N node){
for(N n : node.path()){
if (n.action() != null) actions.add(n.action());
}
- Collections.reverse(actions);
return actions;
}
}
diff --git a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/BellmanFord.java b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/BellmanFord.java
old mode 100644
new mode 100755
index ac520a2..9fd2d74
--- a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/BellmanFord.java
+++ b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/BellmanFord.java
@@ -47,6 +47,7 @@
public class BellmanFord,N extends CostNode> extends Algorithm {
protected N initialNode;
protected NodeExpander nodeExpander;
+ protected boolean checkNegativeCycles = true;
public BellmanFord(N initialNode, NodeExpander nodeExpander) {
this.initialNode = initialNode;
@@ -104,6 +105,9 @@ public boolean hasNext() {
public N next() {
// Take the next node
N currentNode = dequeue();
+ if (checkNegativeCycles && currentNode.pathSize() > explored.size()){
+ throw new NegativeCycleException();
+ }
for (N successor : nodeExpander.expand(currentNode)) {
// Check if there is any improvement in the old cost
N previousNode = this.explored.get(successor.state());
@@ -138,7 +142,7 @@ public SearchResult search(Predicate condition){
while(it.hasNext()){
iteration++;
currentNode = it.next();
- if (condition.apply(currentNode)) {
+ if (goalNode == null && condition.apply(currentNode)) {
goalNode = currentNode;
}
}
@@ -155,4 +159,28 @@ public SearchResult search(Predicate condition){
public Iterator iterator() {
return new Iterator();
}
+
+ public N getInitialNode() {
+ return initialNode;
+ }
+
+ public void setInitialNode(N initialNode) {
+ this.initialNode = initialNode;
+ }
+
+ public NodeExpander getNodeExpander() {
+ return nodeExpander;
+ }
+
+ public void setNodeExpander(NodeExpander nodeExpander) {
+ this.nodeExpander = nodeExpander;
+ }
+
+ public boolean isCheckNegativeCycles() {
+ return checkNegativeCycles;
+ }
+
+ public void setCheckNegativeCycles(boolean checkNegativeCycles) {
+ this.checkNegativeCycles = checkNegativeCycles;
+ }
}
diff --git a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/BreadthFirstSearch.java b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/BreadthFirstSearch.java
old mode 100644
new mode 100755
diff --git a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/DepthFirstSearch.java b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/DepthFirstSearch.java
old mode 100644
new mode 100755
index 238dc3e..aeb1462
--- a/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/DepthFirstSearch.java
+++ b/hipster-core/src/main/java/es/usc/citius/hipster/algorithm/DepthFirstSearch.java
@@ -19,10 +19,7 @@
import es.usc.citius.hipster.model.Node;
import es.usc.citius.hipster.model.function.NodeExpander;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Stack;
+import java.util.*;
/**
*