u_nesting_core/lib.rs
1//! # U-Nesting Core
2//!
3//! Core traits and abstractions for the U-Nesting spatial optimization engine.
4//!
5//! This crate provides the foundational types and traits that are shared between
6//! the 2D nesting and 3D bin packing modules.
7//!
8//! ## Core Components
9//!
10//! - **Geometry traits**: [`Geometry`], [`Geometry2DExt`], [`Geometry3DExt`]
11//! - **Boundary traits**: [`Boundary`], [`Boundary2DExt`], [`Boundary3DExt`]
12//! - **Solver trait**: [`Solver`] - Common interface for all optimization algorithms
13//! - **GA framework**: [`GaRunner`], [`GaProblem`] - Genetic algorithm infrastructure
14//! - **BRKGA framework**: [`BrkgaRunner`], [`BrkgaProblem`] - Biased Random-Key GA
15//! - **SA framework**: [`SaRunner`], [`SaProblem`] - Simulated Annealing
16//! - **Transform types**: [`Transform2D`], [`Transform3D`], [`AABB2D`], [`AABB3D`]
17//!
18//! ## Optimization Strategies
19//!
20//! The [`Strategy`] enum defines available optimization algorithms:
21//!
22//! | Strategy | Speed | Quality | Description |
23//! |----------|-------|---------|-------------|
24//! | `BottomLeftFill` | Fast | Basic | Greedy bottom-left placement |
25//! | `NfpGuided` | Medium | Good | NFP-based optimal positioning (2D) |
26//! | `GeneticAlgorithm` | Slow | High | GA with permutation encoding |
27//! | `Brkga` | Medium | High | Biased Random-Key GA |
28//! | `SimulatedAnnealing` | Medium | High | Temperature-based optimization |
29//! | `ExtremePoint` | Fast | Good | EP heuristic (3D only) |
30//!
31//! ## Configuration
32//!
33//! Use [`Config`] to configure solver behavior:
34//!
35//! ```rust
36//! use u_nesting_core::{Config, Strategy};
37//!
38//! let config = Config::new()
39//! .with_strategy(Strategy::GeneticAlgorithm)
40//! .with_spacing(2.0)
41//! .with_margin(5.0)
42//! .with_time_limit(30000);
43//! ```
44//!
45//! ## Feature Flags
46//!
47//! - `serde`: Enable serialization/deserialization support
48
49pub mod alns;
50pub mod brkga;
51pub mod error;
52pub mod exact;
53pub mod ga;
54pub mod gdrr;
55pub mod geometry;
56pub mod memory;
57pub mod placement;
58pub mod result;
59pub mod robust;
60pub mod sa;
61pub mod solver;
62pub mod transform;
63
64// Re-exports
65pub use alns::{
66 AlnsConfig, AlnsProblem, AlnsProgress, AlnsResult, AlnsRunner, AlnsSolution, DestroyOperatorId,
67 DestroyResult, OperatorStats, RepairOperatorId, RepairResult,
68};
69pub use brkga::{
70 BrkgaConfig, BrkgaProblem, BrkgaProgress, BrkgaResult, BrkgaRunner, RandomKeyChromosome,
71};
72pub use error::{Error, Result};
73pub use exact::{ExactConfig, ExactResult, SolutionStatus};
74pub use ga::{
75 GaConfig, GaProblem, GaProgress, GaResult, GaRunner, Individual, PermutationChromosome,
76};
77pub use gdrr::{
78 GdrrConfig, GdrrProblem, GdrrProgress, GdrrResult, GdrrRunner, GdrrSolution, RecreateResult,
79 RecreateType, RuinResult, RuinType, RuinedItem,
80};
81pub use geometry::{
82 Boundary, Boundary2DExt, Boundary3DExt, Geometry, Geometry2DExt, Geometry3DExt, GeometryId,
83 Orientation3D, RotationConstraint,
84};
85pub use placement::Placement;
86pub use result::{SolveResult, SolveSummary};
87pub use sa::{
88 CoolingSchedule, NeighborhoodOperator, PermutationSolution, SaConfig, SaProblem, SaResult,
89 SaRunner, SaSolution,
90};
91pub use solver::{Config, ProgressCallback, ProgressInfo, Solver, Strategy};
92pub use transform::{Transform2D, Transform3D, AABB2D, AABB3D};