You may apply these codes to your own objective functions or project, e.g., https://au.mathworks.com/matlabcentral/fileexchange/51250-truss-optimization-with-matlab-genetic-algorithm-ga-function
Also https://tel.archives-ouvertes.fr/tel-03030125/document
I think you may begin with this code https://github.com/Mechazo11/Genetic_Algorithm_2D_Rosenbrock
I wrote it as part of a graduate level project. If your analysis is a two variable problem, my code will work out of the box. All you would need to do is change the objective function. If I recall my mechanics correctly, cantilever beam can be analyzed from 2D.