Ockham - OR toolkit
comprehensive OR toolkit for LP, optimization & math modeling in rust. provides efficient, numerically stable algorithms w/ clean API.
features
- performance: optimized simplex solver w/ multiple pivot rules
- intuitive API: builder pattern for easy problem construction
- variable types: continuous, int & binary vars
- robust numerics: scaling, presolve & validation utils
- extensible: plugin arch for custom solvers
- comprehensive: detailed diagnostics & solution analysis
- pure rust: memory-safe, concurrent & cross-platform
Quick Start
Add Ockham to your Cargo.toml:
[]
= "0.1.0"
Basic Example
use *;
Examples
The repository includes several detailed examples:
- Basic LP: Simple linear programming problem
- Production Planning: Resource allocation optimization
- Diet Problem: Cost minimization with nutritional constraints
Run examples with:
🏗️ Problem Modeling
Variables
use *;
let mut builder = new;
// Continuous variables
builder = builder.add_variable?; // Bounded
builder = builder.add_non_negative_variable?; // Non-negative
builder = builder.add_free_variable?; // Unbounded
// Integer variables
builder = builder.add_integer_variable?; // Integer
builder = builder.add_binary_variable?; // Binary (0 or 1)
Constraints
// Using variable names (recommended)
builder = builder.add_constraint_by_name?;
// Using coefficient vectors
builder = builder.add_constraint?;
// Named constraints for debugging
builder = builder.add_named_constraint?;
Objectives
// Maximize profit
builder = builder.objective_by_name?;
// Minimize cost with constant term
let objective = new_with_constant?;
Advanced Features
Presolve
Automatically simplify problems before solving:
let presolve = new;
let result = presolve.apply?;
println!;
Scaling
Improve numerical stability:
let scaling = new;
let scaled_problem = scaling.apply?;
Custom Solver Configuration
let config = new
.with_max_iterations
.with_optimality_tolerance
.verbose
.with_option;
let solution = solve_with_config?;
Problem Validation
let validator = new;
let validation = validator.validate;
if !validation.is_valid
Solver Algorithms
Simplex Method
- Two-phase method for handling artificial variables
- Multiple pivot rules: Most negative, first negative, steepest edge
- Degeneracy handling with Bland's anti-cycling rule
- Numerical stability with careful pivot selection
Future Algorithms
- Interior Point Methods
- Branch and Bound (for integer programming)
- Cutting Plane Methods
- Heuristic Algorithms
Performance
Ockham is designed for performance:
- Efficient data structures minimize memory allocation
- SIMD optimizations for linear algebra operations (optional)
- Parallel processing support (optional)
- Benchmark suite for performance regression testing
Run benchmarks:
Features Flags
default = ["serde"]serde: Serialization support for problems and solutionsparallel: Parallel processing with Rayonlinalg: Advanced linear algebra with nalgebra
License
Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)