From 2eb73c5d2521633d5738dbf19c3bad5b77fcfd9d Mon Sep 17 00:00:00 2001 From: Anto01 Date: Mon, 17 Nov 2025 21:34:52 -0500 Subject: [PATCH] fix: Parse LLM design variable bounds correctly and save workflow config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIXES: 1. Parameter Range Parsing Bug - LLM returns bounds as [min, max] array, but code was looking for 'min'/'max' keys - This caused all parameters to default to 0-1 range instead of actual mm values - Example: "20 to 30 mm" was being used as 0.2-1.0mm instead of 20-30mm 2. Missing Workflow Documentation - Added automatic saving of LLM workflow config to output directory - Creates llm_workflow_config.json with complete optimization setup - Includes design variables, bounds, objectives, constraints, engineering features Changes: - optimization_engine/llm_optimization_runner.py: * Lines 205-211: Parse 'bounds' array from LLM output * Lines 80-84: Save workflow config JSON for transparency * Maintains backward compatibility with old 'min'/'max' format Test Results: BEFORE: - beam_half_core_thickness: 0.27-0.95mm (WRONG!) - beam_face_thickness: 0.07-0.73mm (WRONG!) AFTER: - beam_half_core_thickness: 20.16-28.16mm (CORRECT!) - beam_face_thickness: 21.69-24.73mm (CORRECT!) E2E test now passes with realistic parameter values and proper documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- optimization_engine/llm_optimization_runner.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/optimization_engine/llm_optimization_runner.py b/optimization_engine/llm_optimization_runner.py index e5e25598..bf491825 100644 --- a/optimization_engine/llm_optimization_runner.py +++ b/optimization_engine/llm_optimization_runner.py @@ -77,6 +77,12 @@ class LLMOptimizationRunner: self.output_dir = Path(output_dir) self.output_dir.mkdir(parents=True, exist_ok=True) + # Save LLM workflow configuration for transparency and documentation + workflow_config_file = self.output_dir / "llm_workflow_config.json" + with open(workflow_config_file, 'w') as f: + json.dump(llm_workflow, f, indent=2) + logger.info(f"LLM workflow configuration saved to: {workflow_config_file}") + # Initialize automation components self._initialize_automation() @@ -201,8 +207,14 @@ class LLMOptimizationRunner: design_vars = {} for var_config in design_vars_config: var_name = var_config['parameter'] - var_min = var_config.get('min', 0.0) - var_max = var_config.get('max', 1.0) + + # Parse bounds - LLM returns 'bounds' as [min, max] + if 'bounds' in var_config: + var_min, var_max = var_config['bounds'] + else: + # Fallback to old format + var_min = var_config.get('min', 0.0) + var_max = var_config.get('max', 1.0) # Suggest value using Optuna design_vars[var_name] = trial.suggest_float(var_name, var_min, var_max)