A method of allocating resource by UAV-assisted federated learning, applied on an environment comprising a unmanned aerial vehicle (UAV) and user devices, and the UAV as an airborne base station is combined with federated learning, comprising:
- S1. determining a total cost function and constraints of a system based on total energy consumption of user devices that participate in the federated learning and an inverse of a number of the user devices, and constructing an optimization problem P with a minimization of the total cost function;
- S2. solving by the optimization problem P to obtain an optimal horizontal position of the (UAV), an optimal local accuracy, an optimal user resource allocation decision, and an optimal altitude of the UAV;
- and
- S3. controlling the UAV to fly to the optimal horizontal position and the optimal altitude of the UAV, and the user devices within a coverage range of the UAV determining to participate in the federated learning based on the optimal user resource allocation decision and the optimal local accuracy to upload neural network model parameters related to the data, and
- a main server securely aggregating the neural network model parameters and feed the neural network model parameters back to the user devices within the coverage range of the UAV for updating a global model according to the dataset owned by the user devices within the coverage range of the UAV;
- wherein the S1, constructing the optimization problem P for minimizing the total cost function, comprises:
- S11. a set of user devices is denoted as N=={1, 2 . . . N}, a set of the user devices within the coverage range of the UAV is denoted as Nm;
- a distance between the user device i and the UAV is:
- dim=√{square root over (h2+∥qm−qi∥22)};
- where h denotes the altitude of the UAV, qm={xm,ym} denotes a horizontal position of the UAV, qi={xi,yi} denotes a position of the user device i, and a channel gain of the user device i is:
- g
- i
- =
- g
- 0
- (
- d
- im
- d
- 0
- )
- -
- α
- ;
- where g0 is a channel interference power at timed d0=1 m and α is a path loss exponent;
- S12. energy consumption of the user device during the federated learning comprises training energy and communication energy;
- S13. Di denotes an amount of data of the user device, fi denotes a number of revolutions per second of a CPU of the user device i, Ci denotes a number of revolutions of the CPU of the user device i to process a sample data, and Il denotes a number of rounds of local training when a local accuracy is achieved η;
- I
- l
- =
- 2
- (
- 2
- -
- L
-
- δ
- )
-
- δ
-
- y
-
- log
-
- (
- 1
- η
- )
- ;
- wherein L, γ are relevant parameters about a neural network loss function, δ is a training learning step of the federated learning;
- training energy consumption Eicomp of the user device i in one iteration of the federated learning is denoted as:
- Eicomp=κIlCiDifi2;
- S14. after the user completes the local training, a trained model is uploaded to the UAV by a frequency division multiple access (FDMA);
- bi denotes a bandwidth allocated to the user device i, p, denotes a transmission power of the user device i, N0 denotes a noise power spectral density, and according to a Shannon's formula an achievable transmission rate Ri of the user device i is:
- R
- i
- =
- b
- i
-
- log
- 2
- (
- 1
- +
- g
- i
-
- p
- i
- N
- 0
-
- b
- i
- )
- ;
- assuming that a size of data of the neural network model w is s and communication energy consumption Eicomp of the user device i is:
- E
- i
- comm
- =
- p
- i
-
- t
- i
- =
- p
- i
-
- s
- b
- i
-
- log
- 2
- (
- 1
- +
- g
- i
-
- p
- i
- N
- 0
-
- b
- i
- )
- ;
- S15. when a global model accuracy is required to be achieved ε0 a number of communication rounds Ig is:
- I
- g
- =
- 2
-
- L
- 2
- γ
- 2
-
- ξ
-
- log
-
- 1
- ε
- 0
-
- 1
- 1
- -
- η
- ;
- where ξ denotes relevant parameters in a local neural network training, a total energy consumption Etotal of a whole federated learning process is:
- E
- total
- =
- I
- g
-
- ∑
- i
- ∈
- N
- m
- ❘
- "\[LeftBracketingBar]"
- N
- m
- ❘
- "\[RightBracketingBar]"
- (
- E
- i
- comm
- +
- E
- i
- comp
- )
- ;
- S16. the total cost function C is defined as:
- C
- =
- E
- total
- +
- ρ
-
- 1
- N
- m
- ;
- a target function is:
- min
- q
- m
- ,
- h
- ,
- f
- ,
- t
- ,
- p
- ,
- n
- ,
- η
- C
- =
- min
- q
- m
- ,
- h
- ,
- f
- ,
- t
- ,
- p
- ,
- b
- ,
- η
- a
- (
- 1
- -
- η
- )
-
- (
- ∑
- i
- ∈
- N
- m
- ❘
- "\[LeftBracketingBar]"
- N
- m
- ❘
- "\[RightBracketingBar]"
- log
-
- (
- 1
- η
- )
-
- vC
- i
-
- D
- i
-
- f
- i
- 2
- +
- t
- i
-
- p
- i
- )
- +
- ρ
- N
- m
- ;
- wherein
- a
- =
- 2
-
- L
- 2
- γ
- 2
-
- ζ
-
- log
-
- 1
- ε
- 0
- and
- v
- =
- 2
- (
- 2
- -
- L
-
- δ
- )
-
- δγ
- denote fixed values and ρ denotes a weighting factor;
- S17. considering the total energy consumption of the user devices and a performance of federated learning, the optimization problem P of the system is:
- min
- q
- m
- ,
- h
- ,
- f
- ,
- t
- ,
- p
- ,
- b
- ,
- η
- a
- (
- 1
- -
- η
- )
-
- (
- ∑
- i
- ∈
- N
- m
- ❘
- "\[LeftBracketingBar]"
- N
- m
- ❘
- "\[RightBracketingBar]"
- log
-
- (
- 1
- η
- )
-
- vC
- i
-
- D
- i
-
- f
- i
- 2
- +
- t
- i
-
- p
- i
- )
- +
- ρ
- N
- m
- ;
- the constraints are:
- 0
- ≤
- f
- i
- ≤
- f
- i
- max
- C
-
- 1
- 0
- ≤
- p
- i
- ≤
- p
- i
- max
- C
-
- 2
- I
- g
- (
- t
- i
- +
- I
- l
-
- C
- i
-
- D
- i
- f
- i
- )
- ≤
- T
- C
-
- 3
- t
- i
- ≥
- s
- R
- i
- C
-
- 4
-
- q
- m
- -
- q
- i
-
- 2
- 2
- ≤
- r
- 2
- C
-
- 5
- h
- min
- ≤
- h
- ≤
- h
- max
- C
-
- 6
- ∑
- i
- ∈
- N
- m
- |
- N
- m
- |
- b
- i
- ≤
- B
- ,
- b
- i
- >
- 0
- C
-
- 7
- 0
- ≤
- η
- ≤
- 1
- ;
- C
-
- 8
- where T is a total pre-estimated completion time of the federated learning, B denotes a total bandwidth owned by the UAV, fimax denotes a maximum computation frequency of the user device i, pimax denotes a maximum transmission power of the user device i, and, hmin and hmax denote a minimum altitude and a maximum altitude of the UAV for flying, respectively;
- under a constraint of a maximum delay allowed by the federated learning, a position of the UAV, the transmission power p=[p1, . . . pNm] and a computation frequency f=[f1, . . . fNm] of the user device i, a transmission bandwidth b=[b1, . . . bNm], transmission time t=[t1 . . . tNm] and the local accuracy η are optimized jointly to minimize the target function;
- constraints C1 and C2 limit the computation frequency and the transmission power of the user device i;
- a constraint C3 denotes that a total delay of the user devices that participate in the federated learning is not greater than a preset maximum value;
- a constraint C4 limits the transmission delay, and Ri is the achievable transmission rate of the user device i;
- a constraint C5 limits the position of the UAV m and the distance between the user device and the UAV not greater than the coverage range of the UAV;
- a constraint C6 limits a flight altitude range of the UAV;
- the constraint C7 indicates that a sum of the bandwidth allocated to all user devices within the coverage range of the UAV is not greater than a total bandwidth B;
- and the constraint C8 specifies a range of constraints on the local training accuracy.