Skip to content

Warn on silently dropped quadratic/self-interaction terms in DoE formulas#765

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-silent-failure-quadratic-terms
Draft

Warn on silently dropped quadratic/self-interaction terms in DoE formulas#765
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-silent-failure-quadratic-terms

Conversation

Copilot AI commented May 20, 2026

Copy link
Copy Markdown

Formulaic drops non-braced quadratic/self-interaction terms like x**2, x*x, and x:x during parsing, which made DoE model term counts wrong without any signal to the user. This change adds targeted detection and warnings so risky formulas are surfaced early in both strategy utilities and DoE criterion validation.

  • AST-based risky pattern detection

    • Added Formulaic AST traversal to detect patterns that are commonly dropped silently:
      • operators outside the supported set for this context (e.g. ** not wrapped in {...})
      • self-interactions (x*x, x:x) that collapse under Formulaic grammar
    • Emits a UserWarning with concrete remediation: wrap intended nonlinear terms in {...}.
  • Warnings in both entry points

    • bofire/strategies/doe/utils.py (get_formula_from_string)
    • bofire/data_models/strategies/doe.py (DoEOptimalityCriterion.validate_formula)
    • This closes the silent-failure gap whether formulas come from strategy execution paths or data-model validation paths.
  • Focused coverage for warning semantics

    • Added/updated unit tests to assert warnings are raised for risky unbraced terms and not raised for braced equivalents.
from bofire.strategies.doe.utils import get_formula_from_string

# warns: may be silently reduced by Formulaic
get_formula_from_string(model_type="1 + x1 + x1**2")

# no warning: explicit nonlinear intent
get_formula_from_string(model_type="1 + x1 + {x1**2}")

Copilot AI changed the title [WIP] Fix silent failure for model_type strings with quadratic terms Warn on silently dropped quadratic/self-interaction terms in DoE formulas May 20, 2026
Copilot AI requested a review from rosonaeldred May 20, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: silent failure for model_type strings whose quadratic terms are not separated by {}'s

2 participants