solverforge_config/
phase.rs1use serde::{Deserialize, Serialize};
2
3use crate::acceptor::AcceptorConfig;
4use crate::forager::ForagerConfig;
5use crate::move_selector::{MoveSelectorConfig, VariableTargetConfig};
6use crate::termination::TerminationConfig;
7
8#[derive(Debug, Clone, Deserialize, Serialize)]
10#[serde(tag = "type", rename_all = "snake_case")]
11pub enum PhaseConfig {
12 ConstructionHeuristic(ConstructionHeuristicConfig),
14
15 LocalSearch(LocalSearchConfig),
17
18 Vnd(VndConfig),
20
21 ExhaustiveSearch(ExhaustiveSearchConfig),
23
24 PartitionedSearch(PartitionedSearchConfig),
26
27 Custom(CustomPhaseConfig),
29}
30
31fn default_k() -> usize {
32 2
33}
34
35#[derive(Debug, Clone, Deserialize, Serialize)]
37#[serde(rename_all = "snake_case")]
38pub struct ConstructionHeuristicConfig {
39 #[serde(default)]
41 pub construction_heuristic_type: ConstructionHeuristicType,
42
43 #[serde(flatten)]
45 pub target: VariableTargetConfig,
46
47 #[serde(default = "default_k")]
49 pub k: usize,
50
51 pub termination: Option<TerminationConfig>,
53}
54
55impl Default for ConstructionHeuristicConfig {
56 fn default() -> Self {
57 Self {
58 construction_heuristic_type: ConstructionHeuristicType::default(),
59 target: VariableTargetConfig::default(),
60 k: default_k(),
61 termination: None,
62 }
63 }
64}
65
66#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
68#[serde(rename_all = "snake_case")]
69pub enum ConstructionHeuristicType {
70 #[default]
72 FirstFit,
73
74 FirstFitDecreasing,
76
77 WeakestFit,
79
80 WeakestFitDecreasing,
82
83 StrongestFit,
85
86 StrongestFitDecreasing,
88
89 CheapestInsertion,
91
92 AllocateEntityFromQueue,
94
95 AllocateToValueFromQueue,
97
98 ListRoundRobin,
101
102 ListCheapestInsertion,
105
106 ListRegretInsertion,
109
110 ListClarkeWright,
113
114 ListKOpt,
117}
118
119#[derive(Debug, Clone, Default, Deserialize, Serialize)]
121#[serde(rename_all = "snake_case")]
122pub struct LocalSearchConfig {
123 pub acceptor: Option<AcceptorConfig>,
125
126 pub forager: Option<ForagerConfig>,
128
129 pub move_selector: Option<MoveSelectorConfig>,
131
132 pub termination: Option<TerminationConfig>,
134}
135
136#[derive(Debug, Clone, Default, Deserialize, Serialize)]
138#[serde(rename_all = "snake_case")]
139pub struct VndConfig {
140 #[serde(default)]
142 pub neighborhoods: Vec<MoveSelectorConfig>,
143
144 pub termination: Option<TerminationConfig>,
146}
147
148#[derive(Debug, Clone, Default, Deserialize, Serialize)]
150#[serde(rename_all = "snake_case")]
151pub struct ExhaustiveSearchConfig {
152 #[serde(default)]
154 pub exhaustive_search_type: ExhaustiveSearchType,
155
156 pub termination: Option<TerminationConfig>,
158}
159
160#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
162#[serde(rename_all = "snake_case")]
163pub enum ExhaustiveSearchType {
164 #[default]
166 BranchAndBound,
167
168 BruteForce,
170}
171
172#[derive(Debug, Clone, Default, Deserialize, Serialize)]
174#[serde(rename_all = "snake_case")]
175pub struct PartitionedSearchConfig {
176 pub partition_count: Option<usize>,
178
179 pub termination: Option<TerminationConfig>,
181}
182
183#[derive(Debug, Clone, Default, Deserialize, Serialize)]
185#[serde(rename_all = "snake_case")]
186pub struct CustomPhaseConfig {
187 pub custom_phase_class: Option<String>,
189}