Info
此问题已关闭。 请重新打开它进行编辑或回答。
Have a problem with my objective function for using genetic algorithm toolbox
1 次查看(过去 30 天)
显示 更早的评论
I have my objective function and would like to use ga toolbox to find minimum solution.
function Fr = objmin(X)
m = X(1,1); % Range <3-12>
alpha = X(1,2); % Range <0.1-1>
R0 = X(1,3); % Range <0.013-0.015>
R1 = X(1,4); % Range <0.020-0.050>
ita=0.01;
frad = 220; %loading
rpm = 20000;
% find h0
heps = 0.0001;
errF = 1e-4;
err = 1;
h0 = 0.00002;
while any(err > errF)
k = (2*pi*(R0+R1)/(2*m))*tan(alpha*pi/180)/h0;
fu = -(6*ita*(rpm*2*pi*(R0+R1)/(2*60))*(R1-R0)*(2*pi*(R0+R1)/(2*m))^2)*(-log(k+1)+(2*k)/(k+2))/((k^2)*(h0^2));
f = fu-frad;
h0 = h0+heps;
kk = (2*pi*(R0+R1)/(2*m))*tan(0.3*pi/180)/h0;
fu = -(6*ita*(rpm*2*pi*(R0+R1)/(2*60))*(R1-R0)*(2*pi*(R0+R1)/(2*m))^2)*(-log(kk+1)+(2*kk)/(kk+2))/((kk^2)*(h0^2));
f1 = fu-frad;
h0 = h0-heps;
jacobian = (f1-f)/heps;
h0 = h0 - 0.2*f/jacobian;
err = abs(f/frad);
end
h0_opt = h0;
k_opt = k;
Fr = (R1-R0)*(rpm*2*pi*(R0+R1)/(2*60))*ita*(2*pi*(R0+R1)/(2*m))*((6/(k_opt+2))+(4*log(k_opt+1)/k_opt))/h0_opt;
But i am not sure since during the code running i let it to also find the value of h0 in while loop so may be this is a problem that it takes too long to find the optimal solution with ga toolbox. Is it possible to do the while loop during finding the optimal in ga toolbox??
2 个评论
Geoff Hayes
2019-3-2
Paranee - while it is probably possible to include the while loop it may, as you rightly say, be a problem as it will introduce a delay and so cause the GA to take longer to find an optimal solution. You could allow the while loop to iterate for a maximum number of iterations so that you have a little more control over how long the objective function will take to produce a solution. Or maybe remove the while loop altogether...?
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!