I have a function with two input variables we are looking to optimise. The function returns an output and we want to minimise this output. What is the best way to do this in Python?
Presently the functions input variables have been hardcoded, the goal would be to iterate over a range and find the optimal for both parameters.
I've looked into scipy but unsure how to utilise it in my situation.
The output of my code can be seen below.
def average_receptance(K_t, C_t):
frequency_matrix = np.array([])
alphabetaE11_matrix = np.array([])
for i in range(first_natural_frequency - natural_frequency_delta,first_natural_frequency + natural_frequency_delta):
frequency_matrix = np.append(frequency_matrix, i)
alphabetaE11_matrix = np.append(alphabetaE11_matrix, math.log(abs(receptance(K_t, C_t, i))))
receptance_average = np.average(alphabetaE11_matrix)
return receptance_average
print(average_receptance(600000, 50))
print(average_receptance(626759, 50))
print(average_receptance(650000, 50))
print(average_receptance(600000, 100))
print(average_receptance(626759, 100))
print(average_receptance(650000, 100))
print(average_receptance(600000, 150))
print(average_receptance(626759, 150))
print(average_receptance(650000, 150))