Expand description
LP Parser - A Linear Programming File Parser
This crate provides robust parsing capabilities for Linear Programming (LP) files using nom parser combinators. It supports multiple industry-standard LP file formats and offers comprehensive features for optimization problems.
§Features
- Zero-copy parsing with lifetime management
- Support for multiple LP file format specifications
- Comprehensive parsing of all standard LP file components
- Optional serialization and diff tracking
§Quick Start
use std::path::Path;
use lp_parser::{parser::parse_file, LpProblem};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let content = parse_file(Path::new("problem.lp"))?;
let problem = LpProblem::parse(&content)?;
println!("Problem name: {:?}", problem.name());
Ok(())
}
§Module Organization
model
: Core data structures for LP problemsparser
: File parsing utilitiesparsers
: Component-specific parserslp_problem
: Main problem representation and parsing
Modules§
- csv
- model
- Core data structures for representing Linear Programming problems.
- parser
- File I/O and content parsing utilities.
- parsers
- This module provides a collection of specialized parsers for different elements of LP files. Each sub module handles a specific aspect of the LP format, working together to provide comprehensive parsing capabilities.
- problem
- Main problem representation and parsing logic.
Macros§
- impl_
section_ parser - Macro to implement the SectionParser trait.
Constants§
- ALL_
BOUND_ HEADERS - All possible section headers that can appear in an LP file’s bounds section.
- BINARY_
HEADERS - Headers that indicate the beginning of a binary variable section.
- CONSTRAINT_
HEADERS - Headers that indicate the beginning of a constraint section in an LP file.
- END_
HEADER - Header marking the end of an LP file or section.
- GENERAL_
HEADERS - Headers that indicate the beginning of a general integer variable section.
- INTEGER_
HEADERS - Headers that indicate the beginning of an integer variable section.
- SEMI_
HEADERS - Headers that indicate the beginning of a semi-continuous variable section.
- SOS_
HEADERS - Headers that indicate the beginning of a Special Ordered Set (SOS) constraint section.
- VALID_
LP_ FILE_ CHARS - Valid characters that can appear in LP file elements.
Functions§
- is_
binary_ section - Checks if the input string starts with a binary section header.
- is_
bounds_ section - Checks if the input string starts with a bounds section header.
- is_
generals_ section - Checks if the input string starts with a generals section header.
- is_
integers_ section - Checks if the input string starts with a integers section header.
- is_
semi_ section - Checks if the input string starts with a semi-continuous section header.
- is_
sos_ section - Checks if the input string starts with a SOS constraints section header.