4.3.2. Phase 2: Initial Pre-Filling Phase
The objective of this phase is to accelerate the convergence process and improve the overall performance of the system. The technique adopted in this phase is initial pre-filling, where the main idea is to populate the ERB before starting the actual training process. In the conventional approach, DDPG algorithm begins to converge only after its ERB has been filled to its total capacity. This initial delay in convergence can lead to a slower overall optimization process, ultimately affecting the algorithm’s overall performance, particularly in situations where quick convergence is essential. To address this problem, this paper performs ERB initialization prior to training by pre-collecting experiences.
At the beginning, the agent selects actions randomly from the action space within the predefined bounds. The reason for using random actions initially is to ensure sufficient.
Exploration and to generate a diverse and unbiased set of experiences that cover different regions of the state–action space. After this prefilling step, the KNN algorithm is employed [
46]. KNN is chosen because of its simplicity, effectiveness in capturing local similarities, and its ability to approximate values based on neighboring samples without requiring complex training. In this paper, KNN receives the current normalized state
as input and produces the corresponding action
by identifying the
most similar states stored in ERB. An inverse-distance weighting scheme is applied so that closer neighbors have a greater influence on the selected action, allowing more relevant experiences to contribute more significantly to the decision. The weighted average of KNN action at time slot
is computed as:
where
represents the action of the
nearest neighbor at time slot
,
denotes the distance to that neighbor, and
is the KNN neighbors. After the KNN algorithm predicts an action
for each new normalized state
. The reward
is then calculated using (21) with
, and the next state
is obtained. The corresponding transition
is stored in the ERB. At the same time, both the state and action datasets are updated iteratively.
As shown in
Figure 4, this pre-filling phase is executed only once, continuing until the ERB reaches its full capacity. Once the ERB is filled, the training process for the proposed PAW-DDPG algorithm begins, using the pre-filled, state-aware experiences to improve learning stability and convergence efficiency.
4.3.3. Phase 3: Training and Updating Phase
The main objective of this phase is to enhance the agent’s performance by improving exploration capability, learning efficiency, and overall training stability and convergence. The proposed PAW-DDPG algorithm relies on four networks: the actor network
, which generates a deterministic action
based on the current normalized state
; the critic network
, which evaluates this action by estimating its Q-value; and their corresponding target networks
,
, which contribute to stabilizing the learning process. Although the actor produces deterministic actions, effective exploration remains essential to avoid convergence to suboptimal solutions. For this reason, noise is incorporated during training to encourage broader exploration of the action space and improve policy learning. After executing the action in the environment, both processing delay and energy consumption are obtained. These represent conflicting objectives and therefore require adaptive weighting consistent with the dynamic nature of the environment to determine the appropriate trade-off between them. The reward is then computed using (21). The next normalized state is also obtained. In each time slot
, the transition
is stored in ERB. Sampling mechanism from this ERB plays a critical role in stabilizing training [
43].
All the exploration, reward function design, and sampling optimization methods significantly influence convergence behavior, learning stability, and overall system performance; therefore, enhancing these components is essential, and the following in this sub-subsection presents the improvements introduced to optimize their effectiveness.
- 1.
Exploration optimization sub-phase
The objective of this sub-phase is to enhance the exploration capability of the proposed PAW-DDPG algorithm, which in turn improves convergence and consequently enhances the overall performance of the PAW-DDPG algorithm. In the conventional approaches, exploration is achieved by adding only Gaussian noise [
42]. However, relying solely on Gaussian noise introduces purely random fluctuations that may lead to oscillatory behavior in the search trajectory. These random perturbations can cause instability, slow down convergence, and negatively affect the algorithm’s overall performance. To address this limitation, a hybrid noise strategy is proposed by combining Gaussian noise with Ornstein–Uhlenbeck (OU) noise. While Gaussian noise promotes broad and unbiased exploration due to its independent random distribution, OU noise introduces temporal correlation that generates smoother and more consistent exploratory movements [
47]. The action space after adding hybrid noise is defined as:
where
,
represents the OU noise and Gaussian noise, respectively, and
and
are weighting coefficients that control the contribution of each noise. The OU noise follows the stochastic differential equation:
where
is the rate of mean reversion,
is the mean value and
controls the volatility of the process. The Gaussian noise component is sampled from a normal distribution as follows:
where
is the standard deviation that determines the magnitude of the noise.
By integrating both types of noise, the algorithm benefits from both diverse global exploration (via Gaussian noise) and stable, correlated local exploration (via OU noise). Compared to using each noise type independently, the proposed combined noise approach reduces oscillations, improves convergence stability, accelerates convergence speed, and ultimately enhances the overall performance.
- 2.
Adaptive weights update sub-phase
The purpose of this sub-phase is to improve stability and convergence by selecting optimal reward weights for delay and energy consumption. In RL–based optimization problems, especially in dynamic environments, the reward function often combines multiple conflicting objectives. In our paper, delay and energy consumption are weighted to balance performance and efficiency. Selecting appropriate weights is critical because they directly influence the agent’s learning direction, convergence speed, and overall system performance.
However, traditional methods typically rely on fixed or manually tuned weights. In dynamic environments, where network conditions, and resource availability vary over time, sudden or arbitrary weight selection can lead to unstable learning behavior. Abrupt changes in weights may cause oscillations in the reward signal, slow convergence, or even divergence. Moreover, poorly chosen weights may bias the agent excessively toward minimizing either delay or energy consumption, resulting in suboptimal performance. Such instability negatively affects policy convergence and reduces adaptability to environmental changes.
To address this problem, we adopt the EMA algorithm to adaptively determine the reward weights [
48]. EMA provides a smooth and responsive mechanism for updating weights based on recent observations while still retaining historical information. Unlike abrupt or heuristic-based tuning methods, EMA ensures gradual transitions in weight values, which enhances learning stability and prevents sudden reward fluctuations. We select EMA over other adaptive methods because it is computationally efficient, easy to implement, and well-suited for real-time dynamic systems. Additionally, EMA inherently filters noise in the observed delay and energy metrics, contributing to more stable policy updates.
The weights for delay and energy consumption are selected at each episode and then applied across all time slots within that episode. This approach is a key design choice because it shifts the learning and optimization process to the episode level rather than operating independently at each time slot. The main advantage of this design is improved stability and convergence, especially in dynamic environments where per time-slot updates can introduce high variance and instability in learning.
Initially, all weights are assigned equal values to ensure a fair and unbiased starting point. These equal weights are then used during the first episode to evaluate baseline performance under consistent conditions. After completing the first episode, the EMA algorithm begins to refine the weights based on the observed outcomes, gradually improving performance over time.
After each episode, the current delay and energy are compared to their EMAs to calculate relative gaps, which quantify how much each metric deviates from its recent trend. These gaps are then compared, and the metric with the larger gap is considered worse, indicating that it requires more focus. Using this approach, the system adaptively prioritizes between delay and energy according to their relative performance, allocating resources to enhance the weaker metric. EMA and relative gap equations are represented as follows:
where
is the EMA smoothing factor that controls how much weight is given to the current observation compared to the past average, ep denotes episode, and
is a small constant to avoid division by zero.
Once the gaps are calculated, they are passed through a sigmoid function, which bounds extreme values between 0 and 1. This ensures that unusually large deviations do not dominate the weight calculation, creating a more stable adjustment process. The sigmoid function is applied as:
The resulting values are then used to compute target weights for processing delay and energy consumption as follows:
Before updating the weights, the EMA algorithm is enhanced by using soft update and momentum mechanisms to improve stability and learning efficiency during training. The main objective of these mechanisms is to gradually adjust the contribution of each weight according to the desired target behavior while avoiding sudden fluctuations that may negatively affect performance. Soft update mechanism is used as smoothing step. Instead of abruptly replacing the current weight with a new target value, the update blends the old value with the target using a smoothing factor
. This is computed as:
where
=
= 0.5.
After that, momentum mechanism was introduced as an optimization mechanism that speeds up learning and stabilizes updates by combining the current gradient with a fraction of previous updates. Instead of relying only on the latest change, it accumulates past gradients, allowing the updates to maintain direction, move more smoothly, and converge faster with fewer oscillations:
where
is the momentum coefficient. Together, these two mechanisms enhance convergence speed, improve robustness, and produce more reliable weight adjustments in dynamic environments.
- 3.
Prioritized sampling sub-phase
The main objective of this sub-phase is to select a representative mini-batch of experiences from the ERB to improve learning efficiency, convergence speed, and overall system performance. An effective sampling method ensures that the most informative experiences contribute more significantly to the training process. The PAW-DDPG algorithm starts by using the normalized state as input to produce the corresponding action. Hybrid noise is then added to the action before executing it in the environment. Once the action is performed, the reward was computed by applying a weighted sum to the delay and energy consumption values, using weights obtained from the previous sub-phase. The next state, which is also normalized, is also obtained. This transition is then stored in the ERB for future learning. These stored transitions form the ERB, from which samples are drawn to update the actor and critic networks.
The purpose of sampling from ERB is to break the temporal correlation between consecutive experiences and to reuse past interactions to improve data efficiency. In traditional ERB, transitions are sampled uniformly at random. While this approach stabilizes training compared to pure online updates, it treats all transitions as equally important. However, some experiences particularly those with large TD errors contain more learning information than others. Uniform random sampling may therefore slow convergence, as important transitions might be selected infrequently, reducing the speed at which the value function approximates the optimal solution.
To address this limitation, PER assigns higher sampling probability to transitions with larger TD errors [
43,
46]. The TD error represents the difference between the predicted Q-value and the updated target Q-value. It is mathematically defined as:
where
is the Q value of the target critic network, which was computed in (23) and
is the Q value of the output of the critic network. A large TD error indicates that the network’s prediction was inaccurate, meaning the transition carries significant learning information.
Instead of uniform sampling, each transition
at each time slot
is assigned a priority
, defined as:
where
is the TD error of transition
,
is used to ensure that each experience has a nonzero probability of being selected, and
controls how strongly priorities affect sampling, where
ignores priorities completely and samples experiences uniformly at random and
results in full prioritization based entirely on priority values [
43].
The probability of sampling transition
at each time slot
is then computed as:
where
refers to all stored transitions in ERB. By focusing on high-error transitions, PER accelerates error correction in the value function, which improves convergence speed and learning stability.
To correct the sampling bias introduced by prioritization, importance-sampling (IS) weights are utilized during gradient updates, which expressed as:
where
is the replay buffer size, and
is a correction parameter that gradually increases to 1 to fully correct the bias.
After sample
mini-batch, the critic network is updated at each time slot
using a weighted mean squared error loss:
where
is the batch size.
After the critic update, it guides the update of the actor network, encouraging the actor to select actions that maximize the expected reward according to the critic. The actor network is updated at each time slot
through the deterministic policy gradient as follows:
To further stabilize training and improve convergence, the critic target network and actor target network softly updated by using a small constant
as follows:
Algorithm 2 outlines the PAW-DDPG-based computation offloading and UAV trajectory control in UAV-assisted MEC system. The PAW-DDPG algorithm begins by initializing its networks: actor, critic, target actor, and target critic networks. After that, an initial pre_filling phase is performed, where the ERB is filled with more informative samples using the KNN algorithm in step 3. This step continues until the ERB is filled. Once the ERB is full, this step is terminated and is not revisited again. In the subsequent steps, the entire training process is carried out. The initial step is to determine the weights according to the EMA algorithm, starting with 0.5 and 0.5. The current state is normalized in step 9 and fed into the actor network, which outputs an action. Hybrid noise is then added to this action to generate the final action in step 10, which includes user scheduling, partial-task offloading and UAV trajectory and then executed in the environment, along with the next state in step 11. As a result, delay and energy are obtained, and from them the reward is calculated using the EMA weights values using (21) in step 12. The transition
are then stored in ERB with a priority in step 14. In steps 15–19, samples are selected from ERB using PER, and the networks are updated accordingly. At the end of each episode, the reward weights are dynamically computed in steps 21–26. These steps are repeated starting from step 5 until the training process is completed.
Figure 5 depicts the proposed PAW-DDPG framework architecture, showing all the complete phases that were discussed.
| Algorithm 2: PAW-DDPG-based computation offloading and UAV trajectory control |
| Input: Training episode length , training sample length , learning rates for actor and critic networks , discount factor , soft update rate , ERB capacity, KNN parameters, hybrid noise weights , mini-batch size , EMA parameters. |
Steps:- 1.
Initialize the weights of actor network and critic network , respectively - 2.
Initialize the target networks with weights and , respectively - 3.
Initialize the ERB:
Collect some random state–action pairs Build a KNN algorithm from these samples While the ERB is not full:
- ○
Obtain the current normalized state - ○
If there are sufficient samples available, apply KNN to choose an action. If not, choose it random - ○
Store transition in the ERB - ○
Add the new state–action pair to the KNN dataset
Start training once the ERB is filled
- 4.
Initialize adaptive weights - 5.
for each episode do - 6.
and - 7.
Reset the environment and obtain the initial state - 8.
for
do - 9.
Normalize the current state: = normalize state )
- 10.
Get an action with hybrid noise using Equation (27) - 11.
Execute and move to next state - 12.
Compute delay and energy consumption and obtain reward using Equation (21)
- 13.
Normalize the next state to obtain
- 14.
Store transition in the ERB with priority - 15.
Sample a mini batch of transitions according to the PER probabilities using Equation (44) - 16.
Compute target Q-values using Equation (23) - 17.
Update the critic network by minimizing the loss using Equation (46) - 18.
Update the actor network using the policy-gradient using Equation (47) - 19.
Update the target networks using the soft update rule using Equations (48) and (49) - 20.
end for - 21.
Compute EMA of delay and energy using Equations (30) and (31) - 22.
Compute relative performance gaps using Equations (32) and (33) - 23.
Apply a sigmoid to convert gaps into stable, bounded importance scores using Equations (34) and (35) - 24.
Build target weights from above importance scores using Equations (36) and (37) - 25.
Apply a soft update to smooth weights using Equations (38) and (39) - 26.
Enhance the weight update using momentum using Equations (40) and (41) - 27.
end for
|