forked from CorinnaKrebs/SolutionValidator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstraintsLoading.h
More file actions
302 lines (277 loc) · 10.8 KB
/
ConstraintsLoading.h
File metadata and controls
302 lines (277 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#pragma once
#include "Item.h"
#include "Vehicle.h"
#include "Solution.h"
#include "Instance.h"
#include "ConstraintSet.h"
namespace validator {
/**
* Class with all Loading Constraints
*/
class ConstraintsLoading {
public:
/**
* Check solution concerning the feasibility of all loading constraints defined in the constraint set.
*
* @param solution the solution
* @param cSet the constraint set
* @param instance the instance
* @return the feasibility of the solution w.r.t. loading constraints
*/
static bool checkLoadingConstraints(Solution& solution, const ConstraintSet& cSet, Instance& instance, const bool& msg);
/**
* Check if an item overlaps with the vehicle walls.
*
* @param item the item
* @param vehicle the vehicle
* @param msg optional output messages
* @return feasibility of item position.
*/
static bool checkVehicleWalls(const Item& item, const Vehicle& vehicle, const bool& msg);
/**
* Check if an item overlaps with any already placed item.
*
* @param item the item
* @param tour the tour
* @param tourEndPos the current position of the packing process
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkOverlapping(Item& item, Tour& tour, const unsigned int& tourEndPos, const Instance& instance, const bool& msg);
/**
* Check if the dimension of an item are calculated correctly.
*
* @param item the item
* @param msg optional output message
* @return correctness of item dimensions
*/
static bool checkDimensions(const Item& item, const bool& msg);
/**
* Check if the maximum corner point is not zero.
*
* @param item the item
* @param msg optional output message
* @return correctness of maximum corner point
*/
static bool checkMaxCoordinates(const Item& item, const bool& msg);
/**
* Check item position w.r.t. Unloading Sequence Constraints.
*
* @param item the item
* @param tour the tour
* @param tourEndPos the current position of the packing process
* @param uSequence the considered Unloading Sequence constraint
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkUnloadingSequence(Item& item, Tour& tour, const unsigned int& tourEndPos, const UnloadingSequence& uSequence, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Stacking Constraints.
*
* @param item the item
* @param tour the tour
* @param tourEndPos the current position of the packing process
* @param stacking the considered stacking constraint
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkStacking(Item& item, Tour& tour, const unsigned int& tourEndPos, const Stacking& stacking, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Fragility Constraint.
* Non-Fragile Items cannot be stacked on fragile items.
* Fragile Item can be stacked on top of fragile items.
*
* @param item the item
* @param tour the tour
* @param tourEndPos the current position of the packing process
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkFragility(Item& item, Tour& tour, const unsigned int& tourEndPos, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. LBS (Complete or Simple) Constraint.
*
* @param below the item below
* @param above the item above
* @param weight the weight to be distributed
* @param instance the instance
* @param stacking the stacking constraint (LBS)
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkLBS(Item& below, Item& above, double weight, Instance& instance, const Stacking& stacking, const bool& msg);
/**
* Check item position w.r.t. LBS Simple Constraint.
* The Load of an item is distributed to all indirect and direct
* supporting items underneath the item base area.
*
* @param item the item
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkLBSSimple(Item& item, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. LBS Complete Constraint.
* The load of an item is recursively distributed to the direct underlying items.
*
* @param item the item
* @param instance the instance
* @param load the load
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkLBSComplete(Item& item, Instance& instance, double load, const bool& msg);
/**
* Check item position w.r.t. Vertical Stability Constraints.
*
* @param item the item
* @param vStability the considered vertical stability constraint
* @param alpha support parameter (part of base area)
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkVStability(Item& item, const VerticalStability& vStability, const float& alpha, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. at least one directly underlying item.
*
* @param item the item
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkFlyingItem(Item& item, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Minimal Supporting Area Constraint.
* Each item has a supporting area of at least a percentage alpha of its base area;
*
* @param item the item
* @param alpha support parameter (part of base area)
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkMinimalSupport(Item& item, const float& alpha, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Multiple Overhanging Constraint.
* Each item has a supporting area of at least a percentage alpha of its base area at any height.
* Therefore check the Minimal Supporting Area at each level.
*
* @param item the item
* @param alpha support parameter (part of base area)
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkMultipleOverhanging(Item& item, const float& alpha, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Top Overhanging Constraint.
* All Items of a stack must be fully supported except the topmost item,
* which is allowed to overhanging respecting the Minimal Supporting Area Constraint.
*
* @param item the item
* @param alpha support parameter (part of base area)
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkTopOverhanging(Item& item, const float& alpha, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Static Stability Constraint.
* Each item has a center of gravity, which must be within an item at each level.
*
* @param item the item
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkStaticStability(Item& item, Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Static Stability Constraint proposed by Mack et al. (2004).
* The center of gravity of each item must be supported by underlying items and
* the base area of each item must be supported by the items on the ground.
* @param item the item
* @param alpha support parameter (part of base area)
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkStaticStabiltyMack(Item& item, const float& alpha, Instance& instance, const bool& msg);
/**
* Check if item position does not lead to an exceedence of the axle weights.
*
* @param item the item
* @param tour the tour
* @param axle_weights the consideration of axle weights
* @param instance the instance
* @param msg optional output messages
* @return feasibility of item position.
*/
static bool checkAxleWeights(Item& item, Tour& tour, const bool& axle_weights, const Instance& instance, const bool& msg);
/**
* Check if item position does not lead to an exceedence of the permissible load per vehicle half.
* The load of one vehicle half does not exceed a certain percentage of the vehicle capacity.
*
* @param item the item
* @param tour the tour
* @param balanced_loading the consideration of balanced loading
* @param balanced_part the part of the vehicle capacity
* @param instance the instance
* @param msg optional output messages
* @return feasibility of item position.
*/
static bool checkBalancedLoading(Item& item, Tour& tour, const bool& balanced_loading, const float& balanced_part, const Instance& instance, const bool& msg);
/**
* Check item position w.r.t. Reachability Constraint.
*
* @param item the item
* @param tour the tour
* @param lambda the minimum dimension units
* @param reachability the consideration of reachability constraint
* @param instance the instance
* @param msg optional output message
* @return feasibility of item position.
*/
static bool checkReachability(Item& item, Tour& tour, const unsigned int& lambda, const bool& reachability, Instance& instance, const bool& msg);
/**
* Calculate the total support of an item.
*
* @param item the item
* @param instance the instance
*/
static void calcItemSupport(Item& item, Instance& instance);
/**
* Calculate the support area units between two items.
*
* @param current the current item
* @param other the other item
* @return the supporting area units
*/
static int calcSupportArea(const Item& current, const Item& other);
/**
* Fills relevant sets of items.
* For each item, add all indirect supporting items,
* add all items above,
* add all items in front and
* add all items behind.
*
* @param tour the tour
* @param tourEndPos the current position of the packing process
* @param instance the instance
*/
static void getRelevantItems(Item& item, Tour& tour, const unsigned int& tourEndPos, Instance& instance);
/**
* Gets the scale factor for Reachability Constraint
* to rescale the lambda factor.
*
* @param vehicleH the vehicle height
* @return the scale factor
*/
static int getScaleFactor(const unsigned int& vehicleH);
};
}