Skip to content

Conversation

@david-r-cox
Copy link
Member

Summary

This PR adds support for CPLEX MIP (Mixed Integer Programming) and QP
(Quadratic Programming) extensions to the MPS parser, while updating the build
infrastructure from cargo2nix to naersk.

Key Changes

Parser Enhancements

  • MIP/QP Support: Added parsers for CPLEX-specific sections:

    • OBJSENSE/OBJNAME/REFROW for objective function control
    • USERCUTS for user-defined cutting planes
    • SOS (Special Ordered Sets) with S1/S2 types
    • INDICATORS for indicator constraints
    • LAZYCONS for lazy constraints
    • QSECTION/QUADOBJ/QMATRIX/QCMATRIX for quadratic programming
    • CSECTION for second-order cone constraints
    • BRANCH for branching priorities and directions
  • Format Improvements:

    • Strict CPLEX section ordering enforcement (NAME → OBJSENSE → ... → ENDATA)
    • Support for flexible whitespace-separated parsing alongside fixed-column format
    • Better comment handling (lines starting with *)
    • Improved line ending support (Unix \n and Windows \r\n)
    • More robust error messages with context snippets instead of full file dumps

Data Types

  • New ObjectiveSense enum (Min/Max)
  • Extended BoundType with BV (binary), LI (lower integer), UI (upper integer), SC
    (semi-continuous)
  • New types: IndicatorLine, LazyConstraintLine, QuadraticObjectiveTerm, SOSLine,
    ConeConstraint, BranchPriority, etc.
  • IndexMap replaces HashMap for deterministic serialization (~10% perf gain)

Build System

  • Nix Flake: Switched from cargo2nix to naersk for simpler, more maintainable builds
  • Dependencies: Updated to latest stable versions
    • clap: 4.4 → 4.5
    • color-eyre: 0.6.2 → 0.6
    • hashbrown: 0.14.3 → 0.15 (now with indexmap 2.0)
    • insta: 1.34 → 1.41
    • proptest: 1.4 → 1.9

Testing

  • Comprehensive unit tests for all new section parsers
  • Integration test covering all section types in correct CPLEX order
  • Tests verifying QMATRIX vs QSECTION equivalence
  • Indicator constraint format validation
  • SOS section ordering enforcement

Spec Compliance

Implements full CPLEX MPS format specification with strict section ordering and support for
all documented extensions. Parser now handles both standard optimization problems and
complex MIP/QP formulations.

Breaking Changes

  • Parser struct now includes new optional fields for MIP/QP sections
  • Bound type parsing now supports 8 types instead of 4
  • HashMap replaced with IndexMap in internal model structures

- Add flexible line ending support (Unix/Windows)
- Support both strict and flexible column formatting
- Handle comments and empty lines throughout file
- Add support for unknown MPS sections (INDICATORS, LAZYCONS, etc)
- Handle MARKER lines in COLUMNS section
- Improve error messages with context preview
- Support inline comments with $ delimiter
@david-r-cox david-r-cox merged commit 6173a34 into main Nov 8, 2025
4 checks passed
@david-r-cox
Copy link
Member Author

Fixes #17

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.

1 participant