All Projects → rust-or → good_lp

rust-or / good_lp

Licence: MIT license
Linear Programming for Rust, with an user-friendly API. This crate allows modeling LP problems, and let's you solve them with various solvers.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to good lp

rcbc
COIN-OR branch and cut (CBC) bindings for R
Stars: ✭ 16 (-79.22%)
Mutual labels:  linear-programming, cbc
gibbous
Convex optimization for java and scala, built on Apache Commons Math
Stars: ✭ 17 (-77.92%)
Mutual labels:  optimization, linear-programming
siconos
Simulation framework for nonsmooth dynamical systems
Stars: ✭ 120 (+55.84%)
Mutual labels:  optimization, solvers
Gosl
Linear algebra, eigenvalues, FFT, Bessel, elliptic, orthogonal polys, geometry, NURBS, numerical quadrature, 3D transfinite interpolation, random numbers, Mersenne twister, probability distributions, optimisation, differential equations.
Stars: ✭ 1,629 (+2015.58%)
Mutual labels:  optimization, linear-programming
rust-lp-modeler
Lp modeler written in Rust
Stars: ✭ 75 (-2.6%)
Mutual labels:  linear-programming, lp-modeler
flipy
A Python linear programming interface library
Stars: ✭ 23 (-70.13%)
Mutual labels:  linear-programming, cbc
noisyopt
Python library for optimizing noisy functions.
Stars: ✭ 73 (-5.19%)
Mutual labels:  optimization
dopt
A numerical optimisation and deep learning framework for D.
Stars: ✭ 28 (-63.64%)
Mutual labels:  optimization
okama
Investment portfolio and stocks analyzing tools for Python with free historical data
Stars: ✭ 87 (+12.99%)
Mutual labels:  optimization
mader
Trajectory Planner in Multi-Agent and Dynamic Environments
Stars: ✭ 252 (+227.27%)
Mutual labels:  optimization
Windows11-Optimization
Community repository, to improve security and performance of Windows 10 and windows 11 with tweaks, commands, scripts, registry keys, configuration, tutorials and more
Stars: ✭ 17 (-77.92%)
Mutual labels:  optimization
studio
GAMS Studio
Stars: ✭ 25 (-67.53%)
Mutual labels:  optimization
cplex-example
Solving a TSP with the CPLEX C++ API.
Stars: ✭ 40 (-48.05%)
Mutual labels:  optimization
fastnumbers
Super-fast and clean conversions to numbers.
Stars: ✭ 85 (+10.39%)
Mutual labels:  optimization
DotNet.SystemCollections.Analyzers
A set of code analyzers & code fix providers to help developers use the proper .NET Collection & API in their algorithms
Stars: ✭ 72 (-6.49%)
Mutual labels:  optimization
modest-py
FMI-compliant Model Estimation in Python
Stars: ✭ 40 (-48.05%)
Mutual labels:  optimization
RazorHtmlMinifier.Mvc5
↘️ Trivial compile-time Razor HTML Minifier for ASP.NET MVC 5.
Stars: ✭ 31 (-59.74%)
Mutual labels:  optimization
profiling
Non-discriminatory profiling of Ruby code leveraging the ruby-prof gem
Stars: ✭ 12 (-84.42%)
Mutual labels:  optimization
ultraopt
Distributed Asynchronous Hyperparameter Optimization better than HyperOpt. 比HyperOpt更强的分布式异步超参优化库。
Stars: ✭ 93 (+20.78%)
Mutual labels:  optimization
SumOfSquares.jl
Sum of Squares Programming for Julia
Stars: ✭ 96 (+24.68%)
Mutual labels:  optimization

good_lp

A Mixed Integer Linear Programming modeler that is easy to use, performant with large problems, and well-typed.

Crates.io documentation MIT license

use std::error::Error;

use good_lp::{constraint, default_solver, Solution, SolverModel, variables};

fn main() -> Result<(), Box<dyn Error>> {
    variables! {
        vars:
               a <= 1;
          2 <= b <= 4;
    } // variables can also be added dynamically
    let solution = vars.maximise(10 * (a - b / 5) - b)
        .using(default_solver) // multiple solvers available
        .with(constraint!(a + 2 <= b))
        .with(constraint!(1 + a >= 4 - b))
        .solve()?;
    println!("a={}   b={}", solution.value(a), solution.value(b));
    println!("a + b = {}", solution.eval(a + b));
    Ok(())
}

Features and limitations

  • Linear programming. This crate currently supports only the definition of linear programs. You cannot use it with quadratic functions. For instance: you can maximise 3 * x + y, but not 3 * x * y.
  • Continuous and integer variables. good_lp itself supports mixed integer-linear programming (MILP), but not all underlying solvers support integer variables.
  • Not a solver. This crate uses other rust crates to provide the solvers. There is no solving algorithm in good_lp itself. If you have an issue with a solver, report it to the solver directly. See below for the list of supported solvers.

Contributing

Pull requests are welcome ! If you need a feature that is not yet implemented, get in touch. Also, do not hesitate to open issues to discuss the implementation.

Alternatives

If you need non-linear programming, you can use lp-modeler. However, it is currently very slow with large problems.

You can also directly use the underlying solver libraries, such as coin_cbc or minilp if you don't need a way to express your objective function and constraints using an idiomatic rust syntax.

Usage examples

You can find a resource allocation problem example in resource_allocation_problem.rs.

Solvers

This library offers an abstraction over multiple solvers. By default, it uses cbc, but you can also activate other solvers using cargo features.

solver feature name integer variables no C compiler* no additional libs** fast
coin_cbc
highs
lpsolve
minilp
lp-solvers
  • * no C compiler: builds with only cargo, without requiring you to install a C compiler
  • ** no additional libs: works without additional libraries at runtime, all the dependencies are statically linked

To use an alternative solver, put the following in your Cargo.toml:

good_lp = { version = "*", features = ["your solver feature name"], default-features = false }

cbc

Used by default, performant, but requires to have the cbc C library headers available on the build machine, and the cbc dynamic library available on any machine where you want to run your program.

In ubuntu, you can install it with:

sudo apt-get install coinor-cbc coinor-libcbc-dev

In MacOS, using homebrew :

brew install cbc

minilp

minilp is a pure rust solver, which means it works out of the box without installing anything else.

Minilp is written in pure rust, so you can use it without having to install a C compiler on your machine, or having to install any external library, but it is slower than other solvers.

It performs very poorly when compiled in debug mode, so be sure to compile your code in --release mode when solving large problems.

HiGHS

HiGHS is a free (MIT) parallel mixed integer linear programming solver written in C++. It is able to use OpenMP to fully leverage all the available processor cores to solve a problem.

good_lp uses the highs crate to call HiGHS. You will need a C compiler, but you shouldn't have to install any additional library on linux (it depends only on OpenMP and the C++ standard library). More information in the highs-sys crate.

lpsolve

lp_solve is a free (LGPL) linear (integer) programming solver written in C and based on the revised simplex method.

good_lp uses the lpsolve crate to call lpsolve. You will need a C compiler, but you won't have to install any additional library.

lp-solvers

The lp-solvers feature is particular: it doesn't contain any solver. Instead, it calls other solvers at runtime. It writes the given problem to a .lp file, and launches an external solver command (such as gurobi, cplex, cbc, or glpk) to solve it.

There is some overhead associated to this method: it can take a few hundred milliseconds to write the problem to a file, launch the external solver, wait for it to finish, and then parse its solution. If you are not solving a few large problems but many small ones (in a web server, for instance), then this method may not be appropriate.

Additionally, the end user of your program will have to install the desired solver on his own.

License

This library is published under the MIT license. The solver themselves have various licenses, please refer to their individual documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].