Finding the global minimum of a function using SciPy's differential_evolution function

share link

by kanika dot icon Updated: Mar 29, 2023

technology logo
technology logo

Solution Kit 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.

  1. Install Jupyter Notebook on your computer.
  2. Open terminal and install the required libraries with following commands.
  3. Install SciPy - pip install scipy.
  4. Copy the code using the "Copy" button above, and paste it into your IDE's Python file.
  5. 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


scipyby scipy

Python doticonstar image 11340 doticonVersion:v1.11.0rc1doticon
License: Permissive (BSD-3-Clause)

SciPy library main repository

Support
    Quality
      Security
        License
          Reuse

            scipyby scipy

            Python doticon star image 11340 doticonVersion:v1.11.0rc1doticon License: Permissive (BSD-3-Clause)

            SciPy library main repository
            Support
              Quality
                Security
                  License
                    Reuse

                      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.

                      1. The solution is created in Python 3.9.6
                      2. 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

                      1. For any support on kandi solution kits, please use the chat
                      2. For further learning resources, visit the Open Weaver Community learning page.


                      See similar Kits and Libraries