Add idempotence tests for export/import serialization#263
Merged
Conversation
Contributor
- Add 3 helper functions for deep Solution comparison - Add 7 idempotence test cases (4 JSON, 3 JLD2) - Test double and triple export-import cycles - Verify no progressive information loss - Add comprehensive analysis and documentation All 1721 tests pass. Closes #217
- Add infos_symbol_keys metadata field to track Symbol values - Implement path-based Symbol restoration during deserialization - Update _serialize_infos and _deserialize_infos to handle Symbol tracking - Fix type conversion issues with JSON3.Array using collect() - Update test expectations to verify Symbol preservation - All 1722 tests pass Closes part of #217
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.
Add idempotence tests for export/import serialization
Summary
This PR adds comprehensive idempotence tests for the
export_ocp_solutionandimport_ocp_solutionfunctions to verify that multiple export-import cycles produce stable results with no progressive information loss.Changes
Test Implementation (~460 lines)
Helper Functions (
test/suite/serialization/test_export_import.jl):compare_trajectories: Compares function-based trajectories at time pointscompare_infos: Deep comparison ofDict{Symbol,Any}with type awarenesscompare_solutions: Comprehensive Solution object comparison with configurable tolerancesNew Test Cases (7 total):
Documentation
Analysis:
reports/2026-01-29_Idempotence/analysis/01_serialization_idempotence_analysis.mdImplementation Plan:
reports/2026-01-29_Idempotence/reference/01_serialization_idempotence_plan.mdWalkthrough:
reports/2026-01-29_Idempotence/walkthrough.mdTest Results
✅ All tests pass - No regressions
Key Findings
Information Preserved ✅
Expected Transformations 🔄
Functions → Discretization: Analytical functions become interpolated after JSON export/import
atol=1e-8)Symbols → Strings: Symbols in
infosbecome strings after JSON serialization:optimal→"optimal"Conclusion
No progressive information loss:
sol₁ ≈ sol₂ ≈ sol₃after multiple cycles.Future Work
The analysis identified areas for future investigation:
ctinterpolate/ctdeinterpolatefor lossless function serializationdeepcopyusage inbuild_solution(rationale unclear)See analysis document for details.
Related Issue
Closes #217