merge_summary - morinim/ultra GitHub Wiki
merge_summary.py is a small command-line utility designed to merge two ULTRA experiment summaries into a single consolidated XML report. It is useful when multiple independent batches of runs need to be aggregated while preserving statistical consistency and maintaining compatibility with the C++ tools in the ULTRA framework.
The script performs the following tasks:
-
XML parsing and validation. It loads two
<ultra>XML files, extracts their<summary>blocks, verifies that required tags exist, and collects all relevant metrics (run count, elapsed time, success rate, distribution statistics, best solution information, and per-run solution list); - statistical merging. The utility recomputes: the combined number of runs, the total elapsed time, the run-weighted success rate, the pooled mean fitness, the unbiased pooled standard deviation using the same formula as the C++ implementation. This ensures that merged statistics are mathematically correct and consistent across runs;
- best-solution selection. The script compares the best solution from each input file and selects the globally best one. When this comes from the second file, run indices are properly offset so that the merged numbering remains consistent;
- merging solution lists. The list of solution run numbers is concatenated, with the second file's entries offset by the first file's run count.
-
checksum generation (CRC32). The utility mirrors the C++ checksum logic: a
<checksum>tag is temporarily set to zero, the XML is serialised, the CRC32 checksum (ISO 3309 / IEEE 802.3 polynomial) is computed using Python'szlib.crc32, which matches the C++ implementation, the checksum is injected back into the final XML output; - output. The final signed XML is written to the file indicated on the command line. The script preserves formatting through indentation and produces a fully valid ULTRA summary file that downstream tools can process transparently.
python3 merge_summary.py summary1.xml summary2.xml merged.xml