声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 988|回复: 1

[编程技巧] 优化问题

[复制链接]
发表于 2007-3-5 15:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
funf='f=0.0061*[(x(1)^2-x(5)^2)*x(4)+(x(2)^2-x(5)^2)*x(3)];';
fung='g=[x(1)-60;40-x(1);x(2)-51;28-x(2);x(3)-214.4;107.2-x(3);x(4)-140;90-x(4);0.9*x(2)-x(5)-2.5;2-0.9*x(2)+x(5);x(5)/x(2)-0.7;x(5)/x(1)-6.5];';
fun=[funf fung];
x0=[-1 1];
options=[];
[x, options]=constr(fun, x0, options);


Warning: The function CONSTR is obsolete and has been replaced by
FMINCON.  CONSTR will be removed in a future release of the
Optimization Toolbox.  Update your code to call FMINCON to
suppress this warning message.  See "Converting your code to
Version 2 Syntax" in the Optimization Toolbox User's Guide
for more information.

> In F:\Matlab\toolbox\optim\constr.m at line 55
??? Error using ==> inlineeval
Error in inline expression ==> 0.0061*[(x(1)^2-x(5)^2)*x(4)+(x(2)^2-x(5)^2)*x(3)]
???  Index exceeds matrix dimensions.

Error in ==> F:\Matlab\toolbox\matlab\funfun\@inline\feval.m
On line 34  ==>         INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ==> F:\Matlab\toolbox\optim\private\opteval.m
On line 27  ==>       f = feval(FUNfcns{1},x,varargin{:});

Error in ==> F:\Matlab\toolbox\optim\private\nlconstold.m
On line 59  ==>   [f,g,msg] = opteval(x,FUNfcn,varargin{:});

Error in ==> F:\Matlab\toolbox\optim\constr.m
On line 86  ==> [x,OPTIONS,lambda,HESS]=nlconstold(funfcn,x,OPTIONS,VLB,VUB,gradfcn,varargin{:});


惩罚函数法计算最优解,怎么调,高手指教!

[ 本帖最后由 xinyuxf 于 2007-7-22 12:15 编辑 ]
回复
分享到:

使用道具 举报

发表于 2007-3-12 01:35 | 显示全部楼层
改用FMINCON来做,具体参考帮助
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-24 19:23 , Processed in 0.057526 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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