Skip to content

Rust LP file Parser

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

dandxy89/lp_parser_rs

Repository files navigation

LP File Parser

Cargo Test Crates.io Documentation

Overview

Logo

A robust Rust parser for Linear Programming (LP) files, built on the PEST parsing framework. This crate provides comprehensive support for parsing and analyzing LP files according to major industry specifications.

Supported Specifications

Features

Core Functionality

  • Problem Definition

    • Problem name and sense specification
    • Single and multi-objective optimization support
    • Comprehensive constraint handling
  • Variable Support

    • Integer variables
    • General variables
    • Bounded variables (lower, upper, or both)
    • Free variables
    • Semi-continuous variables
    • Special Ordered Sets (SOS)

Advanced Features

  • LP File Comparison (diff feature)

    • Compare two LP files to identify:
      • Added elements
      • Removed elements
      • Modified components
    • Useful for model version control and validation
  • Serialization (serde feature)

    • Full serialization support for all model structures
    • Compatible with various data formats
    • Enables integration with other tools and systems

Quick Start

Installation

Add to your Cargo.toml:

[dependencies]
lp_parser_rs = "x.y.z"

Basic Usage

Clone and run with a sample file:

git clone https://github.com/dandxy89/lp_parser_rs.git
# Dissemble a single LP file
cargo run --release -- {{ /path/to/your/file.lp }}
# Compare two LP files (enabling the 'diff' feature)
cargo run --release --features diff -- {{ /path/to/your/file.lp }} {{ /path/to/your/other/file.lp }}

Enable Optional Features

[dependencies]
lp_parser_rs = { version = "x.y.z", features = ["serde", "diff"] }

Development

Testing

The project uses snapshot testing via insta for reliable test management:

# Run all tests with all features enabled
cargo insta test --all-features

# Review snapshot changes
cargo insta review

Test Data Sources

The test suite includes data from various open-source projects:

Contributors

Special thanks to our contributors:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.