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.gitNavigate to the directory
cd Random-Search-for-OptimizationInstall the required packages
pip install -r requirements.txtRun the Python scripts
python linear_regression_simulated_annealing.pypython linear_regression_particle_swarm_optimization.pypython tsp_genetic_algorithm.pypython tsp_nearest_neighbor_algorithm.pypython tsp_simulated_annealing_algorithm.pyHere's an example of running the TSP using Simulated Annealing Algorithm:
Navigate to the directory
cd Random-Search-for-OptimizationRun the Python script
python tsp_simulated_annealing_algorithm.py