Posts

Showing posts with the label nonlinear-optimization

Trying to solve the maximization function

Image
Trying to solve the maximization function I have a maximization problem I would like to solve: In order to do so I am looking forward to use the minimize function from the scipy library. minimize scipy Before I go into what I tried, I will define each of the variables: mu=[[-0.241035], [ 0.03557551], [-0.00410642], [-0.43985304], [-0.24741543]] landa= 42.74650697 # is a scalar E =[[0.000167,0.000032,0.000082,0.000055,0.000055], [0.000032,0.000131,0.000019,0.000043,0.000032], [0.000082,0.000019,0.000273,0.000110,0.000086], [0.000055,0.000043,0.000110,0.000229,0.000131], [0.000055,0.000032,0.000086,0.000131,0.000165]] In funct0 I set the Maximization function that appears in the image attached and define weights matrix. funct0 def funct0(x): x0,x1,x2,x3,x4=x weights= np.array([x0,x1,x2,x3,x4]) return -1*(np.matmul(weights.T , mu) - np.matmul(np.matmul (landa*weights.T, E ),weights) /2) In funct1 I set the bounds and the constraint because I want the var...