]> Piment Noir Git Repositories - freqai-strategies.git/commit
refactor(ReforceXY): PBRS refactoring, bug fix, and documentation harmonization
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 23 Dec 2025 19:13:18 +0000 (20:13 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 23 Dec 2025 19:13:18 +0000 (20:13 +0100)
commite938a3036f284f69073182ee51aedcab01258a31
treef721b61a2499dc85b204466aa3e3e966cc399f4a
parentc9283b19b8798074c0b38bb41d2278b9df2f4244
refactor(ReforceXY): PBRS refactoring, bug fix, and documentation harmonization

This commit includes three major improvements to the PBRS implementation:

1. Bug Fix: idle_factor calculation
   - Fixed incorrect variable reference in reward_space_analysis.py:625
   - Changed 'factor' to 'base_factor' in idle_factor formula
   - Formula: idle_factor = base_factor * (profit_aim / risk_reward_ratio) / 4.0
   - Also fixed in test_reward_components.py and ReforceXY.py

2. Refactoring: Separation of concerns in PBRS calculation
   - Renamed apply_potential_shaping() → compute_pbrs_components()
   - Removed base_reward parameter from PBRS functions
   - PBRS functions now return only shaping components
   - Caller responsible for: total = base_reward + shaping + entry + exit
   - Kept deprecated wrapper for backward compatibility
   - Updated ReforceXY.py with parallel changes
   - Adapted tests to new function signatures

3. Documentation: Complete mathematical notation harmonization
   - Achieved 100% consistent notation across both implementations
   - Standardized on Greek symbols: Φ(s), γ, Δ(s,a,s')
   - Eliminated mixing of word forms (Phi/gamma/Delta) with symbols
   - Harmonized docstrings to 156-169 lines with identical theory sections
   - Added cross-references between implementations
   - Fixed all instances of Δ(s,s') → Δ(s,a,s') to include action parameter

Files modified:
- reward_space_analysis/reward_space_analysis.py: Core refactoring + docs
- user_data/freqaimodels/ReforceXY.py: Parallel refactoring + docs
- tests/components/test_additives.py: Adapted to new signature
- tests/components/test_reward_components.py: Bug fix
- tests/api/test_api_helpers.py: Adapted to new signature

All 50 tests pass. Behavior preserved except for intentional bug fix.
ReforceXY/reward_space_analysis/reward_space_analysis.py
ReforceXY/reward_space_analysis/tests/api/test_api_helpers.py
ReforceXY/reward_space_analysis/tests/components/test_additives.py
ReforceXY/reward_space_analysis/tests/components/test_reward_components.py
ReforceXY/user_data/freqaimodels/ReforceXY.py