optimizer
diapason.learning.optimize.optimizer
¶
OptimizationEngine -- orchestrates the optimize loop.
Ties together the LLM optimizer, trial runner, and persistence store into a single propose -> evaluate -> analyze -> repeat loop.
OptimizationEngine
¶
Orchestrates the optimize loop: propose -> evaluate -> analyze -> repeat.
export_best_recipe(run, path)
¶
Export the best trial's config as a TOML recipe file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
OptimizationRun
|
A completed :class: |
required |
path
|
Path
|
Destination path for the TOML file. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The path written to. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no best trial in the run. |
run(progress_callback=None)
¶
Execute the full optimization loop.
- Generate a run_id via uuid.
llm_optimizer.propose_initial()-> first config.- Loop up to
max_trials: a.trial_runner.run_trial(config)-> TrialResult b.llm_optimizer.analyze_trial(config, summary, traces)c. Update TrialResult with analysis text d. Append to history e. If store,store.save_trial(result)f. Update best_trial if accuracy improved g. Check early stopping (no improvement for patience trials) h. If not stopped,llm_optimizer.propose_next(history) - Set run status to
"completed". - If store,
store.save_run(optimization_run). - Return the :class:
OptimizationRun.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress_callback
|
Optional[Callable[[int, int], None]]
|
Optional |
None
|
compute_pareto_frontier(trials, objectives)
¶
Compute the Pareto frontier: trials not dominated by any other.
A trial A dominates trial B if A is >= B on all objectives and > B on at least one (direction-aware: maximize flips the comparison).