Crate ockham

Crate ockham 

Source
Expand description

§Ockham - OR toolkit

comprehensive OR toolkit for LP, optimization & math modeling in rust

§Features

  • Linear Programming: simplex solver w/ 2-phase method
  • Problem Modeling: builder pattern for easy problem construction
  • Variable Types: continuous, int, binary vars
  • Error Handling: comprehensive error types & validation
  • Numerical Stability: scaling, presolve, validation utils
  • Solver Framework: extensible solver trait for diff algorithms
  • Diagnostics: detailed solver stats & solution info

§Quick Start

use ockham::prelude::*;

// simple LP: max 3x + 2y s.t. x + y <= 10, x,y >= 0
let problem = ProblemBuilder::new()
    .add_non_negative_variable("x")?
    .add_non_negative_variable("y")?
    .add_constraint_by_name(
        &[("x", 1.0), ("y", 1.0)],
        ConstraintType::LessEqual,
        10.0,
    )?
    .objective_by_name(
        &[("x", 3.0), ("y", 2.0)],
        ObjectiveType::Maximize,
    )?
    .build()?;

// solve it
let solution = solve(&problem)?;

if solution.is_optimal() {
    println!("found optimal solution!");
    println!("x = {:.2}", solution.variables[0]);
    println!("y = {:.2}", solution.variables[1]);
    println!("obj = {:.2}", solution.objective_value);
}

§modules

  • problem: problem modeling, vars, constraints & objectives
  • solvers: solver implementations & framework
  • utils: presolve, scaling, validation stuff
  • errors: error types & handling

Re-exports§

pub use problem::ConstraintType::LessEqual as Le;
pub use problem::ConstraintType::GreaterEqual as Ge;
pub use problem::ConstraintType::Equal as Eq;
pub use problem::Problem as LPProblem;
pub use errors::OptimizationError;
pub use errors::ProblemError;
pub use errors::Result;
pub use problem::Problem;
pub use problem::ProblemBuilder;
pub use problem::Variable;
pub use problem::Constraint;
pub use problem::Objective;
pub use problem::ConstraintType;
pub use problem::ObjectiveType;
pub use problem::VariableType;
pub use solvers::solve;
pub use solvers::solve_with_config;
pub use solvers::Solver;
pub use solvers::Solution;
pub use solvers::SolutionStatus;
pub use solvers::SolverConfig;
pub use solvers::SimplexSolver;
pub use utils::Presolve;
pub use utils::Scaling;
pub use utils::Validator;

Modules§

errors
prelude
convenient prelude module
problem
simplex
solvers
utils