请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 341|回复: 0

带非线性约束的智能算法求解

[复制链接]

674

主题

793

帖子

4331

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4331
发表于 2019-3-4 23:51:18 | 显示全部楼层 |阅读模式
问题:
已知31个点的极坐标(rjαj)。设有5待求未知数ck(c1,c2,c3,c4,c5),根据约束条件求极小值f下的ck。理论上f越接近0越好。同时,顺带也能求出与31αj对应的31个未知数βj。根据约束条件第一个等式可找到βjck存在的关系因而转化为求以ck为自变量的函数极小值问题

附录:31个点坐标数据
极坐标形式:
rj, αj={{11.055, 0.},{11.055, 0.10472}, {11.055, 0.20944}, {11.055, 0.314159}, {11.055, 0.418879},{11.055, 0.523599}, {11.055, 0.628319}, {11.055, 0.733038}, {11.055, 0.837758},{11.055, 0.942478}, {11.055, 1.0472}, {11.055, 1.15192}, {11.055, 1.25664},{11.055, 1.36136}, {11.055, 1.46608}, {11.055, 1.5708}, {11.1159, 1.67552},{11.302, 1.78024}, {11.6239, 1.88496}, {12.1012, 1.98968}, {11.06, 2.0944},{9.4082, 2.19911}, {8.2645, 2.30383}, {7.4413, 2.40855}, {6.8355, 2.51327},{6.3855, 2.61799}, {6.0533, 2.72271}, {5.8146, 2.82743}, {5.6535, 2.93215},{5.5605, 3.03687}, {5.53, 3.14159}}
单独拿出来:
rj={11.055, 11.055,11.055, 11.055, 11.055, 11.055, 11.055, 11.055, 11.055, 11.055, 11.055, 11.055,11.055, 11.055, 11.055, 11.055, 11.1159, 11.302, 11.6239, 12.1012, 11.06,9.4082, 8.2645, 7.4413, 6.8355, 6.3855, 6.0533, 5.8146, 5.6535, 5.5605, 5.53}
αj={0., 0.10472,0.20944, 0.314159, 0.418879, 0.523599, 0.628319, 0.733038, 0.837758, 0.942478,1.0472, 1.15192, 1.25664, 1.36136, 1.46608, 1.5708, 1.67552, 1.78024, 1.88496,1.98968, 2.0944, 2.19911, 2.30383, 2.40855, 2.51327, 2.61799, 2.72271, 2.82743,2.93215, 3.03687, 3.14159}

fun2适应度函数如下:
  1. function [betaj, s] = fun2(ck, popmin, popmax)
  2. global rj aj nvar
  3. % 上下限
  4. % lb = -pi*ones(size(aj));
  5. lb = aj-0.1;
  6. lb(1) = 0;  lb(end) = pi;
  7. % ub = 5*pi*ones(size(aj));
  8. ub = aj+0.1;
  9. ub(1) = 0;  ub(end) = pi;
  10. constraint = 0;
  11. for i=1:nvar
  12.     constraint = constraint+i*abs(ck(i));
  13. end
  14. if(constraint<1)
  15.     beta0 = rand( size(aj) );
  16.     options = optimoptions( 'fmincon', 'Algorithm', 'sqp', 'Display', 'off' );
  17.     [betaj, s] = fmincon( @(x)fun(x, ck), beta0, [],[],[],[], lb, ub, @(x)nonline_constraint(x, ck), options );
  18. else
  19.     betaj = zeros( size(aj) );
  20.     s = 1e3;
  21. end
  22. s = abs(s);
复制代码
fun目标函数如下:
  1. function y = fun(betaj, ck)
  2. global rj aj nvar
  3. y=0;
  4. % 误差最小
  5. for i=1:length(rj)
  6.     y=y+rj(i)+11.055/(1+sum(ck))*(cos(aj(i)-betaj(i))+ck(1)*cos(aj(i)+1*betaj(i))+...
  7.     ck(2)*cos(aj(i)+2*betaj(i))+ck(3)*cos(aj(i)+3*betaj(i))+ck(4)*cos(aj(i)+4*betaj(i))+...
  8.     ck(5)*cos(aj(i)+5*betaj(i)));
  9. end
复制代码
非线性月数函数如下:
  1. function [c, ceq] = nonline_constraint(betaj, ck)
  2. global rj aj nvar
  3. c = [ ];      % 不等式约束
  4. ceq=[ ];      % 等式约束
  5. for i=1:length(aj)
  6.     ceq(i) = sin(aj(i)-betaj(i))+ck(1)*cos(aj(i)+1*betaj(i))+...
  7.     ck(2)*cos(aj(i)+2*betaj(i))+ck(3)*cos(aj(i)+3*betaj(i))+ck(4)*cos(aj(i)+4*betaj(i))+...
  8.     ck(5)*cos(aj(i)+5*betaj(i));
  9. end
复制代码












本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
程序:算法QQ  3283892722
群智能算法视频售价:38元,链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


Python|Opencv|MATLAB|Halcom.cn  

GMT+8, 2019-3-25 19:56 , Processed in 0.121823 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表