Expand description
§ROOC
ROOC is a modeling language for defining and solving optimization problems.
Write everything as a single source file:
use indexmap::IndexMap;
use rooc::pipe::{AutoSolverPipe, LinearModelPipe, ModelPipe, PipeContext, PipeRunner, PipeableData, PreModelPipe};
let source = "
max sum((value, i) in enumerate(values)) { value * x_i }
s.t.
sum((weight, i) in enumerate(weights)) { weight * x_i } <= capacity
where
let weights = [10, 60, 30, 40, 30, 20, 20, 2]
let values = [1, 10, 15, 40, 60, 90, 100, 15]
let capacity = 102
define
x_i as Boolean for i in 0..len(weights)";
//use pipes to solve the problem
let pipe_runner = PipeRunner::new(vec![
Box::new(rooc::pipe::CompilerPipe::new()),
Box::new(PreModelPipe::new()),
Box::new(ModelPipe::new()),
Box::new(LinearModelPipe::new()),
Box::new(AutoSolverPipe::new()),
]);
let result = pipe_runner
.run(
PipeableData::String(source.to_string()),
&PipeContext::new(vec![], &IndexMap::new()),
)
.unwrap();
let last = result
.into_iter()
.last()
.unwrap()
.to_milp_solution()
.unwrap();
println!("{}", last)
Or extend the language with your own functionality and data
Modules§
- binary_
solver - block_
functions - builtin_
primitive_ traits_ impl - common
- consts
- domain_
declaration - function_
traits - functions
- graph
- il
- il_exp
- il_
problem - iterable
- iterable_
set - iterable_
utils - linear_
integer_ binary_ solver - linear_
model - linearizer
- math_
enums - math_
utils - model_
transformer - operators
- optimal_
tableau - pipe
- pre_
model - primitive
- primitive_
traits - real_
solver - rules_
parser - simplex
- simplex_
enums - simplex_
solver - simplex_
utils - standard_
linear_ model - standardizer
- tableau
- tuple
- type_
checker
Macros§
- bail_
missing_ token - bail_
semantic_ error - bail_
wrong_ argument - check_
bounds - enum_
with_ variants_ to_ string - err_
unexpected_ token - make_
pipe_ error - match_
or_ bail - match_
pipe_ data_ to - wrong_
argument
Structs§
- Addressable
Access - Represents array-like access to a variable, such as
x[1][2]
. - Assignment
- Represents a variable assignment in a solution.
- Block
Function - A function that operates on a fixed set of expressions. This represents functions like min, max, avg that take a set of arguments and compute a single result.
- Block
Scoped Function - A function that operates over a set of values with iteration variables. This represents functions like sum, product, etc. that iterate over a set.
- Compilation
Error - Represents a compilation error with location information and error details.
- Compound
Variable - Represents a variable with subscript indices, such as x_1_2.
- Constant
- A constant value with a name and a value
- Equality
Constraint - Represents a linear equality constraint in standard form: ax = b where a is a vector of coefficients and b is a constant.
- Function
Call - Represents a function call with its arguments, name and source span.
- Graph
- Graph
Edge - Graph
Node - Input
Span - Represents a span of text in the input source, tracking location information.
- Iterable
Set - Represents an iterable set expression in the intermediate language.
- Linear
Constraint - Represents a linear constraint in the form: coefficients * variables comparison_operator rhs
- Linear
Model - Represents a complete linear programming model including variables, constraints, and objective function.
- Linearizer
- Manages the linearization process for expressions and constraints.
- LpSolution
- Represents a solution to a linear programming problem.
- Normalization
Context - Context for tracking the normalization process of converting constraints to standard form.
- Optimal
Tableau - Optimal
Tableau With Steps - PreConstraint
- Represents a constraint in a mathematical programming problem.
- PreObjective
- Represents an optimization objective in a mathematical programming problem.
- Rooc
Parser - A parser for the Rooc optimization modeling language.
- Rooc
Solver - Simplex
Step - Spanned
- A wrapper type that associates a value with its location in source code.
- Standard
Linear Model - Represents a linear optimization model in standard form.
- Tableau
- Tuple
- A tuple type that holds an ordered collection of
Primitive
values.
Enums§
- BinOp
- Block
Function Kind - Block
Scoped Function Kind - Canonical
Transform Error - Comparison
- IntOr
Bool Value - Represents a variable value that can be either boolean or integer.
- Iterable
Kind - Represents different types of iterable collections in the system.
- Linear
Model Error - Errors that can occur when manipulating a LinearModel.
- Linearization
Error - MILP
Value - Represents a variable value that can be either boolean or integer.
- Operator
- Operator
Error - Represents errors that can occur during operator application.
- Optimization
Type - Parse
Error - Represents different types of parsing errors that can occur during compilation.
- PreExp
- Represents an expression in the intermediate language before final transformation.
- PreVariable
Type - Represents the type of a variable before type checking and transformation
- Primitive
- Represents a primitive value in the system.
- Primitive
Kind - Rooc
Solver Error - Simplex
Error - Solver
Error - Represents errors that can occur during linear programming problem solving.
- Step
Action - UnOp
- Variable
Type - Represents the final, resolved type of a variable after being compiled
Traits§
- ApplyOp
- Trait for types that can have operators applied to them.
- Rooc
Function - Trait defining the interface for Rooc functions.
- Spreadable
- Trait for types that can be spread into a sequence of primitives.
Functions§
- auto_
solver - Solves a any kind of linear programming problem by picking the right solver for the model.
- default_
rooc_ function_ to_ latex - Converts a function call to LaTeX format.
- default_
rooc_ function_ to_ string - Converts a function call to a string representation.
- default_
type_ check - The default type check implementation, it performs type checking of function arguments against expected types.
- default_
wrong_ number_ of_ arguments - Creates an error for wrong number of arguments.
- default_
wrong_ type - Creates a type error for wrong argument types.
- divide_
matrix_ row_ by - find_
invalid_ variables - Finds variables in a domain that don’t satisfy a validation condition.
- float_
eq - Checks if two numbers are the same within 5 decimal digits
- float_
ne - Checks if two numbers are different within 5 decimal digits
- format_
var - Formats a variable term with its coefficient for display.
- make_
constraints_ map_ from_ assignment - normalize_
constraint - Converts a linear constraint to standard form by adding slack or surplus variables as needed.
- process_
variables - Processes coefficients and variables to create Times expressions, filtering based on index.
- process_
variables_ binary - Similar to process_variables but works with binary variables.
- solve_
binary_ lp_ problem - Solves a binary linear programming problem.
- solve_
integer_ binary_ lp_ problem - Solves a mixed integer-binary linear programming problem.
- solve_
milp_ lp_ problem - Solves a mixed-integer linear programming problem using the MicroLP solver.
- solve_
real_ lp_ problem_ clarabel - Solves a linear programming problem with real variables using the Clarabel solver.
- solve_
real_ lp_ problem_ micro_ lp - Solves a linear programming problem with real variables using the microlp solver.
- solve_
real_ lp_ problem_ slow_ simplex - Solves a linear programming problem with real variables using a basic simplex algorithm.
- to_
standard_ form - Converts a linear programming model into standard form.