A pure-Python reinforcement learning library for combinatorial optimization, built on top of PySCIPOpt and Gymnasium.
Gyozas provides a modular RL environment that lets you train agents to make decisions inside SCIP's branch-and-bound solver -- variable selection (branching) and node selection -- with pluggable rewards, observations, and problem instance generators.
- Gymnasium-style API --
reset()/step()/render()interface - Branching & node selection dynamics -- control variable branching or node selection decisions
- Bipartite graph observations -- LP-based features following Gasse et al. (NeurIPS 2019)
- Multiple reward functions -- node count, solving time, LP iterations, primal/dual integrals
- Built-in instance generators -- set cover, independent set, combinatorial auction, capacitated facility location
- Branch-and-bound tree visualization
Gyozas requires the SCIP solver (version 8+). But latest version should be installed when PySCIPOpt is installed automatically with Gyozas dependencies
pip install gyozasOr install from source:
pip install .You can install extra packages for enhanced visualization of branch and bound tree state using
pip install "gyozas[viz]"import gyozas
# Create an instance generator
instances = gyozas.SetCoverGenerator(n_rows=100, n_cols=200)
# Create the RL environment
env = gyozas.Environment(
instance_generator=instances,
observation_function=gyozas.NodeBipartite(),
reward_function=gyozas.NNodes(),
)
# Run one episode
obs, action_set, reward, done, info = env.reset()
while not done:
action = action_set[0] # pick first available action
obs, action_set, reward, done, info = env.step(action)
env.close()Gyozas is a drop-in replacement for Ecole with a near-identical API:
| Ecole | Gyozas | |
|---|---|---|
| Install | C++ build, CMake, custom SCIP | pip install gyozas |
| Language | C++ core + Python bindings | Pure Python |
| Maintained | Last release 2023 | Active |
| Python | 3.7--3.10 | 3.10+ |
| Custom components | Subclass C++ base classes | Any object with reset()/extract() |
| Node selection | Not supported | NodeSelectionDynamics |
| Gymnasium wrapper | Not included | GymnasiumWrapper for SB3/CleanRL |
See the full migration guide for detailed API mapping.
BranchingDynamics-- control variable selection in branching (default)NodeSelectionDynamics-- control which node to explore nextConfiguringDynamics-- single-step algorithm configuration (set SCIP params, then solve)PrimalSearchDynamics-- LP-probing primal heuristic; agent provides partial variable assignmentsExtraBranchingActions-- sentinel actions (SKIP,CUT_OFF,REDUCE_DOMAIN) for branching
NNodes-- change in number of explored nodesSolvingTime-- wall-clock time per stepLPIterations-- change in LP iterationsDualIntegral/PrimalIntegral/PrimalDualIntegral-- bound integralsDone-- binary completion statusArithmeticMixin-- compose rewards with Python operators:-NNodes() * 0.5 + SolvingTime().cumsum()
NodeBipartite/NodeBipartiteEcole-- pure-Python bipartite graph with configurable featuresNodeBipartiteSCIP-- thin wrapper around PySCIPOpt's built-in C implementationPseudocosts-- per-variable pseudocost scores accumulated across branching historyStrongBranchingScores-- full and partial strong-branching scores via LP probing
SetCoverGenerator-- random set cover problemsIndependentSetGenerator-- random independent set problemsCombinatorialAuctionGenerator-- random combinatorial auction problemsCapacitatedFacilityLocationGenerator-- random facility location problemsFileGenerator-- load instances from files on disk
Modifiers wrap any generator and post-process the model before it reaches the environment:
EmbedObjective-- embed the objective function as a variable + equality constraintSetParameters-- apply arbitrary SCIP parametersSetNoCuts/SetNoHeuristics/SetNoDisplay/SetDFSNodeSelection/SetBFSNodeSelection-- convenience presets
GymnasiumWrapper exposes any Environment as a standard Gymnasium environment, compatible with Stable-Baselines3, CleanRL, and other RL frameworks.
uv sync
uv run pytest| Name | Affiliation | GitHub |
|---|---|---|
| Olivier JUAN | EDF Lab | @olivierjuan |
| Paul STRANG | EDF Lab · CNAM · ISAE | @abfariah |