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 /// Seed for the PRNG. If undefined, the algorithm will run in non-deterministic mode using entropy
19 pub prng_seed: Option<u64>,
20 /// Total budget of samples per item per layout
21 pub n_samples: usize,
22 /// Fraction of `n_samples_per_item` used for the local search sampler, the rest is sampled uniformly.
23 pub ls_frac: f32,
24 /// Optional SVG drawing options
25 pub svg_draw_options: SvgDrawOptions,
26}
27
28impl Default for LBFConfig {
29 fn default() -> Self {
30 Self {
31 cde_config: CDEConfig {
32 item_surrogate_config: SPSurrogateConfig {
33 n_pole_limits: [(100, 0.0), (20, 0.75), (10, 0.90)],
34 ff_pole_area_ratio: 0.5,
35 },
36 },
37 poly_simpl_tolerance: Some(0.001),
38 narrow_concavity_cutoff: Some((0.01, 0.01)),
39 prng_seed: None,
40 n_samples: 5000,
41 ls_frac: 0.2,
42 svg_draw_options: SvgDrawOptions::default(),
43 }
44 }
45}