How scipopt/russcip works
Project type and purpose
• This is a Rust library crate (“russcip”) providing a safe, high-level interface on top of the SCIP C solver. It is not a full-stack app or microservice but an SDK/FFI wrapper with extensibility points (plugin traits).
File structure
• Top-level:
• Cargo.toml, README.md, INSTALL.md, CONTRIBUTING.md, LICENSE
• .github/workflows/build_and_test.yml (CI pipeline)
• data/ (test-data folder)
• examples/ (consumer code demonstrating library usage)
• src/:
• lib.rs (entry point, re-exports)
• scip.rs (initialization, global parameters)
• Modules for each wrapper: model.rs, variable.rs, constraint.rs, row.rs, solution.rs, status.rs, retcode.rs, col.rs, param.rs, probing.rs, diving.rs, eventhdlr.rs, heuristic.rs, separator.rs, pricer.rs, branchrule.rs, sepa.rs, …
• builder/ subdirectory: builder.rs plus plugin-specific builders (branchrule.rs, pricer.rs, eventhdlr.rs, heur.rs, cons.rs, row.rs, sepa.rs, var.rs)
• No networking or database—core dependency is the external SCIP C library accessed through FFI.
README for additional insights
• Confirms two layers:
• ffi module (raw C-API bindings)
• Safe wrappers over SCIP entities (Model, Variable, Constraint, etc.)
• Defines plugin-trait modules (BranchRule, Pricer, Eventhdlr, Heuristic, Separator, Conshdlr) and shows how to attach custom data via anymap.
• Examples directory holds standalone Rust programs that call into the library.
Components
a. Main components
1. Rust Safe-API Layer
– Core types: Model, Variable, Constraint, Row, Solution, Status, Retcode, Column, Parameter.
– Plugin traits: BranchRule, Pricer, EventHdlr, Heuristic, Separator, Conshdlr
2. Builder Subsystem
– builder:: (one builder per plugin type + overall Model builder)
3. FFI Layer
– ffi bindings (extern “C” functions matching SCIP’s C-API)
4. External SCIP C Library
– The native solver code (bundled or system-installed)
5. Consumers / Examples / Tests
– examples/*.rs
– data/test input files
6. CI / Packaging
– GitHub Actions workflow
– crates.io (publishing)
– codecov
b. Relationships and interactions
• Safe-API calls into builder and direct wrapper modules.
• Wrapper modules invoke ffi functions to perform operations on the SCIP pointer.
• ffi layer calls into the external SCIP C library.
• Plugin traits are implemented by user code or examples, registered via builder APIs, and invoked by SCIP during solve.
• anymap used internally by Model to store custom user data.
• CI triggers build/test, publishes coverage, and can deploy to crates.io.
c. Architectural patterns and design principles
• Wrapper/Adapter pattern: Rust types adapt the raw C interface to safe, idiomatic Rust.
• Builder pattern: builder/ modules let you configure and attach plugins before solving.
• Plugin architecture: Traits define extension points; user code implements them and registers with Model.
• Separation of concerns:
– Core modeling vs. plugin mechanics vs. raw FFI vs. user code (examples/tests).
• Zero-cost abstractions: Safe wrappers have minimal runtime overhead over raw FFI.
d. Key technologies, frameworks, libraries
• Rust, Cargo, crates.io
• FFI (extern “C”)
• anymap for per-Model data storage
• GitHub Actions, codecov for CI/CD
• SCIP C library (bundled feature)