lonkit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lonkit-0.1.0/.github/workflows/ci.yml +51 -0
- lonkit-0.1.0/.github/workflows/docs.yml +52 -0
- lonkit-0.1.0/.github/workflows/publish.yml +44 -0
- lonkit-0.1.0/.gitignore +9 -0
- lonkit-0.1.0/.pre-commit-config.yaml +28 -0
- lonkit-0.1.0/PKG-INFO +137 -0
- lonkit-0.1.0/README.md +111 -0
- lonkit-0.1.0/docs/api/index.md +82 -0
- lonkit-0.1.0/docs/api/lon.md +41 -0
- lonkit-0.1.0/docs/api/sampling.md +24 -0
- lonkit-0.1.0/docs/api/visualization.md +16 -0
- lonkit-0.1.0/docs/assets/icon.png +0 -0
- lonkit-0.1.0/docs/contributing.md +116 -0
- lonkit-0.1.0/docs/getting-started/concepts.md +160 -0
- lonkit-0.1.0/docs/getting-started/installation.md +90 -0
- lonkit-0.1.0/docs/getting-started/quickstart.md +175 -0
- lonkit-0.1.0/docs/index.md +88 -0
- lonkit-0.1.0/docs/javascripts/mathjax.js +19 -0
- lonkit-0.1.0/docs/user-guide/analysis.md +343 -0
- lonkit-0.1.0/docs/user-guide/examples.md +341 -0
- lonkit-0.1.0/docs/user-guide/sampling.md +340 -0
- lonkit-0.1.0/docs/user-guide/visualization.md +268 -0
- lonkit-0.1.0/examples/bioma/README.md +75 -0
- lonkit-0.1.0/examples/bioma/__init__.py +0 -0
- lonkit-0.1.0/examples/bioma/fig1.py +70 -0
- lonkit-0.1.0/examples/bioma/fig3.py +65 -0
- lonkit-0.1.0/examples/bioma/fig4.py +87 -0
- lonkit-0.1.0/examples/bioma/fig6.py +65 -0
- lonkit-0.1.0/examples/bioma/problems.py +134 -0
- lonkit-0.1.0/examples/bioma/step_size.py +51 -0
- lonkit-0.1.0/examples/bioma/utils.py +236 -0
- lonkit-0.1.0/images/fig1.png +0 -0
- lonkit-0.1.0/images/fig2.png +0 -0
- lonkit-0.1.0/images/fig3.png +0 -0
- lonkit-0.1.0/images/fig4.png +0 -0
- lonkit-0.1.0/images/fig5.png +0 -0
- lonkit-0.1.0/images/fig6.png +0 -0
- lonkit-0.1.0/mkdocs.yml +102 -0
- lonkit-0.1.0/pyproject.toml +82 -0
- lonkit-0.1.0/src/lonkit/__init__.py +24 -0
- lonkit-0.1.0/src/lonkit/lon.py +730 -0
- lonkit-0.1.0/src/lonkit/py.typed +0 -0
- lonkit-0.1.0/src/lonkit/sampling.py +493 -0
- lonkit-0.1.0/src/lonkit/step_size.py +242 -0
- lonkit-0.1.0/src/lonkit/visualization.py +561 -0
- lonkit-0.1.0/tests/__init__.py +0 -0
- lonkit-0.1.0/tests/conftest.py +39 -0
- lonkit-0.1.0/tests/test_nfev.py +25 -0
- lonkit-0.1.0/tests/test_sampling.py +36 -0
- lonkit-0.1.0/tests/test_visualization.py +56 -0
- lonkit-0.1.0/uv.lock +2300 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
concurrency:
|
|
8
|
+
group: ci-${{ github.ref }}
|
|
9
|
+
cancel-in-progress: true
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
pre-commit:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup Python
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: '3.12'
|
|
21
|
+
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@v4
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: uv sync --all-extras
|
|
27
|
+
|
|
28
|
+
- name: Run pre-commit
|
|
29
|
+
uses: pre-commit/action@v3.0.1
|
|
30
|
+
|
|
31
|
+
tests:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
python-version: ['3.10', '3.12']
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
|
|
39
|
+
- name: Setup Python
|
|
40
|
+
uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: ${{ matrix.python-version }}
|
|
43
|
+
|
|
44
|
+
- name: Install uv
|
|
45
|
+
uses: astral-sh/setup-uv@v4
|
|
46
|
+
|
|
47
|
+
- name: Install dependencies
|
|
48
|
+
run: uv sync --all-extras
|
|
49
|
+
|
|
50
|
+
- name: Run tests
|
|
51
|
+
run: uv run pytest
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Deploy Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pages: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: "pages"
|
|
16
|
+
cancel-in-progress: false
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Python
|
|
25
|
+
uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: '3.12'
|
|
28
|
+
|
|
29
|
+
- name: Install uv
|
|
30
|
+
uses: astral-sh/setup-uv@v5
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: uv sync --all-extras
|
|
34
|
+
|
|
35
|
+
- name: Build docs
|
|
36
|
+
run: uv run mkdocs build
|
|
37
|
+
|
|
38
|
+
- name: Upload artifact
|
|
39
|
+
uses: actions/upload-pages-artifact@v3
|
|
40
|
+
with:
|
|
41
|
+
path: site
|
|
42
|
+
|
|
43
|
+
deploy:
|
|
44
|
+
environment:
|
|
45
|
+
name: github-pages
|
|
46
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
needs: build
|
|
49
|
+
steps:
|
|
50
|
+
- name: Deploy to GitHub Pages
|
|
51
|
+
id: deployment
|
|
52
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
name: Build distribution
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v5
|
|
16
|
+
|
|
17
|
+
- name: Build package
|
|
18
|
+
run: uv build
|
|
19
|
+
|
|
20
|
+
- name: Upload distribution artifacts
|
|
21
|
+
uses: actions/upload-artifact@v4
|
|
22
|
+
with:
|
|
23
|
+
name: python-package-distributions
|
|
24
|
+
path: dist/
|
|
25
|
+
|
|
26
|
+
publish-pypi:
|
|
27
|
+
name: Publish to PyPI
|
|
28
|
+
needs: build
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
environment:
|
|
31
|
+
name: pypi
|
|
32
|
+
url: https://pypi.org/p/lonkit
|
|
33
|
+
permissions:
|
|
34
|
+
id-token: write
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- name: Download distribution artifacts
|
|
38
|
+
uses: actions/download-artifact@v4
|
|
39
|
+
with:
|
|
40
|
+
name: python-package-distributions
|
|
41
|
+
path: dist/
|
|
42
|
+
|
|
43
|
+
- name: Publish to PyPI
|
|
44
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
lonkit-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v5.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-added-large-files
|
|
10
|
+
- id: check-merge-conflict
|
|
11
|
+
- id: debug-statements
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
+
rev: v0.8.2
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff
|
|
17
|
+
args: [--fix]
|
|
18
|
+
- id: ruff-format
|
|
19
|
+
|
|
20
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
21
|
+
rev: v1.13.0
|
|
22
|
+
hooks:
|
|
23
|
+
- id: mypy
|
|
24
|
+
additional_dependencies:
|
|
25
|
+
- numpy
|
|
26
|
+
- pandas-stubs
|
|
27
|
+
- types-Pillow
|
|
28
|
+
args: [--ignore-missing-imports]
|
lonkit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lonkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local Optima Networks (LONs) for continuous optimization - Python implementation
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: igraph>=0.11.0
|
|
7
|
+
Requires-Dist: imageio>=2.31.0
|
|
8
|
+
Requires-Dist: kaleido>=0.2.1
|
|
9
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
10
|
+
Requires-Dist: numpy>=1.24.0
|
|
11
|
+
Requires-Dist: pandas>=2.0.0
|
|
12
|
+
Requires-Dist: plotly>=5.15.0
|
|
13
|
+
Requires-Dist: scipy>=1.10.0
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: ioh>=0.3.22; extra == 'dev'
|
|
16
|
+
Requires-Dist: mkdocs-material>=9.7.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: mkdocs>=1.6.1; extra == 'dev'
|
|
18
|
+
Requires-Dist: mkdocstrings-python>=1.0.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: mkdocstrings>=1.0.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: mypy>=1.13.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pre-commit>=4.0.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
<div align="center">
|
|
28
|
+
<img src="docs/assets/icon.png" alt="lonkit" width="800">
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/lonkit/)
|
|
32
|
+
[](https://www.python.org/downloads/)
|
|
33
|
+
[](https://colab.research.google.com/drive/1Ujl48ffgHg9ck1Hueh59s65OR3Q3BG99?usp=sharing)
|
|
34
|
+
|
|
35
|
+
**Local Optima Networks for Continuous Optimization**
|
|
36
|
+
|
|
37
|
+
lonkit is a Python library for constructing, analyzing, and visualizing Local Optima Networks (LONs) for continuous optimization problems. LONs provide a powerful way to understand the structure of fitness landscapes, revealing how local optima are connected and how difficult it may be to find global optima.
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Basin-Hopping Sampling**: Efficient exploration of fitness landscapes using configurable Basin-Hopping
|
|
42
|
+
- **LON Construction**: Automatic construction of Local Optima Networks from sampling data
|
|
43
|
+
- **CMLON Support**: Compressed Monotonic LONs for cleaner landscape analysis
|
|
44
|
+
- **Rich Metrics**: Compute landscape metrics including funnel analysis and neutrality
|
|
45
|
+
- **Beautiful Visualizations**: 2D and 3D plots with support for animated GIFs
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install lonkit
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or install from source:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/helix-agh/lonkit.git
|
|
57
|
+
cd lonkit
|
|
58
|
+
pip install -e .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import numpy as np
|
|
65
|
+
from lonkit import compute_lon, LONVisualizer, BasinHoppingSamplerConfig
|
|
66
|
+
|
|
67
|
+
# Define an objective function
|
|
68
|
+
def rastrigin(x: np.ndarray) -> float:
|
|
69
|
+
return 10 * len(x) + np.sum(x**2 - 10 * np.cos(2 * np.pi * x))
|
|
70
|
+
|
|
71
|
+
# Construct the LON
|
|
72
|
+
config = BasinHoppingSamplerConfig(
|
|
73
|
+
n_runs=20,
|
|
74
|
+
n_iter_no_change=500,
|
|
75
|
+
seed=42
|
|
76
|
+
)
|
|
77
|
+
lon = compute_lon(
|
|
78
|
+
rastrigin,
|
|
79
|
+
dim=2,
|
|
80
|
+
lower_bound=-5.12,
|
|
81
|
+
upper_bound=5.12,
|
|
82
|
+
config=config
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
metrics = lon.compute_metrics()
|
|
86
|
+
print(f"Number of funnels: {metrics['n_funnels']}")
|
|
87
|
+
print(f"Global funnels: {metrics['n_global_funnels']}")
|
|
88
|
+
|
|
89
|
+
# Visualize
|
|
90
|
+
viz = LONVisualizer()
|
|
91
|
+
viz.plot_2d(lon, output_path="lon_2d.png")
|
|
92
|
+
viz.plot_3d(lon, output_path="lon_3d.png")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Compressed Monotonic LONs (CMLONs)
|
|
96
|
+
|
|
97
|
+
CMLONs are a compressed representation where nodes with equal fitness that are connected get merged. This provides a cleaner view of the landscape's funnel structure.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Convert LON to CMLON
|
|
101
|
+
cmlon = lon.to_cmlon()
|
|
102
|
+
|
|
103
|
+
# Analyze CMLON-specific metrics
|
|
104
|
+
cmlon_metrics = cmlon.compute_metrics()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Custom Sampling Configuration
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from lonkit import BasinHoppingSampler, BasinHoppingSamplerConfig
|
|
111
|
+
|
|
112
|
+
config = BasinHoppingSamplerConfig(
|
|
113
|
+
n_runs=50, # Number of independent runs
|
|
114
|
+
n_iter_no_change=1000, # Stop after this many consecutive non-improving perturbations
|
|
115
|
+
step_size=0.05, # Perturbation size
|
|
116
|
+
step_mode="percentage", # "percentage" or "fixed"
|
|
117
|
+
coordinate_precision=4, # Precision for identifying optima
|
|
118
|
+
fitness_precision=None, # Precision for fitness values (None = full double)
|
|
119
|
+
seed=42 # For reproducibility
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
sampler = BasinHoppingSampler(config)
|
|
123
|
+
|
|
124
|
+
# Define search domain
|
|
125
|
+
domain = [(-5.12, 5.12), (-5.12, 5.12)]
|
|
126
|
+
|
|
127
|
+
# Run sampling
|
|
128
|
+
lon = sampler.sample_to_lon(rastrigin, domain)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Documentation
|
|
132
|
+
|
|
133
|
+
For full documentation, visit: [https://helix-agh.github.io/lonkit](https://helix-agh.github.io/lonkit)
|
|
134
|
+
|
|
135
|
+
## Contributing
|
|
136
|
+
|
|
137
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
lonkit-0.1.0/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="docs/assets/icon.png" alt="lonkit" width="800">
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/lonkit/)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://colab.research.google.com/drive/1Ujl48ffgHg9ck1Hueh59s65OR3Q3BG99?usp=sharing)
|
|
8
|
+
|
|
9
|
+
**Local Optima Networks for Continuous Optimization**
|
|
10
|
+
|
|
11
|
+
lonkit is a Python library for constructing, analyzing, and visualizing Local Optima Networks (LONs) for continuous optimization problems. LONs provide a powerful way to understand the structure of fitness landscapes, revealing how local optima are connected and how difficult it may be to find global optima.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Basin-Hopping Sampling**: Efficient exploration of fitness landscapes using configurable Basin-Hopping
|
|
16
|
+
- **LON Construction**: Automatic construction of Local Optima Networks from sampling data
|
|
17
|
+
- **CMLON Support**: Compressed Monotonic LONs for cleaner landscape analysis
|
|
18
|
+
- **Rich Metrics**: Compute landscape metrics including funnel analysis and neutrality
|
|
19
|
+
- **Beautiful Visualizations**: 2D and 3D plots with support for animated GIFs
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install lonkit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or install from source:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/helix-agh/lonkit.git
|
|
31
|
+
cd lonkit
|
|
32
|
+
pip install -e .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import numpy as np
|
|
39
|
+
from lonkit import compute_lon, LONVisualizer, BasinHoppingSamplerConfig
|
|
40
|
+
|
|
41
|
+
# Define an objective function
|
|
42
|
+
def rastrigin(x: np.ndarray) -> float:
|
|
43
|
+
return 10 * len(x) + np.sum(x**2 - 10 * np.cos(2 * np.pi * x))
|
|
44
|
+
|
|
45
|
+
# Construct the LON
|
|
46
|
+
config = BasinHoppingSamplerConfig(
|
|
47
|
+
n_runs=20,
|
|
48
|
+
n_iter_no_change=500,
|
|
49
|
+
seed=42
|
|
50
|
+
)
|
|
51
|
+
lon = compute_lon(
|
|
52
|
+
rastrigin,
|
|
53
|
+
dim=2,
|
|
54
|
+
lower_bound=-5.12,
|
|
55
|
+
upper_bound=5.12,
|
|
56
|
+
config=config
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
metrics = lon.compute_metrics()
|
|
60
|
+
print(f"Number of funnels: {metrics['n_funnels']}")
|
|
61
|
+
print(f"Global funnels: {metrics['n_global_funnels']}")
|
|
62
|
+
|
|
63
|
+
# Visualize
|
|
64
|
+
viz = LONVisualizer()
|
|
65
|
+
viz.plot_2d(lon, output_path="lon_2d.png")
|
|
66
|
+
viz.plot_3d(lon, output_path="lon_3d.png")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Compressed Monotonic LONs (CMLONs)
|
|
70
|
+
|
|
71
|
+
CMLONs are a compressed representation where nodes with equal fitness that are connected get merged. This provides a cleaner view of the landscape's funnel structure.
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
# Convert LON to CMLON
|
|
75
|
+
cmlon = lon.to_cmlon()
|
|
76
|
+
|
|
77
|
+
# Analyze CMLON-specific metrics
|
|
78
|
+
cmlon_metrics = cmlon.compute_metrics()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Custom Sampling Configuration
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from lonkit import BasinHoppingSampler, BasinHoppingSamplerConfig
|
|
85
|
+
|
|
86
|
+
config = BasinHoppingSamplerConfig(
|
|
87
|
+
n_runs=50, # Number of independent runs
|
|
88
|
+
n_iter_no_change=1000, # Stop after this many consecutive non-improving perturbations
|
|
89
|
+
step_size=0.05, # Perturbation size
|
|
90
|
+
step_mode="percentage", # "percentage" or "fixed"
|
|
91
|
+
coordinate_precision=4, # Precision for identifying optima
|
|
92
|
+
fitness_precision=None, # Precision for fitness values (None = full double)
|
|
93
|
+
seed=42 # For reproducibility
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
sampler = BasinHoppingSampler(config)
|
|
97
|
+
|
|
98
|
+
# Define search domain
|
|
99
|
+
domain = [(-5.12, 5.12), (-5.12, 5.12)]
|
|
100
|
+
|
|
101
|
+
# Run sampling
|
|
102
|
+
lon = sampler.sample_to_lon(rastrigin, domain)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Documentation
|
|
106
|
+
|
|
107
|
+
For full documentation, visit: [https://helix-agh.github.io/lonkit](https://helix-agh.github.io/lonkit)
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Complete API documentation for lonkit.
|
|
4
|
+
|
|
5
|
+
## Modules
|
|
6
|
+
|
|
7
|
+
lonkit is organized into three main modules:
|
|
8
|
+
|
|
9
|
+
### [LON Module](lon.md)
|
|
10
|
+
|
|
11
|
+
Data structures for Local Optima Networks.
|
|
12
|
+
|
|
13
|
+
- [`LON`](lon.md#lonkit.lon.LON) - Local Optima Network representation
|
|
14
|
+
- [`CMLON`](lon.md#lonkit.lon.CMLON) - Compressed Monotonic LON
|
|
15
|
+
- [`LONConfig`](lon.md#lonkit.lon.LONConfig) - Configuration for LON construction
|
|
16
|
+
|
|
17
|
+
### [Sampling Module](sampling.md)
|
|
18
|
+
|
|
19
|
+
Basin-Hopping sampling for LON construction.
|
|
20
|
+
|
|
21
|
+
- [`compute_lon()`](sampling.md#lonkit.sampling.compute_lon) - High-level convenience function
|
|
22
|
+
- [`BasinHoppingSampler`](sampling.md#lonkit.sampling.BasinHoppingSampler) - Sampling class
|
|
23
|
+
- [`BasinHoppingSamplerConfig`](sampling.md#lonkit.sampling.BasinHoppingSamplerConfig) - Configuration
|
|
24
|
+
|
|
25
|
+
### [Visualization Module](visualization.md)
|
|
26
|
+
|
|
27
|
+
Plotting and animation tools.
|
|
28
|
+
|
|
29
|
+
- [`LONVisualizer`](visualization.md#lonkit.visualization.LONVisualizer) - Visualization class
|
|
30
|
+
|
|
31
|
+
## Quick Reference
|
|
32
|
+
|
|
33
|
+
### Creating a LON
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from lonkit import compute_lon, BasinHoppingSamplerConfig
|
|
37
|
+
|
|
38
|
+
# Simple usage
|
|
39
|
+
lon = compute_lon(
|
|
40
|
+
func=objective_function,
|
|
41
|
+
dim=2,
|
|
42
|
+
lower_bound=-5.0,
|
|
43
|
+
upper_bound=5.0,
|
|
44
|
+
config=BasinHoppingSamplerConfig(n_runs=20, seed=42)
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Analyzing a LON
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
# Basic properties
|
|
52
|
+
print(f"Optima: {lon.n_vertices}")
|
|
53
|
+
print(f"Edges: {lon.n_edges}")
|
|
54
|
+
print(f"Best: {lon.best_fitness}")
|
|
55
|
+
|
|
56
|
+
# Compute metrics
|
|
57
|
+
metrics = lon.compute_metrics()
|
|
58
|
+
|
|
59
|
+
# Convert to CMLON
|
|
60
|
+
cmlon = lon.to_cmlon()
|
|
61
|
+
cmlon_metrics = cmlon.compute_metrics()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Visualizing a LON
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from lonkit import LONVisualizer
|
|
68
|
+
|
|
69
|
+
viz = LONVisualizer()
|
|
70
|
+
|
|
71
|
+
# 2D plot
|
|
72
|
+
viz.plot_2d(lon, output_path="lon.png")
|
|
73
|
+
|
|
74
|
+
# 3D plot
|
|
75
|
+
viz.plot_3d(lon, output_path="lon_3d.png")
|
|
76
|
+
|
|
77
|
+
# Animation
|
|
78
|
+
viz.create_rotation_gif(lon, output_path="lon.gif")
|
|
79
|
+
|
|
80
|
+
# All visualizations
|
|
81
|
+
viz.visualize_all(lon, output_folder="./output")
|
|
82
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# LON Module
|
|
2
|
+
|
|
3
|
+
::: lonkit.lon.LON
|
|
4
|
+
options:
|
|
5
|
+
show_root_heading: true
|
|
6
|
+
show_source: true
|
|
7
|
+
members:
|
|
8
|
+
- from_trace_data
|
|
9
|
+
- n_vertices
|
|
10
|
+
- n_edges
|
|
11
|
+
- vertex_names
|
|
12
|
+
- vertex_fitness
|
|
13
|
+
- vertex_count
|
|
14
|
+
- get_sinks
|
|
15
|
+
- compute_metrics
|
|
16
|
+
- to_cmlon
|
|
17
|
+
|
|
18
|
+
::: lonkit.lon.CMLON
|
|
19
|
+
options:
|
|
20
|
+
show_root_heading: true
|
|
21
|
+
show_source: true
|
|
22
|
+
members:
|
|
23
|
+
- from_lon
|
|
24
|
+
- n_vertices
|
|
25
|
+
- n_edges
|
|
26
|
+
- vertex_fitness
|
|
27
|
+
- vertex_count
|
|
28
|
+
- get_sinks
|
|
29
|
+
- get_global_sinks
|
|
30
|
+
- get_local_sinks
|
|
31
|
+
- compute_metrics
|
|
32
|
+
|
|
33
|
+
::: lonkit.lon.LONConfig
|
|
34
|
+
options:
|
|
35
|
+
show_root_heading: true
|
|
36
|
+
show_source: true
|
|
37
|
+
members:
|
|
38
|
+
- fitness_aggregation
|
|
39
|
+
- warn_on_duplicates
|
|
40
|
+
- max_fitness_deviation
|
|
41
|
+
- eq_atol
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Sampling Module
|
|
2
|
+
|
|
3
|
+
::: lonkit.sampling.compute_lon
|
|
4
|
+
options:
|
|
5
|
+
show_root_heading: true
|
|
6
|
+
show_source: true
|
|
7
|
+
|
|
8
|
+
::: lonkit.sampling.BasinHoppingSamplerConfig
|
|
9
|
+
options:
|
|
10
|
+
show_root_heading: true
|
|
11
|
+
show_source: true
|
|
12
|
+
|
|
13
|
+
::: lonkit.sampling.BasinHoppingSampler
|
|
14
|
+
options:
|
|
15
|
+
show_root_heading: true
|
|
16
|
+
show_source: true
|
|
17
|
+
members:
|
|
18
|
+
- sample
|
|
19
|
+
- sample_to_lon
|
|
20
|
+
|
|
21
|
+
::: lonkit.sampling.BasinHoppingResult
|
|
22
|
+
options:
|
|
23
|
+
show_root_heading: true
|
|
24
|
+
show_source: true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Visualization Module
|
|
2
|
+
|
|
3
|
+
::: lonkit.visualization.LONVisualizer
|
|
4
|
+
options:
|
|
5
|
+
show_root_heading: true
|
|
6
|
+
show_source: true
|
|
7
|
+
members:
|
|
8
|
+
- plot_2d
|
|
9
|
+
- plot_3d
|
|
10
|
+
- create_rotation_gif
|
|
11
|
+
- visualize_all
|
|
12
|
+
- compute_edge_widths
|
|
13
|
+
- compute_node_sizes
|
|
14
|
+
- compute_lon_colors
|
|
15
|
+
- compute_cmlon_colors
|
|
16
|
+
- get_layout
|
|
Binary file
|