From 9ce6a4e6ec7f1eae1a99ba213cfc1f4c6f3e5fc3 Mon Sep 17 00:00:00 2001 From: TPTBusiness Date: Sun, 31 May 2026 17:49:49 +0200 Subject: [PATCH] fix: ML trigger priority over Optuna (2000 % 500 == 0 collision) --- scripts/nexquant_rd_loop.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/nexquant_rd_loop.py b/scripts/nexquant_rd_loop.py index 0103ad3f..654bc920 100644 --- a/scripts/nexquant_rd_loop.py +++ b/scripts/nexquant_rd_loop.py @@ -242,16 +242,14 @@ class ResearchLoop: def hypothesize(self): self.iteration += 1 + # Every 2000 iterations: train ML model (check before Optuna, higher priority) + if self.iteration % 2000 == 0 and len(self.sota) >= 5: + return {'type': 'ml', 'generation': 'ml', + 'description': f"ML: LightGBM on {len(self.sota)} strategies", + 'sota': self.sota[:5]} + # Every 500 iterations: Optuna-optimize best strategy if self.iteration % 500 == 0 and self.sota: - best = self.sota[0] - hp = dict(best['hypothesis']) - hp['generation'] = 'optuna' - hp['description'] = f"Optuna: {hp.get('description','?')}" - return hp - - # Every 2000 iterations: train ML model - if self.iteration % 2000 == 0 and len(self.sota) >= 5: return {'type': 'ml', 'generation': 'ml', 'description': f"ML: LightGBM on {len(self.sota)} strategies", 'sota': self.sota[:5]}