$ show kiegroup/optaplanner
OptaPlanner is a Java library for constraint satisfaction optimization, solving planning and scheduling problems such as employee rostering, vehicle routing, and cloud resource allocation. The architecture is modular: a core engine provides heuristic search algorithms (construction heuristics, local search, exhaustive search) and incremental score calculation via two constraint stream implementations (Bavet, a custom tuple-based engine, and Drools, a rule-based engine). The public API centers on annotations (@PlanningSolution, @PlanningEntity, @PlanningVariable) and interfaces (ConstraintProvider, SolverFactory, SolverManager). Key entry points include SolverFactory.create() to build a solver, Solver.solve() to run optimization, and ConstraintVerifier for testing constraints. Data flows involve defining a domain model with planning entities and variables, providing constraints as a ConstraintProvider, and the solver iterating through moves while evaluating scores incrementally. External dependencies include Drools (optional), Quarkus or Spring Boot for integration, Jackson/JAXB for serialization, and JPA for persistence. The repository also includes a benchmarking module, a Kubernetes operator, and extensive example applications.
The LLM identified 4 files worth highlighting for reuse:
A set of indexer classes (EqualsIndexer, ComparisonIndexer, IndexerFactory, IndexProperties) that implement a multi-key index for tuple-based join operations in the Bavet constraint stream engine. These are self-contained, reusable for any in-memory indexing need, and demonstrate non-obvious data structure design with efficient insertion, lookup, and removal.
A custom doubly-linked list implementation that provides O(1) removal of entries via TupleListEntry references. Used internally by Bavet to track active tuples with efficient insert/update/retract operations. This is a reusable data structure for any event-driven system requiring constant-time removal from a list.
An abstract base class for incremental score calculation with undo support. Defines the pattern of weighted score impacters that can be applied and undone, enabling efficient score updates during solver moves. The design is clean, extensible, and reusable for any system requiring incremental aggregation with rollback.
A bytecode generation utility that creates fast member accessors using the Gizmo library, replacing reflection-based access for planning entity fields. This is a non-trivial pattern for generating JVM bytecode at build time to improve performance, and could be extracted for any project needing reflection-free property access.