次のコードがあり、「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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
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>
しかし、このプログラムには実行可能な解決策があると確信しています。検索方向や制約許容値など、何か設定する必要がありますか? よろしくお願いします。