I have a Simulink model which depend on parameters like springs value and damper settings. The spring values available are the followings
Springs_F = [275, 325, 375, 425, 475];
Springs_H = [125,150,175,200,225,250,275];
Springs_R = [75,100,125,150,175];
The available damper curves (Damper force Vs speed) are loaded into the Simulink workspace and then the selection of them is done by selecting from the following (number of clicks, as racing damper can be tuned by adjusting the Bump and Rebound knobs)
ii = [0 1 2 3 4 5];
jj = [0 1 2 3 4 5];
kk = [0 1 2 3 4 5];
ll = [0 1 2 3 4 5];
mm = [0 1 2 3 4 5];
nn = [0 1 2 3 4 5];
I also generate a cost function (objetive.m) which is passed to the ga (Genetic Algorithm) optimization tool
The options of ga are set using the following code
options = gaoptimset('CrossoverFraction',0.6,'PopulationSize',100,'StallGen',100,'Generations',900,'PlotFcns', @gaplotbestindiv,'Display','iter');
The Genetic Algorithm optimization is then called with the following
[xOptimum,Cost_fVal,exitflag,output,population,scores] = ga(@(x)objective(x,ii,jj,kk,ll,mm,nn,Springs_F,Springs_H,Springs_R),9,,,,,lb,ub,,intCon,options);
where x is a variable which define the parameters that I want to vary in the model. Conceptually is something like x = [ii,jj,kk,ll,mm,nn,Springs_F,Springs_H,Springs_R]. Note also that intCon = 1:9; (as all the variables passed to the ga function are integer)
The optimization runs and the results are attached for you to have a look
My problem is the following:
The value of Cost_fVal returned by the optimization is 2.7280, and xOptimum = [1,3,3,5,5,1,2,4,4]
However, if I run the model with x = xOptimum; I got a value of the cost function of about 3.15.
I was expecting that xOptimum would have given a cost function value equal to Cost_fVal (=2.7280)
So in summary, the optimization tells me the minimum of the cost function found is 2.7280 BUT the cost function value running the model with x = xOptimum does not correspond to this, but it actually gives an higher value (3.15)
How can I find the value of x corresponding to the minimum value of the const function found (2.7280)?
Finally, with a for-loop I run all the 100 values of x returned by the optimization in "population" (see attached) but the minimum value of the cost function is higher than cost_fVal (with the minimum being 2.76).
Any idea on what I am missing here?
Thanks in advance