Skip to main content

Crate lp_parser_rs

Crate lp_parser_rs 

Source
Expand description

LP Parser - A Linear Programming File Parser

This crate provides robust parsing capabilities for Linear Programming (LP) files using LALRPOP parser generator. It supports multiple industry-standard LP file formats and offers comprehensive features for optimisation problems.

§Features

  • Owned, interned problem model (no lifetimes) built from a zero-copy grammar
  • Support for multiple LP file format specifications
  • Comprehensive parsing of all standard LP file components
  • Writers for both LP (writer) and MPS (mps::writer) output
  • Optional serialisation (serde) and a structural/numeric diff engine (diff, behind the diff feature)

§Quick Start

use lp_parser_rs::LpProblem;

let input = "\
Minimize
 obj: 2 x + 3 y
Subject To
 c1: x + y >= 10
Bounds
 0 <= x <= 40
End";

let problem = LpProblem::parse(input)?;
assert_eq!(problem.variable_count(), 2);
assert_eq!(problem.constraint_count(), 1);

To read from disk, use parser::parse_file to load the file contents (memory-mapped with the mmap feature) and pass them to LpProblem::parse or LpProblem::parse_mps.

Re-exports§

pub use diff::DiffOptions;
pub use diff::DiffTol;
pub use diff::LpDiff;
pub use diff::Normaliser;
pub use error::LpParseError;
pub use error::LpResult;
pub use interner::NameId;
pub use interner::NameInterner;
pub use lexer::ParseResult;
pub use mps::extract_mps_name;
pub use mps::parse_mps;
pub use problem::LpProblem;

Modules§

analysis
Analysis and statistics for Linear Programming problems.
assemble
Assembly of flat LP section bodies into raw objectives/constraints. Assembly of flat objective/constraint element lists into raw model types.
compat
Compatibility adapters for external solver crates.
csv
CSV export: write problem components to per-section .csv files.
diff
Structural and numeric diff engine for two LpProblems (behind the diff feature). Structural and numeric diff engine for two parsed LpProblems.
error
Error types returned by the parsers (LpParseError, LpResult).
interner
String interning for LP problem names.
lexer
Lexer for LP files using Logos.
lp
model
Core data structures for representing Linear Programming problems.
mps
MPS file format parser.
parser
File reading helpers (plain or memory-mapped with the mmap feature).
problem
The LpProblem model: parse entry points and mutation API.
writer
LP file writing and formatting utilities.