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 /// Definition of what is considered a narrow concavity that will be closed
15 /// See [`jagua_rs::geometry::shape_modification::ShapeModifyConfig`] for more details.
16 /// If undefined, the algorithm will run without closing narrow concavities
17 pub narrow_concavity_cutoff: Option<(f32, f32)>,
18 /// Minimum distance between items and other hazards.
19 /// If undefined, the algorithm will run without this constraint
20 pub min_item_separation: Option<f32>,
21 /// Seed for the PRNG. If undefined, the algorithm will run in non-deterministic mode using entropy
22 pub prng_seed: Option<u64>,
23 /// Total budget of samples per item per layout
24 pub n_samples: usize,
25 /// Fraction of `n_samples_per_item` used for the local search sampler, the rest is sampled uniformly.
26 pub ls_frac: f32,
27 /// Optional SVG drawing options
28 pub svg_draw_options: SvgDrawOptions,
29}
30
31impl Default for LBFConfig {
32 fn default() -> Self {
33 Self {
34 cde_config: CDEConfig {
35 quadtree_depth: 5,
36 cd_threshold: 16,
37 item_surrogate_config: SPSurrogateConfig {
38 n_pole_limits: [(100, 0.0), (20, 0.75), (10, 0.90)],
39 n_ff_poles: 2,
40 n_ff_piers: 0,
41 },
42 },
43 poly_simpl_tolerance: Some(0.001),
44 narrow_concavity_cutoff: Some((0.01, 0.01)),
45 min_item_separation: None,
46 prng_seed: None,
47 n_samples: 5000,
48 ls_frac: 0.2,
49 svg_draw_options: SvgDrawOptions::default(),
50 }
51 }
52}