BMR and BWR optimization algorithms with constraint handling
Project description
Optimization Algorithms: BMR and BWR
This package implements two simple yet powerful optimization algorithms:
- BMR (Best-Mean-Random) Algorithm
- BWR (Best-Worst-Random) Algorithm
These algorithms are designed to solve both constrained and unconstrained optimization problems without relying on metaphors or algorithm-specific parameters. The package is based on the paper:
Ravipudi Venkata Rao and Ravikumar Shah (2024), "BMR and BWR: Two simple metaphor-free optimization algorithms for solving real-life non-convex constrained and unconstrained problems." arXiv:2407.11149v2.
Features
- Metaphor-Free: No reliance on nature-inspired metaphors.
- Simple: No algorithm-specific parameters to tune.
- Flexible: Handles both constrained and unconstrained optimization problems.
Installation
You can install this package directly from PyPI:
pip install rao_algorithms
Alternatively, you can clone this repository and install it locally:
git clone https://github.com/VaidhyaMegha/optimization_algorithms.git
cd optimization_algorithms
pip install .
How to Use
Example: Unconstrained BMR Algorithm
import numpy as np
from rao_algorithms import BMR_algorithm, objective_function
# Define the bounds for a 2D problem
bounds = np.array([[-100, 100]] * 2)
# Set parameters
num_iterations = 100
population_size = 50
num_variables = 2
# Run the BMR algorithm
best_fitness = BMR_algorithm(bounds, num_iterations, population_size, num_variables, objective_function)
print(f"Best fitness found: {best_fitness}")
Example: Constrained BWR Algorithm
import numpy as np
from rao_algorithms import BWR_algorithm, objective_function, constraint_1, constraint_2
# Define the bounds for a 2D problem
bounds = np.array([[-100, 100]] * 2)
# Set parameters
num_iterations = 100
population_size = 50
num_variables = 2
constraints = [constraint_1, constraint_2]
# Run the BWR algorithm with constraints
best_fitness = BWR_algorithm(bounds, num_iterations, population_size, num_variables, objective_function, constraints)
print(f"Best fitness found: {best_fitness}")
Unit Testing
This package comes with unit tests. To run the tests:
python -m unittest discover -s tests
You can also run the tests using Docker:
docker build -t optimization-algorithms .
docker run -it optimization-algorithms
Algorithms Overview
BMR (Best-Mean-Random) Algorithm
The BMR algorithm is based on the best, mean, and random solutions from the population. It works by updating solutions based on their interaction with these key elements.
- Paper Citation: R. V. Rao, R. Shah, BMR and BWR: Two simple metaphor-free optimization algorithms. arXiv:2407.11149v2.
BWR (Best-Worst-Random) Algorithm
The BWR algorithm updates solutions by considering the best, worst, and random solutions in the population. The algorithm balances exploration and exploitation through these interactions.
- Paper Citation: R. V. Rao, R. Shah, BMR and BWR: Two simple metaphor-free optimization algorithms. arXiv:2407.11149v2.
Docker Support
You can use the included Dockerfile to build and test the package quickly. To build and run the package in Docker:
docker build -t optimization-algorithms .
docker run -it optimization-algorithms
License
This package is licensed under the MIT License. See the LICENSE file for more details.
References
- Ravipudi Venkata Rao, Ravikumar Shah, "BMR and BWR: Two simple metaphor-free optimization algorithms for solving real-life non-convex constrained and unconstrained problems," arXiv:2407.11149v2.
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 rao_algorithms-0.1.4.tar.gz.
File metadata
- Download URL: rao_algorithms-0.1.4.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df97817b87f9efe536fa15e749785f5188b64ce86a55a6722945232032eb823b
|
|
| MD5 |
66fc35754902943d8e3d38515bceeb24
|
|
| BLAKE2b-256 |
73018e45dcd50c942f689a0f0398394cb2033c4149ce98c4654bec67aac3a116
|
File details
Details for the file rao_algorithms-0.1.4-py3-none-any.whl.
File metadata
- Download URL: rao_algorithms-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb28b82c25357b2a4aabbbe2a409d8b0d264ada7fcaab5863dbf5e5c252ce9d9
|
|
| MD5 |
1d98bed50ae1303e117fb32607fc236d
|
|
| BLAKE2b-256 |
b4bfe0086cd7ceae5a8f691beec182815bd8c389d12016386a587ecd7fc48f86
|