#linear-programming #simplex #lp-solver

rustplex

A linear programming solver based on the Simplex algorithm for Rust

1 unstable release

0.1.0 Feb 6, 2025

#508 in Algorithms

Download history 72/week @ 2025-01-31 61/week @ 2025-02-07

133 downloads per month

MIT/Apache

85KB
2K SLoC

Rustplex

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

๐Ÿ›  Usage

use rustplex::core::{constraint::ConstraintSense, model::Model, objective::ObjectiveSense};

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

    let x1 = model.add_variable().name("x1").bounds(1.0..=5.0);
    let x2 = model.add_variable().name("x2").upper_bound(2.0);
    let x3 = model.add_variable().name("x3");

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

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

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

    model.solve();

    println!("{}", model.get_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.

No runtime deps