-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterest_aware_simulation.m
More file actions
51 lines (31 loc) · 1.98 KB
/
interest_aware_simulation.m
File metadata and controls
51 lines (31 loc) · 1.98 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
function [clusters, total_system_energy_consumed, total_power_info_transmission, metric_iaf1, metric_iaf2] = interest_aware_simulation(D, ID, E, E_i, G, params)
% Interest aware simulation
total_energy = sum(E);
clusters = create_clusters(ID, D, params);
num_rounds = params.rounds;
round_power_info_transmission = zeros(num_rounds,1);
total_system_energy_consumed = zeros(num_rounds,1);
round_metric_iaf1 = zeros(num_rounds,1);
round_metric_iaf2 = zeros(num_rounds,1);
for round = 1:num_rounds
clusterheads = find_clusterheads(clusters, ID, D, E, params);
master_cluster = [clusterheads, params.m+1];
powers_requested = find_powers_to_maximize_utility([clusters master_cluster],[clusterheads params.m+1],G);
powers_info_transmission = find_powers_to_send_info(powers_requested, clusterheads, E, params);
% calculate energy after information transmission of clusterheads first
% so that they give priority to their transmission instead of sending power
% to other devices
E = decrease_energy_availability(E, clusterheads, powers_info_transmission, 'info', params);
power_from_clusterheads = find_powers_clusterheads_must_transmit(powers_requested,clusters,clusterheads, G, E, params);
E = decrease_energy_availability(E, clusterheads, power_from_clusterheads, 'energy', params);
powers_info_transmission = find_powers_devices_will_actually_send(powers_info_transmission, power_from_clusterheads, powers_requested, clusters, clusterheads, G, params);
round_power_info_transmission(round) = sum(powers_info_transmission);
total_system_energy_consumed(round) = total_energy - sum(E);
[round_metric_iaf1(round), round_metric_iaf2(round)] = calculate_metric_with_interest(powers_info_transmission, E_i, clusters, clusterheads);
end
metric_iaf1 = cumsum(round_metric_iaf1);
metric_iaf2 = cumsum(round_metric_iaf2);
total_power_info_transmission = cumsum(round_power_info_transmission);
disp('Number of rounds the process was repeated');
disp(round);
end