A Rust-powered linear programming library for Python.

Overview

Dantzig logo

Dantzig: A Rust-powered LP library for Python

Documentation Status PyPI Checked with mypy Code style: black Imports: isort License: MIT

Dantzig is a lightweight and concise linear programming solver suitable for small and large-scale problems alike.

Dantzig is implemented in both Rust and Python, meaning you get the expressiveness and flexibility of a Python frontend plus the raw computing speed of a Rust backend.

Dantzig supports

  • A solver featuring a parametric self-dual algorithm
  • Arbitrarily restricted variables, including completely unrestricted free variables
  • ==, <=, and >= constraints
  • Both minimization and maximization problems
  • A numerically stable LU factorization with partial pivoting routine for robust linear algebra operations
  • Memory-efficient sparse matrix representations
  • Modern Python type-checking

⚠️ Dantzig is under active development. Please help us improve the library by reporting any issues!

Installation

Dantzig supports Python 3.10+ and can be installed with pip.

pip install dantzig 

Design Philosophies

Dantzig prides itself on being both lightweight (zero-dependency) and concise. The API is designed to be extremely expressive and terse, saving you keystrokes without sacrificing clarity. To this end, Dantzig provides several short aliases for common classes and methods.

A few examples are listed below,

  • Var == Variable
  • Min == Minimize
  • Max == Maximize
  • Var.free() == Variable(lb=0.0, ub=0.0)
  • Var.nn() == Var.nonneg() == Variable(lb=0.0, ub=None)
  • Var.np() == Var.nonpos() == Variable(lb=None, ub=0.0)

Examples

import dantzig as dz

x = dz.Variable(lb=0.0, ub=None)
y = dz.Variable(lb=0.0, ub=None)
z = dz.Variable(lb=0.0, ub=None)

soln = dz.Minimize(x + y - z).subject_to(x + y + z == 1).solve()

assert soln.objective_value == -1.0
assert soln[x] == 0.0
assert soln[y] == 0.0
assert soln[z] == 1.0

Using aliases, the previous example can alternately be written

from dantzig import Min, Var

x = Var.nn()
y = Var.nn()
z = Var.nn()

soln = Min(x + y - z).st(x + y + z == 1)

Road Map

  • Mixed integer linear programing (MILP)
  • SIMD-accelerated linear algebra operations
  • General optimizations to make the library competitive with ortools
  • Improved documentation
You might also like...
The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language.

rcc The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language. Compilers Language Co

Game Boy Emulator written in Rust, as a way to fully grasp the Rust programming language

Flan's Game Boy Emulator Game Boy Emulator written in Rust, as a way to get hands-on with the Rust programming language, and creating a proper project

A minimal version of 'grep' implemented in Rust. Exercise in the "The Rust Programming Language" book.

Minigrep - A simple grep-like tool implemented in Rust This simple CLI tool searches for a given pattern in a specified file and as a result, it print

Nixt is an interpreted programming language written in Rust

Nixt Nixt is an interpreted lisp inspired programming language written in Rust Index About Examples Installation Build About Nixt goal is to provide a

a function programming language for real world applications made in rust

a function programming language for real world applications made in rust

Rust implementation of µKanren, a featherweight relational programming language.

µKanren-rs This is a Rust implementation of µKanren, a featherweight relational programming language. See the original Scheme implementation here for

Aspect-oriented programming in Rust

Aspect Oriented Programming (AOP) for Rust The needs of AOP Aspect-oriented programming (AOP) is a programming paradigm that aims to increase modulari

This repository contains the source of "The Rust Programming Language" book.

The Rust Programming Language This repository contains the source of "The Rust Programming Language" book. The book is available in dead-tree form fro

A short exercise to introduce people to the Rust programming language

Searching primes by brute force This code is ment to be an exercice to teach rust and give a first impression on how to work with the language during

Owner
Matteo Santamaria
Soon enough we'll all be speaking Python
Matteo Santamaria
x86-64 Malware Crypter built in Rust for Windows with Anti-VM, powered by memexec

Rust Crypter x86-64 Malware Crypter built in Rust for Windows with Anti-VM, powered by memexec Usage Put your Portable Executable in /crypt/ and renam

Daniel Ballard 10 May 28, 2023
Super-simple, fully Rust powered "memory" (doc store + semantic search) for LLM projects, semantic search, etc.

memex Super simple "memory" for LLM projects, semantic search, etc. Running the service Note that if you're running on Apple silicon (M1/M2/etc.), it'

Spyglass Search 15 Jun 19, 2023
Functional Reactive Programming library for Rust

Carboxyl is a library for functional reactive programming in Rust, a functional and composable approach to handle events in interactive applications.

Emilia Bopp 379 Dec 25, 2022
Rust library to facilitate event-driven programming.

Squeak Squeak is a zero-dependency Rust library to facilitate event-driven programming. Examples use squeak::{Delegate, Response}; let on_damage_rece

Antoine Gersant 58 Dec 31, 2022
Cogo is a high-performance library for programming stackful coroutines with which you can easily develop and maintain massive concurrent programs.

Cogo is a high-performance library for programming stackful coroutines with which you can easily develop and maintain massive concurrent programs.

co-rs 47 Nov 17, 2022
A fast uuid generator in Python using Rust

ruuid A fast UUID generator for Python built using Rust. Its a simple wrapper on top of Rust's UUID crate. How to use? Installation: pip3 install ruui

Rahul Nair 19 Jul 13, 2022
Write Anchor-compatible Solana programs in Python

seahorse: Write Solana programs in Python The ease of Python with the safety of Rust. Seahorse lets you write Solana programs in Python. It is a commu

✨ amelia chen ✨ 214 Dec 28, 2022
CSGO demo parser for Python

CSGO demo parser for Python Demo parser for Counter-Strike: Global Offensive. Parser is used to collect data from replay files (".dem" files). The goa

null 11 Dec 7, 2022
Utilities for converting Vega-Lite specs from the command line and Python

VlConvert VlConvert provides a Rust library, CLI utility, and Python library for converting Vega-Lite chart specifications into static images (SVG or

Vega 24 Feb 13, 2023
clone of grep cli written in Rust. From Chapter 12 of the Rust Programming Language book

minigrep is a clone of the grep cli in rust Minigrep will find a query string in a file. To test it out, clone the project and run cargo run body poem

Raunak Singh 1 Dec 14, 2021