Add optimize_responses (Tool 4) for DOE response optimization#74
Merged
Conversation
Implement the response optimization engine for designed experiments: - Model evaluation layer: parse coefficient terms and evaluate polynomial at arbitrary coded points (the glue between Tool 3 and the optimizer) - Stationary point analysis via numpy.linalg.solve on second-order models - Canonical analysis via eigenvalue decomposition of the B matrix - Steepest ascent/descent path generation from first-order coefficients - Derringer-Suich desirability functions (maximize, minimize, target) with weighted geometric mean composite and scipy SLSQP multi-start - Stubs for ridge analysis and Pareto front (planned for later) - Public dispatcher optimize_responses() routing to all methods https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Register optimize_responses as an agent-callable tool with full JSON schema for LLM integration. The tool accepts fitted model coefficients, optimization goals, and method selection, dispatching to the core optimization module. Also export optimize_responses from the experiments __init__.py. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Initial test file for Tool 4 (optimize_responses) with reusable model coefficient fixtures for quadratic, linear, saddle, and minimum models, plus tests for the internal _parse_term function. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Test polynomial evaluation at known points (origin, corners) for both linear and quadratic models, plus verify correct extraction of the b vector and symmetric B matrix from coefficient lists. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Test classification (maximum, minimum, saddle), eigenvalue extraction, coded-to-actual conversion, and error handling for linear models that lack quadratic terms. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Verify direction vectors, step counts, monotonic response increase for ascent, coded-to-actual conversion, and error on zero coefficients. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Cover maximize, minimize, target desirability functions, individual desirability dispatch, and composite (weighted geometric mean) with edge cases (zero values, empty list, weight effects). https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Test end-to-end desirability optimisation (single and multi-response), stub methods returning proper status, dispatcher routing for all methods, validation errors, and tool wrapper JSON round-trip. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Mark Tool 4 as partially implemented with desirability, steepest ascent/descent, stationary point, and canonical analysis. Ridge analysis and Pareto front remain as stubs. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
Remove unused noqa directives, add strict=True to zip() calls, replace ternary with or operator, add PLR0913 noqa for functions with many args, and add docstrings to all test methods to satisfy D102 rule. https://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement Tool 4 (
optimize_responses) — find optimal factor settings for one or multiple responses after fitting a model withanalyze_experiment(Tool 3).Implemented methods
numpy.linalg.solveIntercept,A,A:B,I(A ** 2)) and evaluate the polynomial at arbitrary coded points (the glue between Tool 3 output and the optimizer)Stubs (planned for later)
Changes
process_improve/experiments/optimization.py— Complete rewrite replacing legacy MATLAB skeleton (~500 lines)process_improve/experiments/tools.py— Newoptimize_responsestool wrapper with full JSON schema for LLM integrationprocess_improve/experiments/__init__.py— Exportoptimize_responsestests/test_optimization.py— 74 unit tests covering all methods, desirability functions, dispatcher, validation, and tool wrapperdocs/doe/coverage.md— Updated status from "Not started" to "Partial"Test plan
pytest tests/test_optimization.py -v)ruff checkpasses on all modified filesoptimize_responsesin experiments categoryhttps://claude.ai/code/session_01Br5mDwaoXvGsaQJZLS5oCV