Minimizer in Python

import pandas as pd
import scipy.optimize as spo
import numpy as np
import matplotlib.pyplot as plt

def f(X):
    Y = (X - 1.5)**2 + 0.5
    print("X = {}, Y = {}".format(X, Y))
    return Y

def test_run():
    Xguess = 2.0
    min_result = spo.minimize(f, Xguess, method='SLSQP', options={'disp': True})
    print("Minima fount at:")
    print("X = {}, Y = {}".format(min_result.x,

    # Plot function values, mark minima
    Xplot = np.linspace(0.5, 2.5, 21)
    Yplot = f(Xplot)
    plt.plot(Xplot, Yplot)
    plt.plot(min_result.x,, 'ro')
    plt.title("Minima of an objective function")

if __name__ == "__main__":


Minimizers in python

(Visited 25 times, 1 visits today)


Eyeing investment. Please note that the views given in this website are meant for reference and guidance of the readers to explore further on the topics and take informed decisions. These should not be construed as investment advice or legal opinion.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
12 × 22 =