Random search (RS) is a family of numerical optimization methods that do not require the gradient of the problem to be optimized. This repository contains the implementation in Python of various optimization algorithms:
- Linear Regression with Simulated Annealing
- Particle Swarm Optimization for Linear Regression
- TSP using Genetic Algorithm
- TSP using Nearest Neighbor Algorithm
- TSP using Simulated Annealing Algorithm
The following packages need to be pre-installed before running the code:
- gifsicle: To create animated GIFs of the optimization process.
- imagemagick: To create an image of the optimization process.
sudo apt install gifsicle
sudo apt install imagemagick
Clone the repository
git clone https://github.com/<username>/Random-Search-for-Optimization.git
Navigate to the directory
cd Random-Search-for-Optimization
Install the required packages
pip install -r requirements.txt
Run the Python scripts
python linear_regression_simulated_annealing.py
python linear_regression_particle_swarm_optimization.py
python tsp_genetic_algorithm.py
python tsp_nearest_neighbor_algorithm.py
python tsp_simulated_annealing_algorithm.py
Here's an example of running the TSP using Simulated Annealing Algorithm:
Navigate to the directory
cd Random-Search-for-Optimization
Run the Python script
python tsp_simulated_annealing_algorithm.py