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§
- AddressableAccess 
- Represents array-like access to a variable, such as x[1][2].
- Assignment
- Represents a variable assignment in a solution.
- BlockFunction 
- 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.
- BlockScoped 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.
- CompilationError 
- Represents a compilation error with location information and error details.
- CompoundVariable 
- Represents a variable with subscript indices, such as x_1_2.
- Constant
- A constant value with a name and a value
- EqualityConstraint 
- Represents a linear equality constraint in standard form: ax = b where a is a vector of coefficients and b is a constant.
- FunctionCall 
- Represents a function call with its arguments, name and source span.
- Graph
- GraphEdge 
- GraphNode 
- InputSpan 
- Represents a span of text in the input source, tracking location information.
- IterableSet 
- Represents an iterable set expression in the intermediate language.
- LinearConstraint 
- Represents a linear constraint in the form: coefficients * variables comparison_operator rhs
- LinearModel 
- 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.
- NormalizationContext 
- Context for tracking the normalization process of converting constraints to standard form.
- OptimalTableau 
- OptimalTableau With Steps 
- PreConstraint
- Represents a constraint in a mathematical programming problem.
- PreObjective
- Represents an optimization objective in a mathematical programming problem.
- RoocParser 
- A parser for the Rooc optimization modeling language.
- RoocSolver 
- SimplexStep 
- Spanned
- A wrapper type that associates a value with its location in source code.
- StandardLinear Model 
- Represents a linear optimization model in standard form.
- Tableau
- Tuple
- A tuple type that holds an ordered collection of Primitivevalues.
Enums§
- BinOp
- BlockFunction Kind 
- BlockScoped Function Kind 
- CanonicalTransform Error 
- Comparison
- IntOrBool Value 
- Represents a variable value that can be either boolean or integer.
- IterableKind 
- Represents different types of iterable collections in the system.
- LinearModel Error 
- Errors that can occur when manipulating a LinearModel.
- LinearizationError 
- MILPValue 
- Represents a variable value that can be either boolean or integer.
- Operator
- OperatorError 
- Represents errors that can occur during operator application.
- OptimizationType 
- ParseError 
- Represents different types of parsing errors that can occur during compilation.
- PreExp
- Represents an expression in the intermediate language before final transformation.
- PreVariableType 
- Represents the type of a variable before type checking and transformation
- Primitive
- Represents a primitive value in the system.
- PrimitiveKind 
- RoocSolver Error 
- SimplexError 
- SolverError 
- Represents errors that can occur during linear programming problem solving.
- StepAction 
- UnOp
- VariableType 
- Represents the final, resolved type of a variable after being compiled
Traits§
- ApplyOp
- Trait for types that can have operators applied to them.
- RoocFunction 
- 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.