24小时热门版块排行榜    

查看: 1558  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0703化学调剂 ,六级已过,有科研经历 +12 曦熙兮 2026-03-15 12/600 2026-03-19 19:42 by maocaozhuxi
[考研] 0703化学调剂 +4 18889395102 2026-03-18 4/200 2026-03-19 16:13 by 30660438
[考研] 化学求调剂 +3 临泽境llllll 2026-03-17 4/200 2026-03-19 13:59 by houyaoxu
[考研] 281求调剂(0805) +9 烟汐忆海 2026-03-16 19/950 2026-03-19 11:42 by laoshidan
[考研] 354求调剂 +4 Tyoumou 2026-03-18 7/350 2026-03-18 21:45 by Tyoumou
[考研] 085600材料与化工 +5 安全上岸! 2026-03-16 5/250 2026-03-18 15:33 by cmz0325
[考研] 070300化学319求调剂 +6 锦鲤0909 2026-03-17 6/300 2026-03-18 13:22 by Iveryant
[考研] 0703化学求调剂 总分331 +3 ZY-05 2026-03-13 3/150 2026-03-18 10:58 by macy2011
[考研] 0703化学调剂 +3 妮妮ninicgb 2026-03-17 3/150 2026-03-18 10:29 by macy2011
[考研] 296求调剂 +5 大口吃饭 身体健 2026-03-13 5/250 2026-03-17 21:05 by 不惑可乐
[考研] 085601求调剂 +4 Du.11 2026-03-16 4/200 2026-03-17 17:08 by ruiyingmiao
[考研] 26考研求调剂 +6 丶宏Sir 2026-03-13 6/300 2026-03-17 16:13 by 醉在风里
[考研] 070303 总分349求调剂 +3 LJY9966 2026-03-15 5/250 2026-03-16 14:24 by xwxstudy
[考研] 0703化学调剂 290分有科研经历,论文在投 +7 腻腻gk 2026-03-14 7/350 2026-03-16 10:12 by houyaoxu
[考研] 0856求调剂 +3 刘梦微 2026-03-15 3/150 2026-03-16 10:00 by houyaoxu
[考研] 080500,材料学硕302分求调剂学校 +4 初识可乐 2026-03-14 5/250 2026-03-14 21:08 by peike
[考研] 材料与化工 323 英一+数二+物化,一志愿:哈工大 本人本科双一流 +4 自由的_飞翔 2026-03-13 5/250 2026-03-14 19:39 by hmn_wj
[考研] 中科大材料专硕319求调剂 +3 孟鑫材料 2026-03-13 3/150 2026-03-14 18:10 by houyaoxu
[考研] 297求调剂 +4 学海漂泊 2026-03-13 4/200 2026-03-14 11:51 by 热情沙漠
[考研] 330求调剂 +3 ?酱给调剂跪了 2026-03-13 3/150 2026-03-14 10:13 by JourneyLucky
信息提示
请填处理意见