An implementation of Local Search algorithms based on single solution design
Project description
Local Search - Metaheuristic
Project GIT address: https://github.com/anduralex/LSpackage.git
This lib implements some algorithms described on the book “Metaheuristics - From Design to Implementation”, from El-Ghazali Talbi.
I am testing the lib and it is available via pip install.
At this moment, the implementation includes:
- Search
Local Search algorithms - Hill Climbing
Installation
Just get it:
pip install LSpackage
You will need to have pip installed on your system. On linux install the python-pip package.
Examples
LSpackage allows you to define problems and look for the solution with different strategies. A sample are in the hello_word.py.
The problem will try to create the string “HELLO WORLD” using localSearchAlg algorithm:
from code.models import SearchProblem
from code.local import hillClimbing,localSearchAlg,firstExpander
WORD = 'HELLO WORLD'
class HelloProblem(SearchProblem):
def actions(self, state):
if len(state) < len(WORD):
return list(' ABCDEFGHIJKLMNOPQRSTUVWXYZ')
else:
return []
def result(self, state, action):
return state+action
def value(self, state):
# how many correct letters there are?
count=sum(1 if state[i] == WORD[i] else 0
for i in range(min(len(WORD), len(state))))
return count
result = localSearchAlg(HelloProblem(initial_state=''),firstExpander)
print(result.state)
More detailed documentation
You can read the book “Metaheuristics - From Design to Implementation”, from El-Ghazali Talbi. Or for offline access, you can clone the project code repository and work with it.
Project details
Release history Release notifications | RSS feed
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 LSpackage-1.0.tar.gz.
File metadata
- Download URL: LSpackage-1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c2937f306d986171d7b97b965d84fe23e6081a386396645c050cb03217d9a03
|
|
| MD5 |
9e354ed8c735ad6ed4e766b674d1d0ed
|
|
| BLAKE2b-256 |
76b7069b58b601411dcc751f113251d1d6f0842420df844c2b5a0a5ad8c9dc76
|
File details
Details for the file LSpackage-1.0-py2-none-any.whl.
File metadata
- Download URL: LSpackage-1.0-py2-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
460580b55520008800a0f0434698d6e27b9c31f64dfa8f3f6212b1deaa94cee5
|
|
| MD5 |
e451b49e11135eca04fbae1714eacd6b
|
|
| BLAKE2b-256 |
99769dc38c343123f7ce22845bdfacfa8cd1a863276474c44131c7f454823d87
|