PE

docx

School

Multimedia University of Kenya *

*We aren’t endorsed by this school

Course

MANAGERIAL

Subject

Electrical Engineering

Date

Nov 24, 2024

Type

docx

Pages

7

Uploaded by mongaresams

Report
Q1: Potential Energy dynamic problem The Nelder-Mead simplex method successfully minimized the potential energy function P ( x 1 , x 2 ) = 5.2 x 1 2 + 1.8 x 2 2 2 x 1 x 2 x 1 2 x 2 . After 36 iterations, the algorithm converged to an optimal solution: x 1 = 0.2273, x 2 = 0.6818, f ( x 1 ,x 2 ) =− 0.7955 The convergence criterion, measuring the distance between the highest point x H and the centroid x CE , fell below the specified tolerance (0.3), signifying successful convergence. The iterative progression of the simplex is summarized in a table, showcasing the dynamic changes in x 1 , x 2 , and f ( x 1 ,x 2 ) across different steps. The figure visualizes how the simplex evolved, with the red ' x ' pinpointing the final optimal point. This graphical representation illustrates the method's ability to navigate the parameter space efficiently, ultimately identifying the minimum potential energy. The optimization process demonstrates the efficacy of the Nelder-Mead simplex method in efficiently finding the optimal solution for the given potential energy function. # Define the convergence criterion def convergence_criterion ( vertices ): x_L , x_M , x_H = vertices x_CE = ( x_L + x_M + x_H ) / 3 return np .sqrt( np .sum(( x - x_CE ) ** 2 for x in vertices )) / 3 # Set initial values
x0 = np .array([ 2.0 , 2.0 ]) c = 2 # Initialize variables for recording iteration details iterations = [] results = [] # Define the objective function for the optimization def objective_function ( x ): result = potential_energy ( x ) iterations . append ( np .concatenate(( x , [ result ]))) results . append ( result ) return result # Perform the Nelder-Mead optimization res = minimize( objective_function , x0 , method = 'nelder-mead' , options = { 'initial_simplex' : np .array([ [ x0 [ 0 ] + c , x0 [ 1 ]], [ x0 [ 0 ], x0 [ 1 ] + c ], [ x0 [ 0 ], x0 [ 1 ]]]), 'maxiter' : 1000 , 'fatol' : tol , 'disp' : True }) # Display the optimization results print ( "Optimal Solution:" ) print ( f "x1 = { res .x[ 0 ] :.4f} , x2 = { res .x[ 1 ] :.4f} , f(x1, x2) = { res .fun :.4f} " ) # Display the iteration details #print("\nIterations:") #print("Iter x1 x2 f(x1, x2)") #for i, iteration in enumerate(iterations): # print(f"{i+1:<5} {iteration[0]:.4f} {iteration[1]:.4f} {iteration[2]:.4f}") # Plot the iterations iterations = np .array( iterations ) plt . figure ( figsize = ( 8 , 6 )) plt . scatter ( iterations [:, 0 ], iterations [:, 1 ], c = 'red' , marker = 'x' , label = 'Iterations' )
plt . plot ( iterations [:, 0 ], iterations [:, 1 ], linestyle = '-' , color = 'blue' , label = 'Simplex Path' ) plt . scatter ( res .x[ 0 ], res .x[ 1 ], c = 'green' , marker = 'o' , label = 'Optimal Solution' ) plt . xlabel ( 'x1' ) plt . ylabel ( 'x2' ) plt . title ( 'Nelder-Mead Simplex Method Iterations' ) plt . legend () plt . grid ( True ) plt . show () Optimization terminated successfully. Current function value: -0.795455 Iterations: 36 Function evaluations: 72 Optimal Solution: x 1 = 0.2273, x 2 = 0.6818, f ( x 1, x 2 )=− 0.7955 Iterations: 14.0000
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
The graph illustrates the convergence of the Nelder-Mead simplex method during the optimization process for the given potential energy function. Each blue marker represents the simplex at a particular iteration, and the red marker denotes the final optimized point. The method progresses towards the optimal solution by adjusting the simplex configuration iteratively, demonstrating the algorithm's ability to navigate the parameter space efficiently. The convergence is evident as the simplex evolves towards the optimal values of ¿ 1 x ¿ ¿ and ¿ 2 x ¿ ¿ . The termination point aligns with the minimum potential energy, achieving a value of -0.7955. This visual representation enhances our understanding of the optimization process, showcasing how the algorithm refines its search space. The convergence is in line with the specified tolerance, highlighting the effectiveness of the Nelder-Mead simplex method in minimizing the potential energy function. Q3: (a) Karush-Kuhn-Tucker (KKT) Method: The KKT conditions for a constrained optimization problem involve the Lagrangian, complementary slackness, and gradient of the Lagrangian. The Lagrangian is as follows: L ( x 1 , x 2 , λ ) ¿ f 1 ( x 1 , x 2 ) + λ ( 2 ( x 2 x 1 ) ) + μ 1 x 1 + μ 2 ( x 2 x 1 2 ) x 2 x 1 ¿ ¿ ¿ ¿ x 1 2 + x 2 2 2 x 1 + 6 + λ ( 2 ( x 2 x 1 ) ) + μ 1 x 1 + μ 2 ¿ ¿ ¿
Let's denote g 1 ( x )= x 2 x 1 and g 2 ( x )= x 1 x 2 + 2 . The problem has two constraints. 1. Stationarity: ∂ L ∂x 1 = 2 x 1 2 λ + μ 1 μ 2 = 0 ∂L ∂ x 2 = 2 x 2 2 λ μ 2 = 0 1. Primal feasibility: g 1 ( x )= x 2 x 1 2 g 2 ( x )= x 1 x 2 + 2 0 1. Dual feasibility: λ≥ 0, μ 1 0, μ 2 0 1. Complementary słackness: λ g 1 ( x )= 0, μ 1 x 1 = 0, μ 2 g 2 ( x )= 0 (b) Solve Each Individual Optimization Problem Graphically: (0) For f 1 ( x 1 , x 2 ) = x 1 2 + x 2 2 2 x 1 + 6 subject to 0 ≤x 2 x 1 2 (ii) For
f 2 ( x 1 , x 2 ) = x 1 2 + x 2 2 4 x 1 10 x 2 + 32 subject to 0 ≤x 2 x 1 2 (c) Plot the Pareto Front, Showing the Utopia Point: Part C: Plot # Define the objective functions def f1 ( x1 , x2 ): return x1 ** 2 + x2 ** 2 - 2 * x1 + 6 def f2 ( x1 , x2 ): return x1 ** 2 + x2 ** 2 - 4 * x1 - 10 * x2 + 32 # Define the constraint functions def g1 ( x1 , x2 ): return x2 - x1 def g2 ( x1 , x2 ): return x1 - x2 + 2 # Generate points for plotting x1 = np .linspace( 0 , 5 , 100 ) x2_1 = x1 x2_2 = x1 + 2 # Plot the Pareto front plt . figure ( figsize = ( 8 , 6 )) plt . plot ( f1 ( x1 , x2_1 ), f2 ( x1 , x2_1 ), label = r '$0 \l eq x_2 - x_1 \l eq 2$' , color = 'blue' ) plt . plot ( f1 ( x1 , x2_2 ), f2 ( x1 , x2_2 ), linestyle = '--' , color = 'blue' ) # Highlight the utopia point (solution to KKT conditions) utopia_x1 = 1 utopia_x2 = 3 plt . scatter ( f1 ( utopia_x1 , utopia_x2 ), f2 ( utopia_x1 , utopia_x2 ), color = 'red' , marker = 'x' , label = 'Utopia Point' ) # Label axes and add legend plt . xlabel ( '$f_1(x_1, x_2)$' ) plt . ylabel ( '$f_2(x_1, x_2)$' ) plt . title ( 'Pareto Front with Utopia Point' ) plt . legend ()
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
# Show plot plt . grid ( True ) plt . show ()