0

我有以下代码,我需要使用“fmincon”来求解具有线性约束和非线性目标函数的模型:

A = [Aeq ; Aineq];
x0 = zeros(size(A,2),1);
x0(1:T:(n+2)*T) = I0;
lb = zeros(size(A,2),1);
ub = Inf*zeros(size(A,2),1);
options = optimset('fmincon');

% fmincon:
[x , fval , exitflag , output , lambda] = fmincon(@MP_ObjF1 , x0 , Aineq , bineq , Aeq , beq , 0 , Inf , [] , options);

这是功能:

function ObjF = MP_ObjF1(x)

global n;
global T;
global h;
global Total_Tcij; %A row vector of T arrays

ObjF = 0;
for t=1:T
    x_I_set = ((1:T:(n+2)*T)+(t-1))';
    x_I = x(x_I_set);
    HC = x_I*h; %"x_I" is a row vector, and "h" is a column vector.
    newObjF = (Total_Tcij(t) + HC)*x((n+2)*T+t);
    ObjF = (ObjF + newObjF);
end

end

运行模型所需的数据如下(这是代码运行到上面部分代码的结果):

n = 2;
T = 3;
h = [5 ; 5 ; 5 ; 5];
Total_Tcij = [10    10    10];

Aineq =

Columns 1 through 14

 0     0     0     0     0     0     0     0     0     0     0     0     1     0
 0     0     0     0     0     0     0     0     0     0     0     0     0     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
 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
 0     0     0     0     0     0     0     0     0     0     0     0     1     0
 0     0     0     0     0     0     0     0     0     0     0     0     0     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
 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
 1     0     0     0     0     0     0     0     0     0     0     0     0     0
 0     1     0     0     0     0     0     0     0     0     0     0     0     0
 0     0     1     0     0     0     0     0     0     0     0     0     0     0
 0     0     0     1     0     0     0     0     0     0     0     0     0     0
 0     0     0     0     1     0     0     0     0     0     0     0     0     0
 0     0     0     0     0     1     0     0     0     0     0     0     0     0
 0     0     0     0     0     0     1     0     0     0     0     0     0     0
 0     0     0     0     0     0     0     1     0     0     0     0     0     0
 0     0     0     0     0     0     0     0     1     0     0     0     0     0
 0     0     0     0     0     0     0     0     0     1     0     0     0     0
 0     0     0     0     0     0     0     0     0     0     1     0     0     0
 0     0     0     0     0     0     0     0     0     0     0     1     0     0

Column 15

 0
 0
 1
 0
 0
 0
 0
 0
 1
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0

Aeq =

Columns 1 through 14

-1     0     0     0     0     0     0     0     0     0     0     0     4     0
 1    -1     0     0     0     0     0     0     0     0     0     0     0     4
 0     1    -1     0     0     0     0     0     0     0     0     0     0     0
 0     0     1    -1     0     0     0     0     0     0     0     0     0     0
 0     0     0     1    -1     0     0     0     0     0     0     0     0     0
 0     0     0     0     1    -1     0     0     0     0     0     0     0     0
 0     0     0     0     0     0    -1     0     0     0     0     0    13     0
 0     0     0     0     0     0     1    -1     0     0     0     0     0    13
 0     0     0     0     0     0     0     1    -1     0     0     0     0     0
 0     0     0     0     0     0     0     0     0     1     0     0     4     0
 0     0     0     0     0     0     0     0     0    -1     1     0     0     4
 0     0     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     0     0     0     0     0
 0     0     0     0     0     0     0     0     0     0     0     0     4     4
 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
 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
 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     7     7
 0     0     0     0     0     0     0     0     0     0     0     0     1     0
 0     0     0     0     0     0     0     0     0     0     0     0     0     1
 0     0     0     0     0     0     0     0     0     0     0     0     0     0

Column 15

 0
 0
 4
 0
 0
 0
 0
 0
 7
 0
 0
 4
 0
 0
 4
 0
 0
 0
 0
 0
 7
 0
 0
 1

bineq =
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
50
50
50
50
50
50
50
50
50
50
50
50

beq =

-4
 3
 5
 3
 4
 6
 5
 3
 5
 0
-4
-3
 0
 0
 4
 3
 7
13
 0
 2
 7
 1
 1
 1

结果是以下警告:

Warning: Trust-region-reflective method does not currently solve this type of problem, using active-set (line search) instead. 
> In fmincon at 439

No feasible solution found.

fmincon stopped because the size of the current search direction is less than twice the default value of the step size tolerance but constraints were not satisfied to within the selected value of the constraint tolerance.

<stopping criteria details>

但是,我很确定该程序有一个可行的解决方案;我应该设置任何关于搜索方向或约束容差的内容吗?我提前感谢您的帮助。

4

0 回答 0