Optimization using genetic algorithm for 3 variable.

I want to minimize the RMSE i.e., Function final upto tolarence of 0.002 which is depends on three variable
E = [E1 E2 E3] with range of
ub = [1200 3000 200]
lb =[600 20 120]
I am pretty new to MATLAB and read all the documentation related to GA but that still didn't help me to go further and optimize the required problem
If you can help me out.
I am attaching my code and every necessary stuff.
Just tell me how to solve it.
===========================================================================================================
Main code
%define variable
D = [0,0];
%real deflection Value
A= [0.2316,0.1496,0.0978,0.0602,0.042,0.0244,0.0218];
%plate thickness
a = 150;
% declaring elastic modulus
lb = [1200 200 20];
ub = [3000 600 120];
% declaring thickness of layer of pavement
H = [200,550];
% declaring poisson ratio
V = [0.5,0.4,0.4];
% declaring equivalent thickness
t1 = eq1(H , E , V);
t2 = eq2(H, E, t1);
T = [t1,t2];
% finding defelction
RMSE = obj_fit(E,H,V,a,A,D);
=========================================================================================================================
Fitness function
function y = obj_fit(E,H,V,a,A,D)
t1 = H(1)*nthroot((E(1)*(1-V(2).^2))/(E(2)*(1-V(1).^2)) ,3);
t2 = 0.8*(t1+H(2))*nthroot(E(2)/E(3),3);
T = [t1,t2];
for i = 1:7
if i==1
d1 = 0.566*(1+V(1))*a*(1-(power(1+power(H(1)/a,2),-0.5)+(1-2*V(1))*(power(1+power(H(1)/a,2),0.5)-H(1)/a)))/E(1);
d2 =((0.566*(1+V(2))*a*(power(1+power(T(1)/a,2),-0.5)+(1-2*V(2))*(power(1+power(T(1)/a,2),0.5)-T(1)/a)))...
-(0.566*a*(1+V(2))*(power(1+power((T(1)+H(2))/a,2),-0.5)+(1-2*V(2))*(power(1+power((T(1)+H(2))/a,2),0.5)...
-(T(1)+H(2))/a))))/E(2);
d3 = 0.566*(1+V(3))*a*(((power(1+power(T(2)/a,2),-0.5)+(1-2*V(1))*(power(1+power(T(2)/a,2),0.5)-T(2)/a))))/E(3);
D(i)= d1+d2+d3;
else
r= 300*(i-1);
d1 = 0.283*power(a,2)*(((1+V(1))*(H(1).^2)*(power((r.^2)+(H(1).^2),-1.5))+2*(1-(V(1).^2))...
*(power((r.^2)+(H(1).^2),-0.5))))/E(1);
d2 = ((0.283*power(a,2)*((1+V(2))*(T(1).^2)*(power((r.^2)+(T(1).^2),-1.5))+2*(1-(V(2).^2))...
*(power((r.^2)+(T(1).^2),-0.5))))-(0.283*power(a,2)*((1+V(2))*((T(1)+H(2)).^2)*...
(power((r.^2)+((T(1)+H(2)).^2),-1.5))+2*(1-(V(2).^2))*(power((r.^2)+((T(1)+H(2)).^2),-0.5)))))/E(2);
d3 = 0.283*power(a,2)*((1+V(3))*(T(2).^2)*(power((r.^2)+(T(2).^2),-1.5))+2*(1-(V(3).^2))*(power((r.^2)+(T(2).^2),-0.5)))/E(3);
D(i) = d1+d2+d3;
end
end
r=0;
for i=1:7
r = r+(A(i)-D(i)).^2;
end
r= r/7;
y = sqrt(r);
end
===========================================================================================
With your help I just made a obj function.
If it is correct then how to create a random population.
Just help me out to solve this problem.

6 件のコメント

Geoff Hayes
Geoff Hayes 2020 年 5 月 14 日
Aditya - in the above code, what corresponds to the three variables E1, E2, and E3? If they were defined, how would they be used in the code? Presumably they correspond to something in the main code...
ADITYA ANUPAM
ADITYA ANUPAM 2020 年 5 月 15 日
編集済み: ADITYA ANUPAM 2020 年 5 月 15 日
Sir,
I had created a obj function just once see and further help me to create a initial population so that I could progress further more.
Walter Roberson
Walter Roberson 2020 年 5 月 15 日
if you are optimizing with respect to E then create lb and ub with appropriate content
ADITYA ANUPAM
ADITYA ANUPAM 2020 年 5 月 15 日
Sir,
I know about ub and lb.
but before getting there i am still struggling to have a population, crossover and mutation function for my code
please help me out.
Walter Roberson
Walter Roberson 2020 年 5 月 15 日
Leave the population, cross-over, and mutation functions as the default to start out.
Remove
E = [1200:3000;200:600;20:120];
and define
lb = [1200 200 20];
ub = [3000 600 120];
ADITYA ANUPAM
ADITYA ANUPAM 2020 年 5 月 15 日
Sir,
is it correct now for obj function?

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2020 年 5 月 15 日

1 投票

%define variable
D = [0,0];
%real deflection Value
A= [0.2316,0.1496,0.0978,0.0602,0.042,0.0244,0.0218];
%plate thickness
a = 150;
% declaring elastic modulus
nvars = 3;
lb = [1200 200 20];
ub = [3000 600 120];
% declaring thickness of layer of pavement
H = [200,550];
% declaring poisson ratio
V = [0.5,0.4,0.4];
% finding defelction
Alin = []; blin = [];
Aeq = []; beq = [];
nlcon = [];
options = optimoptions('ga','PlotFcn',...
{@gaplotbestf,@gaplotbestindiv,@gaplotexpectation,@gaplotstopping});
fun = @(E) obj_fit(E,H,V,a,A,D);
[bestE, RMSE, exitflag] = ga(fun, nvars, Alin, blin, Aeq, beq, lb, ub, nlcon, options);
My tests show that the optimal occurs when E(2) and E(3) are both at their upper bounds, and E(1) is approximately 2212.675232597514 (the curve is similar to a quadratic in shape at that point, so the location can be found quite precisely.)

3 件のコメント

ADITYA ANUPAM
ADITYA ANUPAM 2020 年 5 月 15 日
Thanks a lot sir.
You solved completely.
Just One think I couldn't understand
I have to make tolarence at max upto 0.002 but the required solution get terminated at 0.032.
is there anyway?
Walter Roberson
Walter Roberson 2020 年 5 月 15 日
options = optimoptions('ga', 'PlotFcn',...
{@gaplotbestf,@gaplotbestindiv,@gaplotexpectation,@gaplotstopping}, ...
'FunctionTolerance', 1e-15, ...
'MaxGenerations', 2000);
ADITYA ANUPAM
ADITYA ANUPAM 2020 年 5 月 15 日
Thanks Sir.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by