Finding the global minimum of a function using SciPy's differential_evolution function
by kanika Updated: Mar 29, 2023
Solution Kit
Finding the global minimum of a function means locating the point where the function has the smallest possible value. This is the "lowest point" of the function, and the coordinates of this point are the global minimum of the function.
Scipy's differential_evolution function is a built-in optimization algorithm used to find the global minimum of a given function. It works by exploring the parameter space of a problem by evolving a population of potential solutions over generations. It uses mutation, crossover, and selection processes to find the best solution and is often used to solve complex problems that cannot be solved using traditional optimization methods.
Here is an example of finding the global minimum of a function using SciPy's differential_evolution function
Fig 1: Preview of the output that you will get on running this code from your IDE
Code
In this solution, we use the differential_evolution function of the SciPy library.
Instructions
Follow the steps carefully to get the output easily.
- Install Jupyter Notebook on your computer.
- Open terminal and install the required libraries with following commands.
- Install SciPy - pip install scipy.
- Copy the code using the "Copy" button above, and paste it into your IDE's Python file.
- Run the file to get the desired output.
I hope you found this useful. I have added the link to dependent libraries, and version information in the following sections.
I found this code snippet by searching for "Finding the global minimum of a function using SciPy's differential_evolution function" in kandi. You can try any such use case!
Dependent Libraries
If you do not have SciPy that is required to run this code, you can install it by clicking on the above link and copying the pip Install command from the scipy page in kandi.
You can search for any dependent library on kandi like scipy
Environment Tested
I tested this solution in the following versions. Be mindful of changes when working with other versions.
- The solution is created in Python 3.9.6
- The solution is tested on SciPy version 1.9.3
Using this solution, we are able to solve linear equations using scipy's linalg.solve function. It can also be used for finding the inverse of a matrix or calculating the determinant of a matrix.
Support
- For any support on kandi solution kits, please use the chat
- For further learning resources, visit the Open Weaver Community learning page.