matlab遗传算法实例求指导
个这样的函数y=(0.0206*x(2)^2/(2*9.81*x(1))+(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1...
个这样的函数y=(0.0206*x(2)^2/(2*9.81*x(1))+(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2))))+((0.25*(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))-1)^2+x(5)*x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))^0.5)*(x(4)/1040-1)+1.8413*(x(2)/(9.81*x(1)))^2.7736*(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2))))+((0.25*(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))-1)^2+x(5)*x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))^0.5)*0.43*x(3)/x(1)*(x(4)/1040-1))/(x(4)*x(5)/1040);
五个自变量,自变量之间没有任何的约束关系,但是自变量有范围,x(1)=[0.2,0.4],x(2)=[1.234,3],x(3)=[0.01,0.04],x(4)=[1190,1398],x(5)=[0.15,0.4],哎,试了很多天了还是不行,劳烦大神指点看怎么编程,不管用遗传算法ga或者fmincon,只要能出自变量范围内的结果就行,谢谢啦:) 展开
五个自变量,自变量之间没有任何的约束关系,但是自变量有范围,x(1)=[0.2,0.4],x(2)=[1.234,3],x(3)=[0.01,0.04],x(4)=[1190,1398],x(5)=[0.15,0.4],哎,试了很多天了还是不行,劳烦大神指点看怎么编程,不管用遗传算法ga或者fmincon,只要能出自变量范围内的结果就行,谢谢啦:) 展开
展开全部
主函数m文件代码:
lb=[0.2 1.234 0.01 1190 0.15];
ub=[0.4 3 0.04 1398 0.4];
x0=lb;
[x,fval]=fmincon('llzy',x0,[],[],[],[],lb,ub);
目标函数m文件代码:
function y=llzy(x)
y=(0.0206*x(2)^2/(2*9.81*x(1))+(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2))))+((0.25*(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))-1)^2+x(5)*x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))^0.5)*(x(4)/1040-1)+1.8413*(x(2)/(9.81*x(1)))^2.7736*(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2))))+((0.25*(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))-1)^2+x(5)*x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))^0.5)*0.43*x(3)/x(1)*(x(4)/1040-1))/(x(4)*x(5)/1040);
lb=[0.2 1.234 0.01 1190 0.15];
ub=[0.4 3 0.04 1398 0.4];
x0=lb;
[x,fval]=fmincon('llzy',x0,[],[],[],[],lb,ub);
目标函数m文件代码:
function y=llzy(x)
y=(0.0206*x(2)^2/(2*9.81*x(1))+(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2))))+((0.25*(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))-1)^2+x(5)*x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))^0.5)*(x(4)/1040-1)+1.8413*(x(2)/(9.81*x(1)))^2.7736*(0.5*(1-(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2))))+((0.25*(x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))-1)^2+x(5)*x(2)/(4*x(3)*9.81*(x(4)-1040)/(3*0.43*1040))^0.5*(1-(x(3)/x(1))^2)*exp(-(2.65*x(5)-3.32*x(5)^2.2)))^0.5)*0.43*x(3)/x(1)*(x(4)/1040-1))/(x(4)*x(5)/1040);
追问
能不能给个遗传算法的调用代码?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询