matlab解有约束的非线性优化
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/17 20:55:46
matlab解有约束的非线性优化
我用matlab优化工具箱或者遗传算法工具箱都试过,没有成功.
水平有限,
我给出一组初值
x(1)=2e-3
x(2)=0.5e-3
x(3)=6e-3
问题描述如下:
%%%%%%%%%%%%%%参数取值%%%%%%%
d1=24e-3
D=84e-3
d=17e-3
z=7
rmax=0.1744
n=1460
ps=1e+7
R=28e-3
fth=1.1
fmth=0.95
W1=500
W2=500
W3=1
brmin=2
Kb=1.2
p0=30e+6
vr0=7
v00=2.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%中间变量%%%%%%%%%%%%%%%%%%%%%%%%%%
r3=x(3)-Kb*x(2)
r2=2*x(1)-r3
r1=r2-x(2)
Fp=0.125*(z+1)*pi*d.^2*ps
M0=0.125*pi*d.^2*R*ps/sin(pi/(2*z))
a0=(R/x(1))*asin(d/(2*R))
faif=(z-1)*pi/z+a0
Fb=0.25*faif*((x(3).^2-r3.^2)/log10(x(3)/r3)-(r2.^2-r1.^2)/log10(r2/r1))*ps
Mb=2*((x(3).^2-r3.^2)/log10(x(3)/r3)-(r2.^2-r1.^2)/log10(r2/r1))*ps/9
Ae=pi*(x(3).^2-r1.^2)-(pi-a0)*(r3.^2-r2.^2)
rd=(r3-r2)/2
Sd=0.5*(r3.^2-r2.^2)*(2*asin(0.5*d/R)-4*asin(0.5*rd/x(1)))+pi*rd.^2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%目标函数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fval=W1*abs(Fp/Fb-fth)+W2*(M0/Mb-fmth)+W3*((pi*(x(3).^2-r1.^2)-(pi-a0)*(r3.^2-r2.^2))/(0.25*pi*D.^2))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%约束%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
g1=M0/Mb-1
g2=(Fp-Fb)/Ae-p0
g3=(pi*n/30)*x(1)-vr0
g4=0.25*pi*d.^2*(pi*n/30)*R*tan(rmax)/Sd-v00
g5=x(3)-0.5*D
g6=0.5*d1-r1
g7=brmin-x(2)
g8=rd-2*x(1)
g9=-rd
我用matlab优化工具箱或者遗传算法工具箱都试过,没有成功.
水平有限,
我给出一组初值
x(1)=2e-3
x(2)=0.5e-3
x(3)=6e-3
问题描述如下:
%%%%%%%%%%%%%%参数取值%%%%%%%
d1=24e-3
D=84e-3
d=17e-3
z=7
rmax=0.1744
n=1460
ps=1e+7
R=28e-3
fth=1.1
fmth=0.95
W1=500
W2=500
W3=1
brmin=2
Kb=1.2
p0=30e+6
vr0=7
v00=2.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%中间变量%%%%%%%%%%%%%%%%%%%%%%%%%%
r3=x(3)-Kb*x(2)
r2=2*x(1)-r3
r1=r2-x(2)
Fp=0.125*(z+1)*pi*d.^2*ps
M0=0.125*pi*d.^2*R*ps/sin(pi/(2*z))
a0=(R/x(1))*asin(d/(2*R))
faif=(z-1)*pi/z+a0
Fb=0.25*faif*((x(3).^2-r3.^2)/log10(x(3)/r3)-(r2.^2-r1.^2)/log10(r2/r1))*ps
Mb=2*((x(3).^2-r3.^2)/log10(x(3)/r3)-(r2.^2-r1.^2)/log10(r2/r1))*ps/9
Ae=pi*(x(3).^2-r1.^2)-(pi-a0)*(r3.^2-r2.^2)
rd=(r3-r2)/2
Sd=0.5*(r3.^2-r2.^2)*(2*asin(0.5*d/R)-4*asin(0.5*rd/x(1)))+pi*rd.^2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%目标函数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fval=W1*abs(Fp/Fb-fth)+W2*(M0/Mb-fmth)+W3*((pi*(x(3).^2-r1.^2)-(pi-a0)*(r3.^2-r2.^2))/(0.25*pi*D.^2))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%约束%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
g1=M0/Mb-1
g2=(Fp-Fb)/Ae-p0
g3=(pi*n/30)*x(1)-vr0
g4=0.25*pi*d.^2*(pi*n/30)*R*tan(rmax)/Sd-v00
g5=x(3)-0.5*D
g6=0.5*d1-r1
g7=brmin-x(2)
g8=rd-2*x(1)
g9=-rd
太麻烦了,给你个例子,仔细琢磨吧.
function hh
a1 = 2; a2 = 1.5; % define parameters first
options = optimset('LargeScale','off'); % run medium-scale algorithm
[x,fval] = fmincon(@(x)myfun(x,a1),[2e-3 ;0.5e-3;6e-3 ],[],[],[],[],[],[],@(x)mycon(x,a2),options)
function f = myfun(x,a1)
f = x(1)^2 + a1*x(2)^2;
function [c,ceq] = mycon(x,a2)
c = a2/x(1) - x(2);
ceq = [];
结果:
x =
1.4565
1.0299
fval =
4.2426
function hh
a1 = 2; a2 = 1.5; % define parameters first
options = optimset('LargeScale','off'); % run medium-scale algorithm
[x,fval] = fmincon(@(x)myfun(x,a1),[2e-3 ;0.5e-3;6e-3 ],[],[],[],[],[],[],@(x)mycon(x,a2),options)
function f = myfun(x,a1)
f = x(1)^2 + a1*x(2)^2;
function [c,ceq] = mycon(x,a2)
c = a2/x(1) - x(2);
ceq = [];
结果:
x =
1.4565
1.0299
fval =
4.2426
急!matlab 如何完成非线性约束优化
matlab优化约束matlab优化的约束,有等式约束,不等式约束;x+8
matlab一道有约束的非线性规划问题
如何用Matlab求有限制条件的目标函数的最小值求解一个优化问题(目标函数非线性,约束函数线性)?
matlab解带不等式约束的非线性方程组.
matlab 有约束非线性 x0是几啊?
非线性约束优化 目标函数和约束函数 在matlab中出错
matlab fmincon 非线性优化
matlab约束优化问题
用matlab求解一个优化问题(目标函数非线性,约束函数线性)
MATLAB做非线性约束优化时,怎么老显示这个啊?
MATLAB基础问题麻烦高手帮个忙,请问解有约束非线性规划问题,用MATLAB中的哪个函数?再麻烦各位把函数的调用格式也