各單位每筆預算計劃書之決策變數 x ij 值彙整表
附錄 3 Matlab 使用之程式碼
問題一: 預算分配最佳化
% 研究者的方法
C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
v_vec = [];
coord = [];
for i = 1:M for j = 1:N
v_vec = [v_vec V(i,j)];
coord = [coord [i;j]];
end end
[v_sort, index] = sort(v_vec,'descend');
money = 0;
indexx = 1;
res_coord = [];
while money < 1262
money = money + C(coord(1,index(indexx)),coord(2,index(indexx)));
res_coord = [res_coord [coord(:,index(indexx))]];
indexx = indexx + 1;
end
money = money - C(coord(1,index(indexx-1)),coord(2,index(indexx-1)));
res_coord(:,length(res_coord)) = [];
x_table = zeros(M,N);
for i = 1:length(res_coord)
x_table(res_coord(1,i),res_coord(2,i)) = 1;
end
% 最大貢獻度
unit_contribution = V.*x_table;
total_contribution = sum(sum(unit_contribution));
% 單位預算
unit_money = C.*x_table;
total_money = sum(sum(unit_money));
% 滿意度
Require = [238;250;245;235;240;213];
real_req = zeros(M,1);
for i = 1:M
real_req(i) = sum(C(i,:).*x_table(i,:));
end
diff = (real_req)./Require;
sati_val = max(diff)-min(diff);
問題二: 作業維持效能最大化
% 研究者的方法
C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
v_vec = [];
coord = [];
for i = 1:M for j = 6:N
v_vec = [v_vec V(i,j)];
coord = [coord [i;j]];
end end
[v_sort, index] = sort(v_vec,'descend');
money = 0;
indexx = 1;
res_coord = [];
while money < 624
money = money + C(coord(1,index(indexx)),coord(2,index(indexx)));
res_coord = [res_coord [coord(:,index(indexx))]];
indexx = indexx + 1;
end
money = money - C(coord(1,index(indexx-1)),coord(2,index(indexx-1)));
res_coord(:,length(res_coord)) = [];
x_table = zeros(M,N);
x_table(:,1:5) = ones(6,5);
for i = 1:length(res_coord)
x_table(res_coord(1,i),res_coord(2,i)) = 1;
end
% 最大貢獻度
unit_contribution = V.*x_table;
total_contribution = sum(sum(unit_contribution));
% 單位預算
unit_money = C.*x_table;
total_money = sum(sum(unit_money));
% 滿意度
Require = [238;250;245;235;240;213];
real_req = zeros(M,1);
for i = 1:M
real_req(i) = sum(C(i,:).*x_table(i,:));
end
diff = (real_req)./Require;
sati_val = max(diff)-min(diff);
問題三: 軍事投資效能最大化
% 研究者的方法
C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
ratio = [0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8];
V = W./C;
M = 6;
N = 9;
v_vec = [];
coord = [];
for i = 1:M for j = 6:N
v_vec = [v_vec V(i,j)];
coord = [coord [i;j]];
end end
[v_sort, index] = sort(v_vec,'descend');
money = 0;
indexx = 1;
res_coord = [];
ratio_C = ratio.*C(:,1:5);
left_money = 1262 - sum(sum(ratio_C));
while money < left_money
money = money + C(coord(1,index(indexx)),coord(2,index(indexx)));
res_coord = [res_coord [coord(:,index(indexx))]];
indexx = indexx + 1;
end
money = money - C(coord(1,index(indexx-1)),coord(2,index(indexx-1)));
res_coord(:,length(res_coord)) = [];
x_table = zeros(M,N);
x_table(:,1:5) = ratio;
for i = 1:length(res_coord)
x_table(res_coord(1,i),res_coord(2,i)) = 1;
end
% 最大貢獻度
unit_contribution = V.*x_table;
total_contribution = sum(sum(unit_contribution));
% 單位預算
unit_money = C.*x_table;
total_money = sum(sum(unit_money));
% 滿意度
Require = [238;250;245;235;240;213];
real_req = zeros(M,1);
for i = 1:M
real_req(i) = sum(C(i,:).*x_table(i,:));
end
diff = (real_req)./Require;
sati_val = max(diff)-min(diff);
整數規劃求解程式碼
問題一: 預算分配最佳化-基於整體貢獻度最大化
% 本程式用於提供最大貢獻度 C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
f = [];
A = [];
for i = 1:M f = [f V(i,:)];
A = [A C(i,:)];
end
b = 1262; % Billion x = bintprog(-f,A,b);
x_table = zeros(M,N);
xindex = 1;
for m = 1:M for n = 1:N
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
win_index = find(x == 1);
win_value = f(win_index);
submit_order = [];
for i = 1:length(win_index)
[max_obj,max_index] = max(win_value);
for j = 1:length(max_obj)
if mod(win_index(max_index(j)),N) ~= 0 submit_order = [submit_order
[win_index(max_index(j));floor(win_index(max_index(j))/N)+1;mod(win_index(max _index(j)),N);win_value(max_index(j))]];
else
submit_order = [submit_order
[win_index(max_index(j));floor(win_index(max_index(j))/N);N;win_value(max_inde x(j))]];
end end
win_value(max_index) = -1e10;
end
% Contribution
dec_mat = zeros(M,N); % Decision matrix index = 1;
for i = 1:M for j = 1:N
dec_mat(i,j) = x(index);
index = index + 1;
end end
% 最大貢獻度
max_contribution = f*x;
% 單位貢獻度
contribution_table = V.*x_table;
% 單位經費
unit_money = C.*x_table;
total_money = sum(sum(C.*x_table));
% 單位戰力
unit_fight = W.*x_table;
total_fight = sum(sum(W.*x_table));
% 滿意度
Require = [238;250;245;235;240;213];
real_req = zeros(M,1);
for i = 1:M
real_req(i) = sum(C(i,:).*dec_mat(i,:));
end
diff = (real_req)./Require;
sati_val = max(diff)-min(diff);
問題一: 預算分配最佳化-基於整體預算最大化
% 本程式用於提供最大經費 C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
f = [];
A = [];
for i = 1:M f = [f C(i,:)];
A = [A C(i,:)];
end
b = 1262; % Billion x = bintprog(-f,A,b);
x_table = zeros(M,N);
xindex = 1;
for m = 1:M for n = 1:N
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
win_index = find(x == 1);
win_value = f(win_index);
submit_order = [];
for i = 1:length(win_index)
[max_obj,max_index] = max(win_value);
for j = 1:length(max_obj)
if mod(win_index(max_index(j)),N) ~= 0 submit_order = [submit_order
[win_index(max_index(j));floor(win_index(max_index(j))/N)+1;mod(win_index(max _index(j)),N);win_value(max_index(j))]];
else
submit_order = [submit_order
[win_index(max_index(j));floor(win_index(max_index(j))/N);N;win_value(max_inde x(j))]];
end end
win_value(max_index) = -1e10;
end
% Contribution
dec_mat = zeros(M,N); % Decision matrix index = 1;
for i = 1:M for j = 1:N
dec_mat(i,j) = x(index);
index = index + 1;
end end
% 最大經費 max_money = f*x;
% 單位貢獻度
contribution_table = V.*x_table;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table;
total_money = sum(sum(C.*x_table));
% 單位戰力
unit_fight = W.*x_table;
total_fight = sum(sum(W.*x_table));
% 滿意度
Require = [238;250;245;235;240;213];
real_req = zeros(M,1);
for i = 1:M
real_req(i) = sum(C(i,:).*dec_mat(i,:));
end
diff = (real_req)./Require;
sati_val = max(diff)-min(diff);
問題一: 預算分配最佳化-基於整體戰力值最大化
% 本程式用於提供最大戰力價值 C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
f = [];
A = [];
for i = 1:M
f = [f W(i,:)];
A = [A C(i,:)];
end
b = 1262; % Billion x = bintprog(-f,A,b);
x_table = zeros(M,N);
xindex = 1;
for m = 1:M for n = 1:N
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
win_index = find(x == 1);
win_value = f(win_index);
submit_order = [];
for i = 1:length(win_index)
[max_obj,max_index] = max(win_value);
for j = 1:length(max_obj)
if mod(win_index(max_index(j)),N) ~= 0 submit_order = [submit_order
[win_index(max_index(j));floor(win_index(max_index(j))/N)+1;mod(win_index(max _index(j)),N);win_value(max_index(j))]];
else
submit_order = [submit_order
[win_index(max_index(j));floor(win_index(max_index(j))/N);N;win_value(max_inde x(j))]];
end end
win_value(max_index) = -1e10;
end
% Contribution
dec_mat = zeros(M,N); % Decision matrix index = 1;
for i = 1:M for j = 1:N
dec_mat(i,j) = x(index);
index = index + 1;
end end
% 最大戰力價值 max_fight = f*x;
% 單位貢獻度
contribution_table = V.*x_table;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table;
total_money = sum(sum(C.*x_table));
% 單位戰力
unit_fight = W.*x_table;
total_fight = sum(sum(W.*x_table));
% 滿意度
Require = [238;250;245;235;240;213];
real_req = zeros(M,1);
for i = 1:M
real_req(i) = sum(C(i,:).*dec_mat(i,:));
end
diff = (Require - real_req)/Require(i);
sati_val = max(diff)-min(diff);
問題二: 作業維持效能最大化-基於整體貢獻度最大化
% 本程式用於滿足最大計畫貢獻度
% Consider the satisification C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
f = [];
A = [];
for i = 1:M
f = [f V(i,6:9)];
A = [A C(i,6:9)];
end
b = 624; % Billion x = bintprog(-f,A,b);
x_table = zeros(M,4);
xindex = 1;
for m = 1:M for n = 1:4
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
% 最大計畫貢獻度
max_contribution = f*x;
% 各單位使用經費
unit_money = C(:,6:9).*x_table;
% 累計經費
unit_total_money = sum(sum(unit_money));
x_table_full = [ones(6,5) x_table];
% 單位貢獻度
contribution_table = V.*x_table_full;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table_full;
total_money = sum(sum(C.*x_table_full));
% 單位戰力
unit_fight = W.*x_table_full;
total_fight = sum(sum(W.*x_table_full));
問題二: 作業維持效能最大化-基於整體預算最大化
% 本程式用於滿足最大可用經費
% Consider the satisification C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
f = [];
A = [];
for i = 1:M
f = [f C(i,6:9)];
A = [A C(i,6:9)];
end
b = 624; % Billion x = bintprog(-f,A,b);
x_table = zeros(M,4);
xindex = 1;
for m = 1:M for n = 1:4
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
% 最大計畫經費
max_money = f*x;
% 各單位使用經費
unit_money = C(:,6:9).*x_table;
% 累計經費
unit_total_money = sum(sum(unit_money));
x_table_full = [ones(6,5) x_table];
% 單位貢獻度
contribution_table = V.*x_table_full;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table_full;
total_money = sum(sum(C.*x_table_full));
% 單位戰力
unit_fight = W.*x_table_full;
total_fight = sum(sum(W.*x_table_full));
問題二:作業維持效能最大化-基於整體戰力值最大化
% 本程式用於滿足最大戰力價值
% Consider the satisification C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
V = W./C;
M = 6;
N = 9;
f = [];
A = [];
for i = 1:M
f = [f W(i,6:9)];
A = [A C(i,6:9)];
end
b = 624; % Billion x = bintprog(-f,A,b);
x_table = zeros(M,4);
xindex = 1;
for m = 1:M for n = 1:4
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
% 最大戰力價值
max_fight = f*x;
% 各單位使用經費
unit_money = C(:,6:9).*x_table;
% 累計經費
total_money = sum(sum(unit_money));
% 累計經費
unit_total_money = sum(sum(unit_money));
x_table_full = [ones(6,5) x_table];
% 單位貢獻度
contribution_table = V.*x_table_full;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table_full;
total_money = sum(sum(C.*x_table_full));
% 單位戰力
unit_fight = W.*x_table_full;
total_fight = sum(sum(W.*x_table_full));
問題三: 軍事投資效能最大化-基於整體貢獻度最大化
% 本程式用於滿足最大貢獻度
% Consider the satisification C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
ratio = [0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8];
V = W./C;
% OM 所要花費的金額表
unit_prerequire_money = C(:,1:5).*ratio;
left_money = 1262 - sum(sum(unit_prerequire_money));
M = 6;
N = 5;
f = [];
A = [];
for i = 1:M
f = [f V(i,6:9)];
A = [A C(i,6:9)];
end
b = left_money; % Billion
x = bintprog(-f,A,b);
x_table = zeros(M,4);
xindex = 1;
for m = 1:M for n = 1:4
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
% 最大貢獻度
max_contribution = f*x;
% 各單位的貢獻度
contribution_table = V(:,6:9).*x_table;
% 各單位使用經費
unit_money = C(:,6:9).*x_table;
% 累計經費
total_money = sum(sum(unit_money));
% 各單位的戰力價值
fight_value_table = W(:,6:9).*x_table;
fight_value = sum(sum(fight_value_table));
% 累計經費
unit_total_money = sum(sum(unit_money));
x_table_full = [ratio x_table];% 單位貢獻度 contribution_table = V.*x_table_full;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table_full;
total_money = sum(sum(C.*x_table_full));
% 單位戰力
unit_fight = W.*x_table_full;
total_fight = sum(sum(W.*x_table_full));
問題三: 軍事投資效能最大化-基於整體預算最大化
% 本程式用於滿足最大可用經費
% Consider the satisification C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
ratio = [0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8];
V = W./C;
% OM 所要花費的金額表
unit_prerequire_money = C(:,1:5).*ratio;
left_money = 1262 - sum(sum(unit_prerequire_money));
M = 6;
N = 5;
f = [];
A = [];
for i = 1:M
f = [f C(i,6:9)];
A = [A C(i,6:9)];
end
b = left_money; % Billion
x = bintprog(-f,A,b);
x_table = zeros(M,4);
xindex = 1;
for m = 1:M for n = 1:4
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
% 最大可用經費 max_fight = f*x;
% 各單位使用經費
unit_money = C(:,6:9).*x_table;
% 貢獻度
contribution_table = V(:,6:9).*x_table;
contribution_value = sum(sum(contribution_table));
% 戰力價值
fight_value_table = W(:,6:9).*x_table;
fight_value = sum(sum(fight_value_table));
% 累計經費
unit_total_money = sum(sum(unit_money));
x_table_full = [ratio x_table];% 單位貢獻度 contribution_table = V.*x_table_full;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table_full;
total_money = sum(sum(C.*x_table_full));
% 單位戰力
unit_fight = W.*x_table_full;
total_fight = sum(sum(W.*x_table_full));
問題三: 軍事投資效能最大化-基於整體戰力值最大化
% 本程式用於滿足最大戰力價值
% Consider the satisification C = [32 26 18 15 12 46 37 28 24;...
36 31 20 14 7 52 36 35 19;...
42 29 18 13 11 56 35 23 18;...
28 25 17 16 16 43 36 32 22;...
39 27 21 12 5 47 34 31 24;...
33 26 22 17 10 42 31 19 13];
W = [18 15 10 8 5 28 19 13 10;...
19 16 11 6 3 29 18 16 8;...
22 16 10 6 4 30 19 11 7;...
16 14 9 8 7 24 19 17 10;...
21 18 11 6 2 25 18 15 10;...
18 14 12 9 4 23 17 10 5];
ratio = [0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.75 0.75 0.75 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8;...
0.8 0.8 0.8 0.8 0.8];
V = W./C;
% OM 所要花費的金額表
unit_prerequire_money = C(:,1:5).*ratio;
left_money = 1262 - sum(sum(unit_prerequire_money));
M = 6;
N = 5;
f = [];
A = [];
for i = 1:M
f = [f W(i,6:9)];
A = [A C(i,6:9)];
end
b = left_money; % Billion
x = bintprog(-f,A,b);
x_table = zeros(M,4);
xindex = 1;
for m = 1:M for n = 1:4
x_table(m,n) = x(xindex);
xindex = xindex + 1;
end end
% 最大戰力價值 max_fight = f*x;
% 各單位使用經費
unit_money = C(:,6:9).*x_table;
% 各單位的貢獻度
contribution_table = V(:,6:9).*x_table;
contribution_value = sum(sum(contribution_table));
% 各單位的戰力價值
fight_value_table = W(:,6:9).*x_table;
% 累計經費
unit_total_money = sum(sum(unit_money));
x_table_full = [ratio x_table];% 單位貢獻度 contribution_table = V.*x_table_full;
total_contribution = sum(sum(contribution_table));
% 單位經費
unit_money = C.*x_table_full;
total_money = sum(sum(C.*x_table_full));
% 單位戰力
unit_fight = W.*x_table_full;
total_fight = sum(sum(W.*x_table_full));