SP4E_HW1/4a51b53fd99amaster
README.md
Minimization of a scalar function in Python
(SP4E 2018, Homework 1) Authors: Sajjad Azimi, Alessia Ferraro
- Description and usage
- optimizer.py
The program optimizer.py finds the minimum of a given scalar function making use of the scipy.optimize.minimize module. Via the command line options, the user can choose the minimization algorithm and whether the starting point is randomly generated (See the helpmode -h by running python optimizer.py -h): -CG (Conjugate Gradient) -BFGS (Broyden-Fletcher-Goldfarb-Shannon) -RI to generate a random initial condition For example: python optimizer -CG -RI Once the optimization process reaches the required tolerance a plotting routine shows both the surface and the minimization path of the chosen algorithm.
- conjugate_gradient.py
To run conjugate_gradient.py you have to run the following command in the terminal: python conjugate_gradient.py Once you run the command, the processor uses the function which implements the linear conjugate gradient method, and finds the minimum of the function S, given in the homework description. The initial condition is a fixed point at [3.0, 1.0]. After running the program, the number of steps and the final solution are printed on the screen and the 3D plot of the surface and the path of the point during the convergence are shown in a new window. The convergence of the point is exactly like the convergence of the point in exercise 1 with the optimizer (when the initial condition is not randomly generated in the optimizer.py the initial conditions in both programs are the same).