PPO Clipped Objective
Compute the PPO clipped surrogate objective.
The PPO clip objective for a single sample:
where r_t = π_θ(a|s) / π_old(a|s) is the probability ratio, A_t is the advantage, and ε is the clip range.
Input:
- Line 1: epsilon (clip range)
- Line 2: N (number of samples)
- Next N lines: ratio advantage
Output: Average clipped objective, rounded to 4 decimal places.
Example
0.2 3 1.5 1.0 0.8 -0.5 1.0 2.0
1.1833
- The clip range is set to , which means the clipped ratio will be between and .
- For each sample, we calculate the clipped surrogate objective :
- For the first sample, , , so .
- For the second sample, , , so .
- For the third sample, , , so .
- We then calculate the average clipped objective: .
- The final output is , rounded to 4 decimal places.
Constraints
- 0.1 <= epsilon <= 0.3
- 1 <= N <= 50
- The objective should be MAXIMIZED (we output positive for good updates)
- Round to 4 decimal places