楼主: leslie133
1796 1

[问答] 紧急求助:我的程序问题到底出在哪里? [推广有奖]

  • 1关注
  • 2粉丝

已卖:52份资源

本科生

9%

还不是VIP/贵宾

-

威望
0
论坛币
31 个
通用积分
0.1200
学术水平
4 点
热心指数
4 点
信用等级
4 点
经验
1040 点
帖子
56
精华
0
在线时间
52 小时
注册时间
2007-11-1
最后登录
2025-8-21

楼主
leslie133 发表于 2014-5-8 12:38:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
未命名.jpg 目标函数:maxW'HW,H为N*N的方阵,约束条件为:W’W=1,W>0,求解W
matlab版本是R2010b。

程序如下:
function x=main(H)
v1=zeros(N,1);
v2=ones(N,1);
x0=[zeros(N-1,1);1];
opt=[];
x=fmincon(@objfun1,x0,[],[],[],[],v1,v2,@consfun1,opt);   
   function f=objfun1(x)
        f=-x'*H*x;
    end
    function [c1,c2]=consfun1(x)
        c1=[];
        c2=x'*x-1;
    end
end
c=main(H)
运行之后出现:Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set algorithm. Youcould also try the interior-point or sqp algorithms: set the Algorithm option to 'interior-point' or 'sqp' andrerun. For more help, see Choosing the Algorithm in the documentation.
> In fmincon at 472
  In main at 6
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current search direction is less thantwice the default value of the step size tolerance and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
Active inequalities (to within options.TolCon = 1e-006):
  lower      upper     ineqlin   ineqnonlin
    2
    3
   4
  6
  16
   17
20
21
   25
c= 0.3036
   -0.0000
   -0.0000
    0.0000
    0.1650
    0.0000
    0.0200
    0.0738
    0.0862
    0.0020
    0.2012
    0.2933
    0.1685
    0.2939
    0.2910
    0.0000
    0.0000
    0.1943
    0.0561
    0.0000
    0.0000
    0.2886
    0.2374
    0.2950
   -0.0000
    0.2511
    0.2241
    0.2893
    0.2772
这儿的c值也就是W值还满足约束条件吗?如果有错应该怎么改?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:紧急求助 急求助 inequalities Constraints Constraint 程序

沙发
leslie133 发表于 2014-5-8 12:47:01
还是说这个不是非线性规划的问题而是其他的?

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 10:15