Explorateur
Explorateur is a Python library to conduct State-Space-Search (SSS), a powerful framework for solving problems that require search over a collection of states.
Explorateur performs generic state-space-search over problem-specific states and moves. The user defines the BaseState and BaseMove and the library drives the search for solutions.
The behavior of the search is controlled by the built-in Search Strategy and the Exploration Strategy and user-defined moves. Given an initial user state, Explorateur performs search moves iteratively until a stopping condition is reached.
Search Strategy
TreeSearchover open states,GraphSearchover open states while also storing the closed states to avoid visiting duplicates.
Exploration Strategy
BreadthFirstin an uninformed fashion,DepthFirstin an uninformed fashion,BestFirstin an informed fashion with an objective function that evaluates the quality of a state. By default, the best first search is set to minimize. To maximize, multiply your objective function by -1.
Stopping Conditions
- A termination state is found,
- The search space is exhausted,
- A stopping criterion such as max iterations, runtime limit, or max depth has been reached,
- (Optionally) The given goal state is encountered.
Quick Start
To use Explorateur, you must define BaseState and BaseMove as in the template below.
from explorateur import Explorateur, BaseMove, BaseState, ExplorationType, SearchType
# Implement your Search Moves
class MyMove(BaseMove):
def __init__(self):
# TODO Your move object
pass
def __str__(self) -> str:
# TODO Your move string, also used for node labels in DOT graph
pass
# Implement your own Search State
class MyState(BaseState):
def __init__(self):
# TODO Your problem-specific state representation
super().__init__() # Make sure to initialize the base state!
def get_moves(self) -> List[MyMove]:
# TODO Your branching decisions as a list of moves
pass
def is_terminate(self, goal_state=None) -> bool:
# TODO Is the current state a solution/termination?
pass
def execute(self, move: MyMove) -> bool:
# TODO Execute the move on the state and return success flag
pass
def __str__(self) -> str:
# TODO Your state string, also used for node labels in DOT graph
pass
# Explarateur
explorer = Explorateur()
# Initial state
initial_state = MyState()
# Search for solutions
if explorer.search(initial_state,
goal_state=None, # Optional goal state
exploration_type=ExplorationType.DepthFirst(),
search_type=SearchType.TreeSearch(),
is_solution_path=True,
dot_filename="tree_search_dfs.dot"):
# Retrieve the solution state and the solution path
# Dot graph file is also available for visualizing the search
print("Solution:", explorer.solution_state)
print("Solution Path:", *explorer.solution_path, sep="\n<-")
else:
print("No solution found!")
# Search statistics
print("Total Decisions:", explorer.num_decisions)
print("Total Failures:", explorer.num_failed_decisions)
print("Total Time:", explorer.total_time)
Examples
- Backtracking Tree-Search: A toy Constraint Satisfaction Problem to find a solution via backtracking tree search as depicted in search visualization.
- Graph Search: The classical Romanian Graph Problem solved with a goal state as depicted in search visualization. Note the use of
__eq__and__hash__to enable graph-based search to handle state comparison and hashing. - A* Search: The classical A* Search between an initial and goal state using an admissible heuristic solved with best-first search to minimize the total cost as depicted in search visualization. Note the use of
get_objectivefunction for optimization.
Installation
Explorateur can be installed from PyPI using pip install explorateur
Install from source
Alternatively, you can build a wheel package on your platform from scratch using the source code:
git clone https://github.com/skadio/explorateur.git
cd explorateur
pip install setuptools wheel # if wheel is not installed
python setup.py sdist bdist_wheel
pip install dist/explorateur-X.X.X-py3-none-any.whl
Test your setup
To confirm that cloning was successful, run the tests included in the project. All tests should pass.
git clone https://github.com/skadio/explorateur.git
cd explorateur
python -m unittest discover tests
To run a specific test from a given test file:
$ python -m unittest -v tests.<file_name>.<class_name>.<function_name>
For example:
$ python -m unittest -v tests.test_usage_example.UsageExampleTest.test_usage_example
To confirm that the installation was successful, try importing Explorateur after pip install explorateur
import explorateur
print(explorateur.__version__)
Support
Please submit bug reports and feature requests as Issues.
License
Explorateur is licensed under the Apache License 2.0.
Metadata
Release files for explorateur 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| explorateur-1.2.2.tar.gz | 24.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| explorateur-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.1 kB
Release files / explorateur-1.2.2.tar.gz
| Download URL | explorateur-1.2.2.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
472d92fdedb88beed67a293e4e84012237f291336c2884b2c95bc34771ea71f7
|
|
BLAKE2b-256 checksum How to use checksums |
43e45970deaa131156b05fcc9e8795d5eb569f8ee84629f62e72b02395c62597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / explorateur-1.2.2-py3-none-any.whl
| Download URL | explorateur-1.2.2-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98b47eca75f7796d8a7e810b637f0a080e2c5ba910023c46e758bae6f73711d6
|
|
BLAKE2b-256 checksum How to use checksums |
0f9eda56b14e3940af648ba9e436f90eae38bbfd9c69a3f7e954aed7966dbf82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for explorateur 1.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.