rustplex 0.2.0

A linear programming solver based on the Simplex algorithm for Rust
Documentation
  • Coverage
  • 8.06%
    15 out of 186 items documented0 out of 144 items with examples
  • Size
  • Source code size: 130.41 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 25.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • ร˜ build duration
  • this release: 20s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mohsenpakzad/rustplex
    9 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mohsenpakzad

Rustplex

Crates.io Version Crates.io Page Downloads

A fast and efficient Linear Programming (LP) Solver implemented in Rust, designed to solve optimization problems using the Simplex Algorithm.

โœจ Features

  • Fast & Efficient: Optimized implementation of the Simplex Algorithm for solving LP problems.
  • User-Friendly API: Designed for ease of use with a clean and intuitive API.
  • Custom Constraints & Objectives: Define your own constraints and objective functions effortlessly.
  • Scalable & Reliable: Suitable for large-scale linear programming problems.

๐Ÿš€ Installation

install via Cargo:

cargo add rustplex

  • Implements the two-phase simplex method for solving LP problems efficiently.

  • Detects and handles infeasible or unbounded problems.

  • Configurable Solver:

    • Supports custom tolerances and iteration limits via SolverConfig.
    • Offers robust numerical stability by accounting for floating-point precision errors.
  • Extensible Slack Dictionary:

    • Efficiently manages basic and non-basic variables.
    • Allows pivot operations and tracks the objective function dynamically.
  • Detailed Solutions:

    • Provides optimal values for decision variables.
    • Reports solver status (optimal, infeasible, unbounded, or iteration limit reached).

Roadmap / TODO

Planned features and improvements for future releases:

  • Comprehensive Documentation: Add detailed API references, architectural explanations, and practical examples to improve usability and understanding.

  • Multi-thread Architecture: Implement parallel processing for faster solving of large-scale problems.

  • Integer & Mixed-Integer Programming (MIP): Add branch-and-bound support for integer and mixed-integer variables.

Usage

Input Requirements

The solver expects an LP problem in standard form, including:

  1. An objective function to maximize or minimize.
  2. A set of constraints.
  3. Decision variable bounds.

Example

Here is an example of how to set up and solve an LP problem:

use rustplex::{ConstraintSense, Model, ObjectiveSense};

fn main() {
    let mut model = Model::new();

    let x1 = model.add_variable().with_name("x1").with_lower_bound(0.0);
    let x2 = model.add_variable().with_name("x2").with_lower_bound(0.0);
    let x3 = model.add_variable().with_name("x3").with_lower_bound(0.0);

    model.set_objective(
        ObjectiveSense::Maximize,
        &x1 + &x2 + &x3,
    );

    model
        .add_constraint(&x1, ConstraintSense::LessEqual, 10)
        .with_name("constr1");

    model
        .add_constraint(&x2 + &x3, ConstraintSense::LessEqual, 5)
        .with_name("constr2");

    if model.solve().is_ok() {
        println!("{}", model.solution());
    }
}

Output:

Solver Status: Optimal
Objective Value: 10.00
Variable Values: [
        Var(x2): 2.00
        Var(x3): 3.00
        Var(x1): 5.00
]
Iterations: 3
Solve Time: 18.10ยตs

๐Ÿ›  Contributing

Contributions are welcome! Feel free to fork, submit issues, or open pull requests.

๐Ÿ“„ License

This project is licensed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-MIT and LICENSE-APACHE for details.


Developed with โค๏ธ in Rust.