8000 Competitor comparison: FlahaX vs Horticalc, PHREEQC, pyEQL and an Irriblend-method baseline (#40) by rafatahmed · Pull Request #63 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

Competitor comparison: FlahaX vs Horticalc, PHREEQC, pyEQL and an Irriblend-method baseline (#40) - #63

Merged
rafatahmed merged 5 commits into
mainfrom
benchmark/competitor-comparison
Oct 20, 2026
Merged

rafatahmed merged 5 commits into
mainfrom
benchmark/competitor-comparison

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

Closes #40.

A pinned, reproducible comparison of FlahaX with other open tools on shared inputs, published as a versioned evidence snapshot on Read the Docs (docs/site/evidence/competitor-comparison.md). Results unfavourable to FlahaX are kept.

Tools

Tool Pin Role
Horticalc v0.6.7, commit db4e68c formulation (as shipped and aligned), EC
PhreeqPython (IPhreeqc) 1.6.2 chemistry reference, EC
pyEQL 1.7.0 EC
Irriblend-DSW method independent LP after Gallego-Elvira et al. 2021 formulation baseline; not the authors' code (no licence declared, request sent)

pyfarm-nutrients is excluded, since it calibrates EC heuristically and does not formulate. All of these tools are development-only (benchmarks/competitors/requirements.txt plus constraints.txt). FlahaX runtime dependencies stay empty.

Results (snapshot 2026-10-21-competitors-ed568c5)

Formulation, 52 recipes re-scored by the Benchmark v1 evaluator. "Acceptable" adds incidental limits: Cl and Na ≤ 3 mmol/L, NH4-N ≤ min(10 % N, 1.5 mmol/L), micronutrients ≤ 2× target.

Engine Meets targets Acceptable Median time
FlahaX recommend + Cl ceiling 41 41 56.5 ms
FlahaX recommend 34 34 60.1 ms
Irriblend method 48 34 1.5 ms
FlahaX single fit 23 23 3.5 ms
Horticalc aligned 47 7 3.4 ms
Horticalc as shipped 0 0 4.5 ms

Chemistry.

  • Live PHREEQC replays the stored 3.8.6 rows to within 1.9e-9.
  • FlahaX passes 21/21 fixtures (1,534 checks).
  • FlahaX is faster than PHREEQC through PhreeqPython on 14/21 fixtures. It is 4–14× slower on the three chelate-rich mixtures.

EC against the IUPAC molality-based KCl primary standards (Pratt et al. 2001):

  • 0.01 mol/kg: FlahaX +1.08 %, Horticalc +1.08 %, PHREEQC −0.86 %, pyEQL −1.28 %.
  • FlahaX declines 0.1 and 1.0 mol/kg (Davies I ≤ 0.1).
  • On the catalogue recipes (agreement only, no measured EC), FlahaX and PHREEQC agree within 3.5 %. The non-speciating tools differ by −11 % to +17 %.

Changes from the approved design

  • EC standards: I used the IUPAC per-kilogram values (1408.23 / 12 824.6 / 108 620 µS/cm) instead of the commercial per-litre 146.9 / 1413 / 12 880, which have no primary source. The transcription is tested against the paper's Table 2 polynomial.
  • PHREEQC conductivity database: PHREEQC conductivity uses PhreeqPython's bundled phreeqc.dat, because minteq.v4.dat has no diffusion coefficients.

Harness bugs found and fixed while building it

  • IPhreeqc keeps SOLUTION_SPECIES/PHASES between inputs, so mixed_product_phases corrupted later fixtures (struvite). The database is now reloaded per fixture.
  • The replay metric was relative on the convergence residuals (charge, pct_err). Log quantities now compare absolutely, molalities relatively above 1e-20, and the residuals are not compared.
  • Acid-target fixtures replay their _target input, as the golden test does.

The comparison also found the solver slowdown fixed in #61 / #62. These results were measured after #62.

Files

  • benchmarks/competitors/: the three tracks, Horticalc adapter, README/protocol, pins.
  • tests/fixtures/condu 8000 ctivity/iupac2001_kcl_table1.json, with provenance.
  • tests/test_competitor_benchmark.py: offline tests, no competitor packages needed.
  • tools/publish_competitor_snapshot.py: copies the outputs byte for byte, adds the environment record and a checksummed zip, and refuses a commit whose src/ or benchmarks/ differ from HEAD.
  • docs/site/evidence/competitor-comparison.md and its snapshot; linked from the evidence toctree and from Benchmark v1.

Verification

  • 366 tests pass (1 skipped, as on main).
  • The Sphinx build is clean with no warnings.
  • The evidence tests check checksums, that downloads match zip members, and that no local paths are published.

… baseline

Development-only harness under benchmarks/competitors (never imported by
flahax). Every engine gets the same 30-product catalogue, 26 formulas and
two waters; each recipe is re-scored by the Benchmark v1 evaluator.

- Horticalc pinned at v0.6.7 (db4e68c), run as shipped and aligned
  (separate N forms, S objective). The catalogue translation inverts
  Horticalc's own conversion rules (max error 3.6e-16).
- Irriblend-DSW has no licence, so the baseline is an independent LP
  after the published method (exact NO3/NH4/P/K/micros, Ca/Mg/S at or
  above target, minimum grams), labelled as not the authors' code.
- A second scoreboard counts recipes that meet every target AND stay
  within agronomic limits: incidental Cl and Na <= 3 mmol/L (De Kreij et
  al. 2003), NH4-N <= min(10% of N, 1.5 mmol/L), micronutrients <= 2x.
- Timings: best of three, engines interleaved per case.
Runs each fixture's own PHREEQC input (the _target input for acid-target
captures) through PhreeqPython's embedded IPhreeqc on the pinned, merged
minteq.v4 database, replays the live rows against the stored PHREEQC 3.8.6
rows, then scores FlahaX with Benchmark v1's evaluate_chemistry at the live
prescribed pH.

The database is reloaded for every fixture: IPhreeqc keeps SOLUTION_SPECIES
and PHASES from earlier inputs, and mixed_product_phases redefines ammonium
species, which had corrupted later fixtures (struvite). Replay compares log
quantities absolutely and molalities relatively above 1e-20; charge and
pct_err are convergence residuals and are not compared.
…KCl standards

Accuracy is scored against the IUPAC molality-based primary standards
(Pratt, Koch, Wu and Berezansky 2001, Pure Appl. Chem. 73, 1783, Table 1,
KCl 0.01/0.1/1.0 mol/kg at 25 C), transcribed into a fixture with its
provenance. Catalogue recipes are compared for agreement only (no measured
EC): every tool gets the same macronutrient totals, phosphate as H2PO4- for
the tools that do not speciate. PHREEQC uses PhreeqPython's bundled
phreeqc.dat, since minteq.v4.dat has no diffusion coefficients.
README gives the tool pins, licences, track protocols and run commands.
requirements.txt pins the direct development tools and constraints.txt the
full environment of the run. Tests cover the IUPAC transcription (checked
against the paper's own Table 2 polynomial), replay scoring, acid-target
input selection, EC input mapping and the incidental-ion limits, without
the competitor packages installed.
Snapshot 2026-10-21-competitors-ed568c5: formulation, chemistry and EC
track outputs from one run at ed568c5 (after #62), with the environment
record and a checksummed evidence.zip. tools/publish_competitor_snapshot.py
refuses a commit whose src/ or benchmarks/ differ from HEAD. The new
evidence page reports every engine, including results unfavourable to
FlahaX; the Benchmark v1 page links to it.
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 Flahax | 🛠️ Build #35283146 | 📁 Comparing aba952c against latest (06b0fce)

  🔍 Preview build  

2 files changed
+ evidence/competitor-comparison.html
± evidence/benchmark-v1.html

@rafatahmed
rafatahmed merged commit 61dda09 into main Oct 20, 2026
6 checks passed
@rafatahmed
rafatahmed deleted the benchmark/competitor-comparison branch October 20, 2026 22:46
@rafatahmed rafatahmed self-assigned this Oct 23, 2026
rafatahmed added a commit that referenced this pull request Nov 7, 2026
Competitor comparison: FlahaX vs Horticalc, PHREEQC, pyEQL and an Irriblend-method baseline (#40)
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.

Implement a new objective-aligned competitor comparison

1 participant

0