-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinear_programming.m
More file actions
60 lines (39 loc) · 1.31 KB
/
linear_programming.m
File metadata and controls
60 lines (39 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [allocate_indicator] = linear_programming(user_modulation, channel_gain, user_TX, noise_plus_ici)
format long
%channel_gain here is an N * 1 array.
%disp(channel_gain);
num_of_users = size(channel_gain, 1);
%disp(num_of_users);
%modulation_requirement(:, 2);
%allocate_indicator = zeros(num_of_users);
allocation = zeros(num_of_users, 5);
allocation(:, 1 : 2) = user_modulation;
%disp(allocation);
allocation(:, 3) = 1;
%allocation(1, 4) = (-1 * user_TX * channel_gain(1)) / allocation(1, 2);
allocation(2 : num_of_users, 4) = user_TX .* channel_gain(2 : num_of_users);
%disp(valid_user);
ObjectiveFunction = -1 * allocation(2 : num_of_users, 3)';
Aeq = [];
beq = [];
A = 10e15 * allocation(2 : num_of_users, 4)';
b = 10e15 * ((user_TX * channel_gain(1)) / allocation(1, 2) - noise_plus_ici);
lb = zeros(1, num_of_users - 1);
ub = ones(1, num_of_users - 1);
%disp(ObjectiveFunction);
%disp(Aeq);
%disp(beq);
%disp(lb);
%disp(ub);
%options = optimoptions('linprog','Algorithm','dual-simplex');
[x] = linprog(ObjectiveFunction, A, b, Aeq, beq, lb, ub);
%disp(x);
%disp(fval);
%disp(exitflag);
%disp(output);
allocation(1, 5) = 1;
allocation(2 : num_of_users, 5) = x;
%disp(allocation);
allocate_indicator = allocation(:, 5);
%disp(allocate_indicator);
end