A collection of state space search algorithms.
Project description
Omnisearch
This library provides a collection of state space search algorithms designed to solve problems defined by the StateSpaceProblem interface. The library includes both blind and informed search algorithms, making it versatile for various problem-solving scenarios.
Installation
You can install this software using pip:
pip install -U omnisearch
You can install the latest version of the code directly from GitHub:
pip install -U git+https://github.com/chaseburton/omnisearch@main
Important Links
- Source code: https://github.com/chaseburton/omnisearch
- Documentation: http://omnisearch.readthedocs.org
Structure
The library is structured as a package containing several search algorithms. Each algorithm utilizes a standard interface, allowing users to easily switch between algorithms when solving a problem. To demonstrate the usage of these algorithms, three example problems are provided, which can be run using blind_search.py and informed_search.py.
Algorithms
The library includes the following algorithms:
- A Star Search (A*)
- Best-First Search (BestFS)
- Branch And Bound (B&B)
- Breadth-First Search (BFS)
- Depth-First Search (DFS)
- Hill Climbing (HC)
- Iterative Deepening (ID)
- Uniform Cost Search (UCS)
Usage
To use the library, first, create a class for your problem that inherits from the StateSpaceProblem interface. This interface requires you to define the following methods:
initial_state(): Returns the initial state of the problem.goal_check(state): Checks if the given state is a goal state. Allows for problems with multiple or unknown goal states.operators(): Returns the list of operators applicable to the problem.apply_operator(operator, state): Applies the given operator to the state and returns the resulting state.cost(state1, state2): Returns the cost of transitioning from state1 to state2.solution(state): Returns the solution for the problem given the goal state.
After defining your problem, you can use any of the algorithms from the library by importing the desired algorithm and passing your problem instance to it. If needed, you can also provide a heuristic function for informed search algorithms like Best-First Search and A* Search.
Example
# algorithms
from omnisearch.algorithms.a_star import a_star_search
from omnisearch.algorithms.best_first import best_first_search
from omnisearch.algorithms.branch_and_bound import branch_and_bound_search
from omnisearch.algorithms.breadth_first import breadth_first_search
from omnisearch.algorithms.depth_first import depth_first_search
from omnisearch.algorithms.hill_climbing import hill_climbing_search
from omnisearch.algorithms.iterative_deepening import iterative_deepening_search
from omnisearch.algorithms.uniform_cost import uniform_cost_search
# existing problems
from omnisearch.problems.maze import MazeProblem
from omnisearch.problems.missionaries_and_cannibals import MissionariesAndCannibalsProblem
from omnisearch.problems.n_queens import NQueensProblem
# example problem
from your_problem import YourProblem
problem = YourProblem()
solution = a_star_search(problem, heuristic=your_heuristic_function)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omnisearch-0.0.4.tar.gz.
File metadata
- Download URL: omnisearch-0.0.4.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fb8595e3e6081e5098609aa7150bdae5f52d433c6205bfa56a6b0ca125027f7
|
|
| MD5 |
a2d789db165bf211f80ce8400b9d8fd3
|
|
| BLAKE2b-256 |
c24bc7b5d6f58fd823a1a80354a608b562a02c647dbe19488573555b22e93692
|
File details
Details for the file omnisearch-0.0.4-py3-none-any.whl.
File metadata
- Download URL: omnisearch-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c71348576626746bb8e76973eddd9887619e45c6f2a568009f6181bdbcf9ca7
|
|
| MD5 |
7f185f4b0f76720169de3f5a0018d0fa
|
|
| BLAKE2b-256 |
350f317455d040d30f34ba2539759886e10ca4704d1a3c12b58fd09c15fba663
|