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,
100
101 ListCheapestInsertion,
103
104 ListRegretInsertion,
106
107 ListClarkeWright,
109
110 ListKOpt,
112}
113
114#[derive(Debug, Clone, Default, Deserialize, Serialize)]
116#[serde(rename_all = "snake_case")]
117pub struct LocalSearchConfig {
118 pub acceptor: Option<AcceptorConfig>,
120
121 pub forager: Option<ForagerConfig>,
123
124 pub move_selector: Option<MoveSelectorConfig>,
126
127 pub termination: Option<TerminationConfig>,
129}
130
131#[derive(Debug, Clone, Default, Deserialize, Serialize)]
133#[serde(rename_all = "snake_case")]
134pub struct VndConfig {
135 #[serde(default)]
137 pub neighborhoods: Vec<MoveSelectorConfig>,
138
139 pub termination: Option<TerminationConfig>,
141}
142
143#[derive(Debug, Clone, Default, Deserialize, Serialize)]
145#[serde(rename_all = "snake_case")]
146pub struct ExhaustiveSearchConfig {
147 #[serde(default)]
149 pub exhaustive_search_type: ExhaustiveSearchType,
150
151 pub termination: Option<TerminationConfig>,
153}
154
155#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
157#[serde(rename_all = "snake_case")]
158pub enum ExhaustiveSearchType {
159 #[default]
161 BranchAndBound,
162
163 BruteForce,
165}
166
167#[derive(Debug, Clone, Default, Deserialize, Serialize)]
169#[serde(rename_all = "snake_case")]
170pub struct PartitionedSearchConfig {
171 pub partition_count: Option<usize>,
173
174 pub termination: Option<TerminationConfig>,
176}
177
178#[derive(Debug, Clone, Default, Deserialize, Serialize)]
180#[serde(rename_all = "snake_case")]
181pub struct CustomPhaseConfig {
182 pub custom_phase_class: Option<String>,
184}