pub struct Config {
pub strategy: Strategy,
pub spacing: f64,
pub margin: f64,
pub time_limit_ms: u64,
pub target_utilization: Option<f64>,
pub threads: usize,
pub population_size: usize,
pub max_generations: u32,
pub crossover_rate: f64,
pub mutation_rate: f64,
pub elite_count: usize,
pub seed: Option<u64>,
}Expand description
Common configuration for solvers.
Fields§
§strategy: StrategyOptimization strategy.
spacing: f64Minimum distance between any two placed geometries. It does not apply
between a geometry and the boundary — that is margin.
margin: f64Minimum distance between any placed geometry and the boundary edge.
time_limit_ms: u64Maximum computation time in milliseconds (0 = unlimited).
The search strategies check it between individual placements, so a solve returns within the limit plus the time of the greedy bottom-left pass it is compared against. The layout returned is the best one found in that time.
target_utilization: Option<f64>Target utilization (0.0 - 1.0). Solver stops if reached.
threads: usizeNumber of threads to use (0 = auto).
population_size: usizePopulation size for GA.
max_generations: u32Number of generations for GA.
crossover_rate: f64Crossover rate for GA (0.0 - 1.0).
mutation_rate: f64Mutation rate for GA (0.0 - 1.0).
elite_count: usizeElite count for GA.
seed: Option<u64>Optional RNG seed for reproducible runs of the stochastic strategies
(GA, BRKGA, SA). None seeds from system entropy (non-deterministic).
Implementations§
Source§impl Config
impl Config
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Checks the fields a caller sets against their ranges – the builders store what they are given, and every solver calls this before it runs.
§Errors
ConfigError naming the first field out of range: spacing or
margin negative or not finite, crossover_rate/mutation_rate or
target_utilization outside [0, 1].
Sourcepub fn with_strategy(self, strategy: Strategy) -> Self
pub fn with_strategy(self, strategy: Strategy) -> Self
Sets the optimization strategy.
Sourcepub fn with_spacing(self, spacing: f64) -> Self
pub fn with_spacing(self, spacing: f64) -> Self
Sets the spacing between geometries.
Sourcepub fn with_margin(self, margin: f64) -> Self
pub fn with_margin(self, margin: f64) -> Self
Sets the margin from boundary edges.
Sourcepub fn with_time_limit(self, ms: u64) -> Self
pub fn with_time_limit(self, ms: u64) -> Self
Sets the time limit in milliseconds.
Sourcepub fn with_target_utilization(self, util: f64) -> Self
pub fn with_target_utilization(self, util: f64) -> Self
Sets the target utilization.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.