声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 959|回复: 3

求教优化程序中的错误,帮忙修改一下。。。

[复制链接]
发表于 2006-4-20 22:31 | 显示全部楼层 |阅读模式

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

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

x
f=[50 30 80 40 0 0 0 0 0 0];<BR>Aeq=[0.4288 -0.4288 -0.214 0.214 -1 0 0 0 0 0<BR>0.4288 -0.4288 -0.214 0.214 0 1 0 0 0 0<BR>0.5717 -0.5717 0.2143 -0.2143 0 0 -1 0 0 0<BR>0.5717 -0.5717 0.2143 -0.2143 0 0 0 1 0 0<BR>0.4286 -0.4286 0.7853 -0.7853 0 0 0 0 -1 0<BR>0.4286 -0.4286 0.7853 -0.7853 0 0 0 0 0 1];<BR> beq=[-18.584<BR>1.416<BR>-46.437<BR>3.573<BR>-53.57<BR>-3.572];<BR>lb=[0;0;0;0;0;0;0;0;0;0];<BR>ub=[1;1;1;1];<BR>[x,fval]=linprog(f,Aeq,beq,lb,ub)<BR>为什么这个程序总是出现这样的错误啊,矩阵应该没问题啊,实在想不通了,求教高手指点!!!<BR>??? Error using ==&gt; linprog<BR>The number of rows in Aeq must be the same as the length of beq.
回复
分享到:

使用道具 举报

发表于 2006-4-20 22:48 | 显示全部楼层
你调用的有问题<BR>Solve a linear programming problem  where f, x, b, beq, lb, and ub are vectors and <STRONG><FONT color=#b32bd5>A and Aeq are matrices</FONT></STRONG>. Syntaxx = linprog(f,A,b,Aeq,beq)<BR>x = linprog(f,A,b,Aeq,beq,lb,ub)<BR>x = linprog(f,A,b,Aeq,beq,lb,ub,x0)<BR>x = linprog(f,A,b,Aeq,beq,lb,ub,x0,options)<BR>[x,fval] = linprog(...)<BR>[x,fval,exitflag] = linprog(...)<BR>[x,fval,exitflag,output] = linprog(...)<BR>[x,fval,exitflag,output,lambda] = linprog(...)<BR><BR>里面 A和Aeq是矩阵,也就是你的lb应该和Aeq大小相等。<BR>还有自己定义参数,最好不要和程序给定同名,容易混淆
 楼主| 发表于 2006-4-21 13:15 | 显示全部楼层
<P>还是不大懂呢,我现在的lb和Aeq是一样大的阿,是不是所有的都要表示成Ax&lt;b和Aeqx=beq啊,要是没有Ax&lt;b应该怎么办啊?</P>
发表于 2006-4-21 22:20 | 显示全部楼层

回复:(naichayu)求教优化程序中的错误,帮忙修改一...

<DIV class=quote><B>以下是引用<I>naichayu</I>在2006-4-20 22:31:47的发言:</B><BR>f=[50 30 80 40 0 0 0 0 0 0];<BR>Aeq=[0.4288 -0.4288 -0.214 0.214 -1 0 0 0 0 0<BR>0.4288 -0.4288 -0.214 0.214 0 1 0 0 0 0<BR>0.5717 -0.5717 0.2143 -0.2143 0 0 -1 0 0 0<BR>0.5717 -0.5717 0.2143 -0.2143 0 0 0 1 0 0<BR>0.4286 -0.4286 0.7853 -0.7853 0 0 0 0 -1 0<BR>0.4286 -0.4286 0.7853 -0.7853 0 0 0 0 0 1];<BR>beq=[-18.584<BR>1.416<BR>-46.437<BR>3.573<BR>-53.57<BR>-3.572];<BR>lb=[0;0;0;0;0;0;0;0;0;0];<BR>ub=[1;1;1;1];<BR><FONT color=#ff0000>[x,fval]=linprog(f,Aeq,beq,lb,ub)<BR></FONT>为什么这个程序总是出现这样的错误啊,矩阵应该没问题啊,实在想不通了,求教高手指点!!!<BR>??? Error using ==&gt; linprog<BR>The number of rows in Aeq must be the same as the length of beq.</DIV>
<P>x = linprog(f,A,b,Aeq,beq,lb,ub)<BR><BR>你这里的A和b呢?怎么丢了啊</P>
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-25 21:28 , Processed in 0.069522 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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