软件编程版 #72874 层

请教各位高手一个matlab最优化问题

楼主 · 1 楼
请教各位高手一个最优化问题
我在用fmincon函数做一个非线性最优化问题,老是出现以下错误提示
>> Warning: Length of lower bounds is > length(x); ignoring extra bounds
> In C:\MATLAB6p5\toolbox\optim\private\checkbounds.m at line 26
In C:\MATLAB6p5\toolbox\optim\fmincon.m at line 153
In C:\MATLAB6p5\work\model.m at line 25
Warning: Length of upper bounds is > length(x); ignoring extra bounds
> In C:\MATLAB6p5\toolbox\optim\private\checkbounds.m at line 35
In C:\MATLAB6p5\toolbox\optim\fmincon.m at line 153
In C:\MATLAB6p5\work\model.m at line 25
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In C:\MATLAB6p5\toolbox\optim\fmincon.m at line 213
In C:\MATLAB6p5\work\model.m at line 25
??? Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:

Index exceeds matrix dimensions.

Error in ==> C:\MATLAB6p5\work\model.m
On line 25 ==> [x,fval,exitflag,output,lambda] = fmincon(@model1,[],A,b,Aeq,beq,lb,ub,@model_c)


请各位高手帮我看看,我估计是非线性约束条件和fmincon函数的接口有问题,因为线性部分我都用linprog函数检验了,没问题。
附源程序:
model.m
A=[0.024 0 0.008 0 0 0.064 0.08 -1 0.048 0.064 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1
0.012 0 0.004 0 0 0.032 0.04 0 0.024 0.032 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1
0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0.65 0 0 0 0 0 0 0 0 0 0 0 -0.768 0 0 0
-0.3 -1 -0.8 -1 -0.8 -0.1 -0.5 -1 -1 -0.12 0 0 0 0 0 0 0 0 0 0.2225 0.195 0.085 0.14 0 0
0 -1 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 -0.15 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 -0.15 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 -0.15 -0.15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
1 0 0 0.08 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
b=[0;0;0.012325;0.010784;-0.0041386;-0.00148385;0;0;0;0;0;0;0;0;0;0.00118708;0.00237416];
Aeq=[1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1
0 0 0 0 0 0 0 0 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
beq=[0.029677;0;1];
lb = zeros(25,1);
ub=ones(25,1);
[x,fval,exitflag,output,lambda] = fmincon(@model1,[],A,b,Aeq,beq,lb,ub,@model_c)

model1.m
function f =model1(x)
f ='-0.031X(1)-0.03 X(3)-0.0252 X(4)-0.0252 X(5)-0.07 X(6)-0.08 X(7)-0.059962x(11)-0.058954 x(12)-0.084842 x(13)-0.077896 x(14)-0.033412 x(15)-0.027557 x(16)-0.184894 x(17)-0.089177 x(18)-0.059509 x(19)+0.029 x(20)+0.03 x(21)+0.028 x(22)+0.031 x(23)+0.0005323158';

model_c.m
function [c,ceq] = model_c(x)
.13,0,0,0,0,0,0,0,0;0,0.18,0,0,0,0,0,0,0;0,0,1.53,0,0,0,0,0,0;0,0,0,2.72,0,0,0,0,0;0,0,0,0,6.74,0,0,0,0;0,0,0,0,0,14.87,0,0,0;0,0,0,0,0,0,32.17,0,0;0,0,0,0,0,0,0,1.43,0;0,0,0,0,0,0,0,0,0.0676];
bb=[1,0.2112,0.2507,0.2815,0.3815,0.5553,0.2518,0.54,0.7581;...
0.2112,1,0.1814,-0.117,0.3386,-0.0544,0.5537,-0.1994,-0.0114;...
0.2507,0.1814,1,0.4165,0.1911,0.0355,0.4767,0.1365,0.2381;...
0.2815,-0.117,0.4165,1,0.5498,0.118,0.3534,0.3497,0.3461;...
0.3815,0.3386,0.1911,0.5498,1,0.1509,0.6149,0.1182,0.2382;...
0.5553,-0.0544,0.0355,0.118,0.1509,1,0.2414,0.1066,0.1887;...
0.2518,0.5537,0.4767,0.3534,0.6149,0.2414,1,0.0482,0.0476;...
0.5,-0.1994,0.1365,0.3497,0.1182,0.1066,0.0482,1,0.6037;...
0.7581,-0.0114,0.2381,0.3461,0.2382,0.1887,0.0476,0.6037,1];
cc=a*bb*a;
d=[x(11),x(12),x(13),x(14),x(15),x(16),x(17),x(18),x(19)];
e=[x(11);x(12);x(13);x(14);x(15);x(16);x(17);x(18);x(19)];
f=d*cc*e;
g=expand((x(11)+x(12)+x(13)+x(14)+x(15)+x(16)+x(17)+x(18)+x(19))^2);
h=f*g;
i=expand((x(12)+x(14)+x(15))^2)/1.65^2;
j=expand(Simple(h-i));
c=j;
ceq=[];

2 楼
你优化的初值是多少啊?
3 楼
同楼上的问题.
4 楼
好象没有附初值????????