Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Have a problem with my objective function for using genetic algorithm toolbox

1 Ansicht (letzte 30 Tage)
Paranee Sawad
Paranee Sawad am 2 Mär. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Geoff Hayes
Geoff Hayes am 2 Mär. 2019
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...?
Paranee Sawad
Paranee Sawad am 3 Mär. 2019
Dear Geoff,
I cannot remove while loop since i need to use it to find the value of h0 which is used during computing the mininum Fr. Do you have any suggest about how to handle with h0 since i also need to use the range 4 input variables to find. It seems like find the optimal input variables to satisfy h0 and also to satisfy min Fr with both input variables and h0.

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by