how can I set the options for Genetic Algorithm and SQP optimization? objective function and constraints are defined but I can not get the result.
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
function f=objfun(x)
Rd = x(1); Rb = x(2); bd = x(3);
dR=(Rd-Rb)
Td=4/3*pi*40000*dR^3+pi*3.8*45/0.001*dR^4+2*pi*Rd^2*bd*[15+0.1*(45*Rd/0.001)]
f=-Td
function [c ceq]=constraint(x)
Rd = x(1); Rb = x(2); bd = x(3);
dR=(Rd-Rb)
Td=4/3*pi*40000*dR^3+pi*3.8*45/0.001*dR^4+2*pi*Rd^2*bd*[15+0.1*(45*Rd/0.001)]
Td0=4/3*pi*15*dR^3+pi*0.1*45/0.001*dR^4+2*pi*Rd^2*bd*[15+0.1*(45*Rd/0.001)]
muJ=Rd^4*bd/[(0.069)^4*0.022-(0.065)^4*(bd+0.002)]
f=-Td
g1=1-Td/(50*Td0)
g2=1-muJ/0.25
g3=muJ/0.5-1
g4=Rb/Rd-1
c(1)=g1
c(2)=g2
c(3)=g3
c(4)=g4
ceq=[]
clc
clear all
%GA optimization
% seting lower bounds and upper bouds
LB = [0.030;0.010;0.003];
UB = [0.068;0.020;0.012];
% starting point
% x0 = [0.050;0.0010;0.010];
options = gaoptimset('MutationFcn',@mutationadaptfeasible);
[x,fval,exitflag,output] = ga(@objfun,3,[],[],[],[],LB,UB,@constraint,options);
%SQP optimization
clc
clear all
close all
LB = [0.030;0.010;0.003];
UB = [0.068;0.020;0.012];
x0 = [0.060;0.012;0.010];
options = optimoptions('fmincon','display','iter','Algorithm','sqp','PlotFcn','optimplotfval');
%options = struct('MaxFunctionEvaluations',100000);
[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(@objfun,x0,[],[],[],[],LB,UB,@constraint,options)
0 Commenti
Risposta accettata
Walter Roberson
il 12 Dic 2022
It works for me.
Do not expect these kinds of optimizers to output a message that says something like "Optimization terminated, global minima found!". Some of the linear and quadratic problem solvers can prove that they have found a global minima, but none of the optimizers that accept a function handle can prove that they have found a global minima.
When you have an arbitrary function that is not known to be linear or polynomial , the only way to be sure that you have found a global minima is if you do a mathematical analysis of the function. Otherwise how could you be sure that there is no hidden statement along the lines of if x == sqrt(352395.231135); y = -324932523532; end ?
Therefore the best that the optimizers can do is say that they have found as good of a local minima as your configuration asks them to look at.
%GA optimization
% seting lower bounds and upper bouds
LB = [0.030;0.010;0.003];
UB = [0.068;0.020;0.012];
% starting point
% x0 = [0.050;0.0010;0.010];
options = gaoptimset('MutationFcn',@mutationadaptfeasible);
[x,fval,exitflag,output] = ga(@objfun,3,[],[],[],[],LB,UB,@constraint,options)
%SQP optimization
LB = [0.030;0.010;0.003];
UB = [0.068;0.020;0.012];
x0 = [0.060;0.012;0.010];
options = optimoptions('fmincon','display','iter','Algorithm','sqp','PlotFcn','optimplotfval');
%options = struct('MaxFunctionEvaluations',100000);
[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(@objfun,x0,[],[],[],[],LB,UB,@constraint,options)
function f=objfun(x)
Rd = x(1); Rb = x(2); bd = x(3);
dR=(Rd-Rb);
Td=4/3*pi*40000*dR^3+pi*3.8*45/0.001*dR^4+2*pi*Rd^2*bd*[15+0.1*(45*Rd/0.001)];
f=-Td;
end
function [c ceq]=constraint(x)
Rd = x(1); Rb = x(2); bd = x(3);
dR=(Rd-Rb);
Td=4/3*pi*40000*dR^3+pi*3.8*45/0.001*dR^4+2*pi*Rd^2*bd*[15+0.1*(45*Rd/0.001)];
Td0=4/3*pi*15*dR^3+pi*0.1*45/0.001*dR^4+2*pi*Rd^2*bd*[15+0.1*(45*Rd/0.001)];
muJ=Rd^4*bd/[(0.069)^4*0.022-(0.065)^4*(bd+0.002)];
f=-Td;
g1=1-Td/(50*Td0);
g2=1-muJ/0.25;
g3=muJ/0.5-1;
g4=Rb/Rd-1;
c(1)=g1;
c(2)=g2;
c(3)=g3;
c(4)=g4;
ceq=[];
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!