1

I'm trying to minimize the following function:

enter image description here

with respect to the parameters H and alpha using the brute force method, specifically the scipy.optimize.brute algorithm. The problem arises that I don't know how to deal with this unknown number of variables, I mean, that is 2n variables and n is an input of the program.

I have the following code, where I'd like that the minimization would lead to arrays for Hand alpha values:

import numpy as np

#Entries:
gamma = 17.0    
C = 70.0        
T = 1           
R = 0.5 
n = int(2)

def F(mins, gamma,C,T,R):
    H,alpha = mins
    ret = 0
    for i in range(n):
    inner_sum = 0
    for j in range(i+1):
        inner_sum += H[j]*np.tan(alpha[j])
    ret += 3*gamma*H[i]*(R+inner_sum)**2

So I can get the values of H and alpha from the position of the array. I was used to multivariable minimization with brute force but only when I have a fixed number of variables. In this case, how can I proceed?

P.S.: I know that the minimization of the above expression will lead to 0 for both variables. This is just a small piece of a bigger expression to illustrate the problem, in which a working algorithm would be very helpful. Thanks in advance!

0 Answers0