lbf/config.rs
1use jagua_rs::collision_detection::CDEConfig;
2use jagua_rs::geometry::fail_fast::SPSurrogateConfig;
3use jagua_rs::io::svg::SvgDrawOptions;
4use serde::{Deserialize, Serialize};
5
6/// Configuration for the LBF optimizer
7#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
8#[serde(default)]
9pub struct LBFConfig {
10 /// Configuration of the Collision Detection Engine
11 pub cde_config: CDEConfig,
12 /// Max deviation from the original polygon area as a fraction. If undefined, the algorithm will run without simplification
13 pub poly_simpl_tolerance: Option<f32>,
14 /// Maximum distance between two vertices of a polygon to consider it a narrow concavity (which will be closed).
15 /// Defined as a fraction of the largest item in the instance.
16 pub narrow_concavity_cutoff_ratio: Option<f32>,
17 /// Minimum distance between items and other hazards.
18 /// If undefined, the algorithm will run without this constraint
19 pub min_item_separation: Option<f32>,
20 /// Seed for the PRNG. If undefined, the algorithm will run in non-deterministic mode using entropy
21 pub prng_seed: Option<u64>,
22 /// Total budget of samples per item per layout
23 pub n_samples: usize,
24 /// Fraction of `n_samples_per_item` used for the local search sampler, the rest is sampled uniformly.
25 pub ls_frac: f32,
26 /// Optional SVG drawing options
27 pub svg_draw_options: SvgDrawOptions,
28}
29
30impl Default for LBFConfig {
31 fn default() -> Self {
32 Self {
33 cde_config: CDEConfig {
34 quadtree_depth: 5,
35 cd_threshold: 16,
36 item_surrogate_config: SPSurrogateConfig {
37 n_pole_limits: [(100, 0.0), (20, 0.75), (10, 0.90)],
38 n_ff_poles: 2,
39 n_ff_piers: 0,
40 },
41 },
42 poly_simpl_tolerance: Some(0.001),
43 narrow_concavity_cutoff_ratio: Some(0.01),
44 min_item_separation: None,
45 prng_seed: None,
46 n_samples: 5000,
47 ls_frac: 0.2,
48 svg_draw_options: SvgDrawOptions::default(),
49 }
50 }
51}