A Mathematical Optimization Method Based on Runge-Kutta Method
Project description
RUN-Optimization-Algorithm
A Mathematical Optimization Method Based on Runge-Kutta Method
RUN: Runge Kutta Optimization Algorithm
The RUN algorithm is a metaheuristic optimization algorithm inspired by the Runge-Kutta method, primarily used for solving unconstrained or constrained optimization problems. This repository contains an implementation of the RUN algorithm with flexibility in constraint handling methods and initialization processes.
Features
- Multi-dimensional Optimization: Capable of optimizing functions in multiple dimensions.
- Constraint Handling: Includes options for traditional clipping constraints and random reinitialization.
- Flexible Initialization: Supports initialization with scalar or vector bounds.
- Verbose Output: Optional verbose mode to print the convergence progress.
Installation
- pip install IM_RUN_optimizer
Parameters
Parameters
- nP: Number of particles in the swarm.
- MaxIt: Maximum number of iterations for the optimization loop.
- lb, ub: Lower and upper bounds for the solution space, which can be scalars (applied uniformly across all dimensions) or vectors (specific to each dimension).
- dim: Dimensionality of the optimization problem.
- fobj: Objective function to be minimized.
- constraint_handling: Method for constraint handling ("clip" for clipping, "RI" for random reinitialization).
- verbose: Boolean flag to enable or disable verbose output.
Constraint Handling Methods
-
Clipping (Default): Keeps all values within the specified bounds using np.clip.
-
Random Reinitialization (RI): If a particle exceeds the bounds, its position is reinitialized randomly within the permissible range.
Run RUN Algorithm
To use the RUN algorithm, import the RUN function from the module and define your objective function. Set the parameters such as population size, maximum iterations, and bounds.
import numpy as np
from IM_RUN_optimizer import RUN
Define objective function
def sphere_function(x):
return np.sum(x**2)
Set parameters
nP = 30 # Number of particles
MaxIt = 100 # Maximum number of iterations
dim = 30 # Problem dimension
lb = -100 # Lower bound (scalar or vector)
ub = 100 # Upper bound (scalar or vector)
verbose = True # Print progress
Execute RUN algorithm
Best_Cost, Best_X, Convergence_curve = RUN(nP, MaxIt, lb, ub, dim, sphere_function, constraint_handling="RI", verbose=verbose)
print(f'Best Cost: {Best_Cost}')
print(f'Best Position: {Best_X}')
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
Hashes for IM_RUN_optimizer-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a97d11d7b95075155412b8a2891df389051fabf5d8f97cb6cbc65f113d40e23 |
|
MD5 | f86059233ea9409bf5ebecbd53a7c0ed |
|
BLAKE2b-256 | bf5fe040bfec85236ccf6752689c4bb8e822ad834bedbfdd8f079b6509ee120c |