| 查看: 338 | 回复: 1 | ||
[求助]
函数调用
|
|
这是我的目标函数,里面有随机生成数: function opforpaper=lq_paper(x) syms theta; mu_ra=0.0645; mu_rb=0.0889; mu_rc=0.043; sigma_ra=0.008; sigma_rb=0.07; sigma_rc=0.004; for i=1:100 f_1(i)=cos(theta)*(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*cos(unifrnd(0,2*pi)))+sqrt((x(2)+x(4)*normrnd(0,1)+normrnd(mu_rc,sigma_rc)*cos(unifrnd(0,2*pi))).^2-(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*sin(theta)).^2); f_2(i)=cos(theta+0.0063)*(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*cos(unifrnd(0,2*pi)))+sqrt((x(2)+x(4)*normrnd(0,1)+normrnd(mu_rc,sigma_rc)*cos(unifrnd(0,2*pi))).^2-(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*sin(theta+0.0063)).^2); f3(i)=abs(f_1(i)-f_2(i)); end opforpaper=mean(f3); 下面的是约束, function [c,ceq]=consfun(x) M=384; c=[(M*sqrt(M^2+f3^2)-M)/(2*sqrt(M^2+f3^2))-0.05;f3*M/(2*sqrt(M^2+f3^2))-0.5]; ceq=[]; 下面的是所用的计算函数: clear x0=[50,335,0.005,0.05]; lb=[45,330,0.002,0.007]; ub=[55,340,0.02,0.07]; options=optimset('largescale','off','Algorithm','active-set'); [x,fval]=fmincon('lq_paper',x0,[],[],[],[],lb,ub,'consfun',options) 现在有个问题:在约束中的f3必须是目标函数中生成的那个f3,因为目标函数中的f3含有随机数,请问哪位大神能帮我下,在约束中调用目标函数中的那个f3! |
» 猜你喜欢
浙大物院表面物理课题组长期招收普博及直博学生
已经有259人回复
【征稿】Springer Nature热电专题 Discover Materials / Discover Chemistry
已经有47人回复
物理学I论文润色/翻译怎么收费?
已经有192人回复
25届硕士申请,材料计算方向
已经有2人回复
课题组招1-2名硕士
已经有1人回复
机时越来越贵之后,我把一部分 DFT 流程搬到了 AI 计算平台上
已经有0人回复
斯坦福大学与Elsevier世界前2%学者新排名查询
已经有1人回复
27申博推荐:南京航空航天大学国际前沿院光学方向招收博士生!
已经有19人回复
华南师范大学+双一流学科物理学+广东省杰青团队2027年博士招生+机器学习驱动材料设计
已经有1人回复
apl投稿状态
已经有2人回复
华南师范大学+双一流学科物理学+广东省杰青团队2027年博士招生+机器学习驱动材料设计
已经有0人回复

2楼2012-11-20 12:01:26










回复此楼