谢谢大家的热情帮忙。
今天我重新修改了一下
myfun.m
function f = myfun(x)
f = 'c(1,1)*abs(d(1,1)-x(1))+c(1,2)*abs(d(1,2)-x(2))+c(1,3)*abs(d(1,3)-x(3))+c(1,4)*abs(d(1,4)-x(4))+c(1,5)*abs(d(1,5)-x(5))+c(2,1)*abs(d(2,1)-x(6))+c(2,2)*abs(d(2,2)-x(7))+c(2,3)*abs(d(2,3)-x(8))+c(2,4)*abs(d(2,4)-x(9))+c(2,5)*abs(d(2,5)-x(10))+c(3,1)*abs(d(3,1)-x(11))+c(3,2)*abs(d(3,2)-x(12))+c(3,3)*abs(d(3,3)-x(13))+c(3,4)*abs(d(3,4)-x(14))+c(3,5)*abs(d(3,5)-x(15))';
Untitled3.m
s=200;
d=[1 2 3 4 5;2 3 4 5 6;3 4 5 6 7];
c=[1 2 3 4 5;2 3 4 5 6;3 4 5 6 7];
x0=[1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;];
A=[1 0 0 0 0 1 0 0 0 0 1 0 0 0 0;0 1 0 0 0 0 1 0 0 0 0 1 0 0 0;0 0 1 0 0 0 0 1 0 0 0 0 1 0 0;0 0 0 1 0 0 0 0 1 0 0 0 0 1 0;0 0 0 0 1 0 0 0 0 1 0 0 0 0 1];
b=[s;s;s;s;s];
Aeq=[1 1 1 1 1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 1 1 1 1 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 1 1 1 1 1];
beq=[d(1,1)+d(1,2)+d(1,3)+d(1,4)+d(1,5);d(2,1)+d(2,2)+d(2,3)+d(2,4)+d(2,5);d(3,1)+d(3,2)+d(3,3)+d(3,4)+d(3,5)];
[x,fval]=fmincon(@myfun,x0,A,b,Aeq,beq);
结果出现一下提示
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In E:\MATLAB6p5\toolbox\optim\fmincon.m at line 213
In e:\MATLAB6p5\work\myfun.m at line 2
In E:\MATLAB6p5\toolbox\optim\fmincon.m at line 288
In e:\MATLAB6p5\work\Untitled3.m at line 9
2 f = c(1,1)*abs(d(1,1)-x(1))+c(1,2)*abs(d(1,2)-x(2))+c(1,3)*abs(d(1,3)-x(3))+c(1,4)*abs(d(1,4)-x(4))+c(1,5)*abs(d(1,5)-x(5))+c(2,1)*abs(d(2,1)-x(6))+c(2,2)*abs(d(2,2)-x(7))+c(2,3)*abs(d(2,3)-x(8))+c(2,4)*abs(d(2,4)-x(9))+c(2,5)*abs(d(2,5)-x(10))+c(3,1)*abs
我怀疑是目标函数过长,fmincon函数解不了
大家怎么认为? |