请各位大哥帮帮忙
楼主 · 1 楼
我用matlab作最优化,用到fmincon函数,但不懂这个函数怎么用的,主要是options后面的参数,[x,fval,exitflag,output]=fmincon(@designobj,x0,A,b,Aeq,beq,lb,ub,@designcon,options,s,p,a,b1,c1,d,e,t),就是后面s,p等参数具体怎么用的?
自己做了一个小例子,但出现如下错误,
>> Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In D:\MATLAB6p5\toolbox\optim\fmincon.m at line 213
In d:\MATLAB6p5\work\Untitled3.m at line
11
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function
failed with the following error:
Error using ==> opt25_3o
Too many input arguments.
Error in ==> d:\MATLAB6p5\work\Untitled3.m
On line
11 ==> [x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c,[],w)
我自己编的小程序如下:
A=[-1 0 0
1 0 0
0 -1 0
0 1 0
0 0 -1
0 0 1];
b=[-1;4;-4.5;50;-
10;;30];
x0=[2.0;5.0;25.0];
lb=zeros(3,1);
w=[2;2];
[x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c,[],w)
function f=myfun
f=0.192457*1e-4*(x(2)+w(1))*x(1)^w(2)*x(3);如果w(1)和w(2)用具体数字的时候就能正常运行,当我换成w代替后就出现上面的错误了,
自己做了一个小例子,但出现如下错误,
>> Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In D:\MATLAB6p5\toolbox\optim\fmincon.m at line 213
In d:\MATLAB6p5\work\Untitled3.m at line
11
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function
failed with the following error:
Error using ==> opt25_3o
Too many input arguments.
Error in ==> d:\MATLAB6p5\work\Untitled3.m
On line
11 ==> [x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c,[],w)
我自己编的小程序如下:
A=[-1 0 0
1 0 0
0 -1 0
0 1 0
0 0 -1
0 0 1];
b=[-1;4;-4.5;50;-
10;;30];
x0=[2.0;5.0;25.0];
lb=zeros(3,1);
w=[2;2];
[x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c,[],w)
function f=myfun
f=0.192457*1e-4*(x(2)+w(1))*x(1)^w(2)*x(3);如果w(1)和w(2)用具体数字的时候就能正常运行,当我换成w代替后就出现上面的错误了,