28
Hipster: An Open Source Java Library for Heuristic Search Pablo Rodríguez-Mier, Adrián González-Sieira, Manuel Mucientes, Manuel Lama, Alberto Bugarín. Centro Singular de Investigación en Tecnoloxías da Información Universidade de Santiago de Compostela 16 de junio de 2014 citius.usc.es

Hipster: An Open Source Java Library for Heuristic Search

Embed Size (px)

DESCRIPTION

We present Hipster: a free, open source Java library for heuristic search algorithms. The motivation of developing Hipster is the lack of standard Java search libraries with an extensible, flexible, simple to use model. Moreover, most of the libraries for search algorithms rely on recursive implementations which do not offer fine-grained control over the algorithm. Hipster provides a wide variety of classical search algorithms implemented in an iterative way like Dijkstra, A*, IDA*, AD* and more. In order to facilitate the use and integration with most research, commercial and non-commercial projects, the software is developed under the open source Apache 2.0 License. Hipster was successfully applied in two different research projects in the areas of Web service composition and motion planning. Source code, documentation, binaries and examples can be found at https://github.com/citiususc/hipster.

Citation preview

Page 1: Hipster: An Open Source Java Library for Heuristic Search

Hipster: An Open Source Java

Library for Heuristic Search

Pablo Rodríguez-Mier, Adrián González-Sieira, Manuel Mucientes,

Manuel Lama, Alberto Bugarín.

Centro Singular de Investigación en Tecnoloxías da Información

Universidade de Santiago de Compostela

16 de junio de 2014citius.usc.es

Page 2: Hipster: An Open Source Java Library for Heuristic Search

Problem Solving as State Space Search - I

Many AI problems can be formulated as State Space Search.

We have a problem and we need to find a solution:

. Where do we start from?

. What is the solution of the problem?

. How can we assess the quality of a solution of a problem?

. Which actions or steps can we take in order to solve it?

. How can we estimate how far we are from the solution during the

search?

Examples:

16 de junio de 2014 1/26

Page 3: Hipster: An Open Source Java Library for Heuristic Search

Problem Solving as State Space Search - II

In a nutshell, a state space search problem is defined in terms of states,

actions and transitions.

States: representation of a particular configuration of our problem.

. Initial state: where we start searching from.

. Goal state: state which represents a valid solution.

Actions: description of the possible actions or movements that we

can do from a given state.

Transitions: describe how actions lead from one given state to a

different state.

The solution to a problem is the sequence of actions that lead from the

initial state to the goal state.

16 de junio de 2014 2/26

Page 4: Hipster: An Open Source Java Library for Heuristic Search

8-Puzzle game example - Step 1

16 de junio de 2014 3/26

Page 5: Hipster: An Open Source Java Library for Heuristic Search

8-Puzzle game example - Step 2

16 de junio de 2014 4/26

Page 6: Hipster: An Open Source Java Library for Heuristic Search

8-Puzzle game example - Step 3

16 de junio de 2014 5/26

Page 7: Hipster: An Open Source Java Library for Heuristic Search

8-Puzzle game example - Step 4

16 de junio de 2014 6/26

Page 8: Hipster: An Open Source Java Library for Heuristic Search

8-Puzzle game example - Step 5

16 de junio de 2014 7/26

Page 9: Hipster: An Open Source Java Library for Heuristic Search

8-Puzzle game example - Step 6

16 de junio de 2014 8/26

Page 10: Hipster: An Open Source Java Library for Heuristic Search

Motivation - I

Why did we create Hipster?

There is an important lack of standard implementations of

algorithms in Java.

Most implementations are neither extensible nor flexible:

. The search process cannot be controlled.

. Costs are usually floats or doubles, there is no way to use complex

custom costs.

. There is no way to handle more than one single goal.

. ...

Graph specific libraries are not always suitable for problem solving!

16 de junio de 2014 9/26

Page 11: Hipster: An Open Source Java Library for Heuristic Search

Motivation - II

Project Goals

Iterative algorithms.

. while(search.hasNext()) search.next();

Flexible, extensible, reusable.

. Hipster.createAStar(problem).search(goal);

. Hipster.createIDA(problem).search(goal);

Powerful, simple, strong-typed API.

. Generic types→ compile-time type safety.

. Builders to assist the specification of search problems.

Highly-tested code.

. Unit tests, continuous integration in the cloud.

Open-Source.

. Permissive Apache 2.0 (GPL compatible) license.

16 de junio de 2014 10/26

Page 12: Hipster: An Open Source Java Library for Heuristic Search

Currently implemented algorithms

Uninformed search (no heuristics)

. Depth First Search (DFS)

. Breadth First Search (BFS)

. Dijkstra’s algorithm

. Bellman-Ford

Informed search

. A* algorithm

. Iterative Deepening A* (IDA*)

. Anytime Dynamic A* (AD*)

Local search

. Hill-climbing.

. Enforced Hill-climbing.

16 de junio de 2014 11/26

Page 13: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster

8-Puzzle state space formulation example

States: 8-Puzzle represented as an array of numbers.

Actions: movements of the empty tile (RIGHT, LEFT, UP, DOWN).

Transitions: state × action→ state’ (board with the tiles swapped).

. Example: {5,4,0,7,2,6,8,1,3} × LEFT = {5,0,4,7,2,6,8,1,3}

Solution: minimal sequence of actions from initial to goal

16 de junio de 2014 12/26

Page 14: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 1

16 de junio de 2014 13/26

Page 15: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 2

16 de junio de 2014 14/26

Page 16: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 3

16 de junio de 2014 15/26

Page 17: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 4

16 de junio de 2014 16/26

Page 18: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 5

16 de junio de 2014 17/26

Page 19: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 6

16 de junio de 2014 18/26

Page 20: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 7

16 de junio de 2014 19/26

Page 21: Hipster: An Open Source Java Library for Heuristic Search

Solving 8-Puzzle with Hipster - Step 8

Finally, we select an algorithm to perform the search until the goal state

is reached.

List<Integer> goalState = Arrays.asList(0,1,2,3,4,5,6,7,8);Hipster.createDijkstra(p).search(goalState);

16 de junio de 2014 20/26

Page 22: Hipster: An Open Source Java Library for Heuristic Search

Different ways to search

Search can also be done in multiple ways.

Automatic search:

Hipster.createAStar(p).search(goalState);

Automatic search with event listeners:

Hipster.createAStar(p).search(new Algorithm.SearchListener() {public void handle(Object node){

...}

});

Fine-grained iterative search:

for (Node n : Hipster.createAStar(p)) {System.out.println("Current state is " + n.state());if (n.state().equals(goalState)) ...

}

16 de junio de 2014 21/26

Page 23: Hipster: An Open Source Java Library for Heuristic Search

Java 8 lambda expressions

Boilerplate code (anonymous interface implementations) can be

removed using Java 8 lambda expressions:

16 de junio de 2014 22/26

Page 24: Hipster: An Open Source Java Library for Heuristic Search

Hipster in Action

Solving 8-Puzzle problem with Hipster. 3 minute video tutorial:

http://youtu.be/ZPOhmnzOKA4

16 de junio de 2014 23/26

Page 25: Hipster: An Open Source Java Library for Heuristic Search

Research projects using Hipster - I

Anytime Motion Replanning in State Lattices for Wheeled Robots.

Use of the Anytime Dynamic A* (AD*) for path search with

replanning.

Custom costs to evaluate the states:

. Collision probability.

. Path traversal time.

. Probability to reach safely the goal state.

16 de junio de 2014 24/26

Page 26: Hipster: An Open Source Java Library for Heuristic Search

Research projects using Hipster - II

Automatic Web Service Composition

Backward A* search to minimize the number of services.

Heuristics to estimate the distance to the goal.

w1w4

w5

L1 L2 L3

w6w3

w2

w7

w8

o2

o3

o4

o5

o6

i4

i5

i6

i8

i9

i10

i11

i7

o7

o8

o9

o10

o11

o12

o13

i12

i13

i14

i15

i16

L0 L4

WI WO

w9

o1

o14

o15

o16

i1

i2

i3

i17

i18

i19

16 de junio de 2014 25/26

Page 27: Hipster: An Open Source Java Library for Heuristic Search

Conclusions

A powerful but easy to use Java Library for using and developing

search algorithms.

Open Source, Apache 2.0 license.

Suitable for commercial and research projects.

Good for prototyping and testing algorithms.

Also suitable for teaching.

16 de junio de 2014 26/26

Page 28: Hipster: An Open Source Java Library for Heuristic Search

Thanks for listening!

Questions?

Hipster Web Page

http://citiususc.github.io/hipster

16 de junio de 2014