Optimization algorithms by Prof. R.V. Rao with constraint handling
Project description
Optimization Algorithms by Prof. R.V. Rao
This package implements several powerful optimization algorithms developed by Prof. Ravipudi Venkata Rao:
- BMR (Best-Mean-Random) Algorithm
- BWR (Best-Worst-Random) Algorithm
- Jaya Algorithm
- Rao Algorithms (Rao-1, Rao-2, Rao-3)
- TLBO (Teaching-Learning-Based Optimization) Algorithm
These algorithms are designed to solve both constrained and unconstrained optimization problems without relying on metaphors or algorithm-specific parameters. The BMR and BWR algorithms are 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: Most algorithms have no algorithm-specific parameters to tune.
- Flexible: Handles both constrained and unconstrained optimization problems.
- Versatile: Includes a variety of algorithms suitable for different types of 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: Constrained BMR Algorithm
import numpy as np
from rao_algorithms import run_optimization, BMR_algorithm, objective_function, constraint_1, constraint_2
# Constrained BMR
# ---------------
bounds = np.array([[-100, 100]] * 2)
num_iterations = 100
population_size = 50
constraints = [constraint_1, constraint_2]
best_solution, best_scores = run_optimization(BMR_algorithm, bounds, num_iterations, population_size, 2, objective_function, constraints)
print(f"Constrained BMR Best solution: {best_solution}")
Example: Jaya Algorithm
import numpy as np
from rao_algorithms import Jaya_algorithm, objective_function
# Unconstrained Jaya
# -----------------
# 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 Jaya algorithm
best_solution, best_scores = Jaya_algorithm(bounds, num_iterations, population_size, num_variables, objective_function)
print(f"Jaya Best solution found: {best_solution}")
Example: TLBO Algorithm
import numpy as np
from rao_algorithms import TLBO_algorithm, objective_function
# Unconstrained TLBO
# -----------------
# 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 TLBO algorithm
best_solution, best_scores = TLBO_algorithm(bounds, num_iterations, population_size, num_variables, objective_function)
print(f"TLBO Best solution found: {best_solution}")
Example: Rao Algorithms
import numpy as np
from rao_algorithms import Rao1_algorithm, Rao2_algorithm, Rao3_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 Rao-1 algorithm
best_solution_rao1, best_scores_rao1 = Rao1_algorithm(bounds, num_iterations, population_size, num_variables, objective_function)
print(f"Rao-1 Best solution found: {best_solution_rao1}")
# Run the Rao-2 algorithm
best_solution_rao2, best_scores_rao2 = Rao2_algorithm(bounds, num_iterations, population_size, num_variables, objective_function)
print(f"Rao-2 Best solution found: {best_solution_rao2}")
# Run the Rao-3 algorithm
best_solution_rao3, best_scores_rao3 = Rao3_algorithm(bounds, num_iterations, population_size, num_variables, objective_function)
print(f"Rao-3 Best solution found: {best_solution_rao3}")
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.
Jaya Algorithm
The Jaya algorithm is a parameter-free algorithm that always tries to move toward the best solution and away from the worst solution. The name "Jaya" means "victory" in Sanskrit.
- Paper Citation: R. V. Rao, "Jaya: A simple and new optimization algorithm for solving constrained and unconstrained optimization problems", International Journal of Industrial Engineering Computations, 7(1), 2016, 19-34.
Rao Algorithms (Rao-1, Rao-2, Rao-3)
The Rao algorithms are a family of three metaphor-less optimization algorithms. Each algorithm uses a different strategy to guide the search process:
-
Rao-1: Uses the best solution and solution comparison
-
Rao-2: Uses the best, worst, and average fitness
-
Rao-3: Uses the best solution and a phase factor
-
Paper Citation: R. V. Rao, "Rao algorithms: Three metaphor-less simple algorithms for solving optimization problems", International Journal of Industrial Engineering Computations, 11(2), 2020, 193-212.
TLBO (Teaching-Learning-Based Optimization)
TLBO is a parameter-free algorithm inspired by the teaching-learning process in a classroom. It consists of two phases: Teacher Phase and Learner Phase.
- Paper Citation: R. V. Rao, V. J. Savsani, D. P. Vakharia, "Teaching-Learning-Based Optimization: An optimization method for continuous non-linear large scale problems", Information Sciences, 183(1), 2012, 1-15.
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.
- Ravipudi Venkata Rao, "Jaya: A simple and new optimization algorithm for solving constrained and unconstrained optimization problems", International Journal of Industrial Engineering Computations, 7(1), 2016, 19-34.
- Ravipudi Venkata Rao, "Rao algorithms: Three metaphor-less simple algorithms for solving optimization problems", International Journal of Industrial Engineering Computations, 11(2), 2020, 193-212.
- Ravipudi Venkata Rao, V. J. Savsani, D. P. Vakharia, "Teaching-Learning-Based Optimization: An optimization method for continuous non-linear large scale problems", Information Sciences, 183(1), 2012, 1-15.
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.3.0.tar.gz.
File metadata
- Download URL: rao_algorithms-0.3.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6be9f0306538ac4c8cabde158aed86f8ee99c6999ac612e5ada754f2cfa07eba
|
|
| MD5 |
94b819263e19272217a49f84fb3a691e
|
|
| BLAKE2b-256 |
57aa97310606b23d3af5be1581033d2725c58d82e20ce64b348e2461e80543be
|
File details
Details for the file rao_algorithms-0.3.0-py3-none-any.whl.
File metadata
- Download URL: rao_algorithms-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e214387d113b3543661756773c48b5f14f65bc1925f5e93dc9f3009d72c4b9e7
|
|
| MD5 |
32ece7c87ef3ecad6d18553cf6248a0b
|
|
| BLAKE2b-256 |
55179b994c9731216469806cb6af63af87b42c0505c46cdd1b1df427e874c45f
|