Skip to content

Random search (RS) is a family of numerical optimization methods that do not require the gradient of the problem to be optimized, and RS can hence be used on functions that are not continuous or differentiable. Such optimization methods are also known as direct-search, derivative-free, or black-box methods.

Notifications You must be signed in to change notification settings

Ibrahim-AbuShara/Random-Search-for-Optimization

Repository files navigation

Random-Search-for-Optimization

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

Pre-Installed Packages

The following packages need to be pre-installed before running the code:

  1. gifsicle: To create animated GIFs of the optimization process.
  2. sudo apt install gifsicle

  3. imagemagick: To create an image of the optimization process.
  4. sudo apt install imagemagick

How to Use

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

Examples

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

The output:

My Animation

About

Random search (RS) is a family of numerical optimization methods that do not require the gradient of the problem to be optimized, and RS can hence be used on functions that are not continuous or differentiable. Such optimization methods are also known as direct-search, derivative-free, or black-box methods.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published