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.
Show older comments
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)

Accepted Answer
More Answers (0)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!