Hi, I am trying to get matlab to use the randomly generated values( parameters) to create a 7 parents with each 6 Capacitor Voltage values corresponding to its amount at the time, and a 7th for a cost function. This is to repeat it 100 times, for the first generation of a 6 by 100 population (In less confusing terms we program matlab randomly chose some parameters to use until it produces something closs to satisfying the desired values)
Using the Ga Solver, repeat the creation of new children( which are the parameters I think) in the population until the cost function gets down to 0.001 or a very small value which indicates that its getting close to the desired values.
According to my proffesor, once the cost function gets close to zero is when the Genetic algorithm should stop which indicates the correct selection of parameters have been met.
He has not shown or shared any examples of how ga solvers would work, also, there is no assigned reading for this application so as a class we are completely lost. The only part that is randomly generated is the parameters. My code is a mess. Im not sure what to do to get it to work. The only part that plots is the desired values that need to be met at the specific charge and discharge times. Attached is my proffesor's psuedo code, but with noing available in our book, this was as far as I could get. I believe he did his dissertation on it so its mostlikely far beyond the scope of this undergrad computations class. Any help is greatly appreciated. The code he gave us for the charging and discharging also seems to be purposefully broken.
%% the 6 Desired values the optimization needs to reach
ylabel('voltage of capacitor')
%% The code below is supposed to Generate the 7 new random resistor capacitor, supply voltage and time constant values to compute to get the outputs of A(1),Vc(0),Vc(2),Vc(4),Vc(6),Vc(8),Vc(10) for each generation to populate an entire 7 by 100 array. This should then be used in a ga solver, and be randomized until A is very small
R = 20000 + (50000-20000)*rand(1);
C= 0.0001 +(0.001-0.0001)*rand(1);
Vs= 5 +(20-5)*rand(1);
%% 4 Euler's Charging and Discharging
%% EULER SOLUTION
limit = round(tc/dt);
A(i)= (Vc@(t=2)-3.27)^2 + (Vc(@t=4)-5.79)^2 + (Vc(@t=6)-7.70)^2 + (Vc(@t=8)-6.64)^2 + (Vc(@t=10)-5.09)^2;