24小时热门版块排行榜    

查看: 1617  |  回复: 0

chenxh97

银虫 (著名写手)

[求助] matlab最优化求解fmincon寻求帮助

运行 [x,fval,exitflag]=fmincon(@opt_fun,x0,A,[100 90 80],Aeq,[20 20],lb,ub,@opt_con_EEVEN)结果有错误,结果应该是:x=[20 0 0 20 0 0],但是运行的结果与初始值相同x0=[0 0 20 0 0 20].
运行结果与相关值如下所示:
>> [x,fval,exitflag]=fmincon(@opt_fun_EEVEN,x0,A,[100 90 80],Aeq,[20 20],lb,ub,@opt_con_EEVEN)
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
5.741181e-17.
> In /usr/local/MATLAB/R2014a/toolbox/optim/optim/private/backsolveSys.p>backsolveSys at 17
  In /usr/local/MATLAB/R2014a/toolbox/optim/optim/private/solveKKTsystem.p>solveKKTsystem at 15
  In /usr/local/MATLAB/R2014a/toolbox/optim/optim/private/computeTrialStep.p>computeTrialStep at 66
  In /usr/local/MATLAB/R2014a/toolbox/optim/optim/barrier.p>barrier at 357
  In fmincon at 818
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
8.881786e-18.
> In /usr/local/MATLAB/R2014a/toolbox/optim/optim/private/backsolveSys.p>backsolveSys at 17
  In /usr/local/MATLAB/R2014a/toolbox/optim/optim/private/solveKKTsystem.p>solveKKTsystem at 15
  In /usr/local/MATLAB/R2014a/toolbox/optim/optim/private/computeTrialStep.p>computeTrialStep at 66
  In /usr/local/MATLAB/R2014a/toolbox/optim/optim/barrier.p>barrier at 357
  In fmincon at 818

Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.

<stopping criteria details>
x =  0.0000    0.0000   20.0000    0.0000    0.0000   20.0000
fval =  6.4000e+03
exitflag =  1


其中
function y=opt_fun(x)
global cc;
y=sum(cc.*x);

function [c,ceq]=opt_con_EEVEN(x)
c=[];
ceq(1)=x(1)*(x(1)-20);
ceq(2)=x(2)*(x(2)-20);
ceq(3)=x(3)*(x(3)-20);
ceq(4)=x(4)*(x(4)-20);
ceq(5)=x(5)*(x(5)-20);
ceq(6)=x(6)*(x(6)-20);

A =
     1     1     0     0     0     0
     0     0     1     1     0     0
     0     0     0     0     1     1

Aeq = 1     0     1     0     1     0
         0     1     0     1     0     1

lb =     0     0     0     0     0     0
ub =   100   100   100   100   100   100
x0=0 0 20 0 0 20
cc =     1     1    20    20   300   300
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 chenxh97 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 只有每年这种时候来逛逛小木虫 +8 yaoyewhu2008 2026-08-20 8/400 2026-08-20 08:46 by since—2010
[基金申请] 今天基金会出结果吗?20260819 +14 kkkl_v 2026-08-19 15/750 2026-08-20 08:21 by sunzitan
[基金申请] 欢迎发来filecode的Mz6后的代码验证其规律 +55 医学老男孩 2026-08-13 123/6150 2026-08-19 23:44 by stan_et
[基金申请] 时间戳变了,能看出什么问题? +12 基诺咪客 2026-08-17 16/800 2026-08-19 22:04 by kk 的小木虫
[教师之家] 为什么余额宝的年化利率越来越低?主要原因有哪些? +5 瞬息宇宙 2026-08-15 5/250 2026-08-19 20:23 by super2002521
[基金申请] 今天放榜没戏了吧 +4 yuleib84 2026-08-19 5/250 2026-08-19 19:52 by hhs666
[基金申请] 今天放榜吗? +14 布布和一二 2026-08-19 15/750 2026-08-19 18:07 by gltch
[基金申请] filecode=后面第一个是大写字母 +10 wangze12014 2026-08-14 12/600 2026-08-19 16:56 by 苦难博士
[基金申请] 朋友圈看到的 +6 wangzilk 2026-08-18 8/400 2026-08-19 10:55 by Haru815
[基金申请] 快农历七夕节了,轻松一下,男人悄悄话,女施主请不要进来。 +6 Tide man 2026-08-14 7/350 2026-08-19 09:56 by ZJTJZ
[基金申请] 什么时候开奖? +6 CrisMessi 2026-08-18 6/300 2026-08-19 08:06 by Equinoxhua
[基金申请] 重要消息,中午系统在维护 +10 yuleib84 2026-08-18 11/550 2026-08-19 07:30 by 羽毛枫f
[基金申请] 明天放榜? +5 Shxjjxjkx 2026-08-18 5/250 2026-08-18 18:14 by -大大大大大-
[论文投稿] 投稿咨询 +4 wwm09 2026-08-17 6/300 2026-08-18 15:36 by wwm09
[基金申请] 时间戳又变了8-15 +14 archvillain 2026-08-15 26/1300 2026-08-18 13:37 by phantomgost
[基金申请] 哪位老哥知道今年的国自然具体哪一天放榜? +13 Ldrop2023 2026-08-13 16/800 2026-08-18 12:25 by 淀粉搬运工
[基金申请] 93BebMhtakh前后11位开头都是大写 +4 且听虎啸 2026-08-17 5/250 2026-08-18 00:49 by 蔡棒棒菂
[基金申请] 感觉是下周放榜了 +6 angus9576 2026-08-17 11/550 2026-08-17 23:57 by angus9576
[基金申请] 今天系统多次维护,明天很可能放榜! +8 zju2000 2026-08-16 9/450 2026-08-17 12:20 by lmz0216
[基金申请] 各位道友,我要去昆明玩几天,回来见。 +7 Tide man 2026-08-14 8/400 2026-08-15 01:11 by arzu_hma
信息提示
请填处理意见