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 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 problems
  • parser: File parsing utilities
  • parsers: Component-specific parsers
  • lp_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.