I am trying to solve a LQR problem using Genetic Algorithm.
The values of the LQR matrices are not importent to me, I am just trying to understand the way that it is work.
First I solve the system using the Matlab's LQR algorithm and them I try to solve using the Genetic Algorithm and compare the results.
In the code attach I am trying to compare between P to P2, but I dont get a match.
Also when I run the code, I get the following Error: Optimization terminated: average change in the fitness value less than options
P = ga(@cost_fun,2);
Optimization terminated: maximum number of generations exceeded.
function P = cost_fun(K1)