Library to optimise picking in the warehouse This library includes algorithms that should lead to improvements in picking path optimization in the warehouse. Any specifications that

Loading...
Searching...
No Matches
WarehousePickingOpt.h
Go to the documentation of this file.
1
12#ifndef _WAREHOUSE_PICKING_OPTIMIZATION_H_
13#define _WAREHOUSE_PICKING_OPTIMIZATION_H_
14
15#include <string>
16#include <list>
17#include <vector>
18#include <map>
19#include <math.h>
20
21 using namespace std;
22
23// incomplete declarations ===============
24 class Box;
25 class Cart;
26 class CartShelf;
27 class OItem;
28 class BoxItem;
29 class Customer;
30
31// class SolverConfiguration;
32// class CartConfiguration;
33// class BoxConfiguration;
34
35//================================NOT SURE / setup_configuration.h ====================================================
37 enum BPAlgorithms
38{
39 FFD_1D_ORDER_ITEMS_NO_SPLIT,
40 FFD_1D_ORDER_ITEMS_SPLIT_ONE_BOX_TYPE,
41 FFDS_1D_ORDER_ITEMS_SPLIT_MULTI_BOX_TYPE,
42 PYLIB_3D_ORDER_ITEMS_SPLIT_ONE_BOX_TYPE,
43 PYLIB_3D_FFDSEnhance_ORDER_ITEMS_SPLIT_MULTI_BOX_TYPE,
44 PYLIB_3D_ORDER_ITEMS_SPLIT_MULTI_BOX_TYPE_COUNT_DEFINED
45};
46
48 enum GroupingCustomersAlgorithms
49{
50 AVG_DISTANCES,
51 LEAST_SQUARE_APPROXIMATION,
52 K_MEANS_CLUSTERING,
53 AUTO
54};
55
57 enum ShortestPathAlgorithms
58{
59 NEAREST_NEIGHBOUR,
60 NEAREST_NEIGHBOUR_BRUTE_FORCE_OPTIMIZATION,
61 GREEDY,
62 GREEDY_BRUTE_FORCE_OPTIMIZATION,
63 JUST_MEASURE_DISTANCE,
64 NONE
65};
66
68 class SolverConfiguration
69{
70 public:
75 SolverConfiguration(
76 BPAlgorithms _bp_alg = BPAlgorithms::FFD_1D_ORDER_ITEMS_NO_SPLIT,
77 GroupingCustomersAlgorithms _grouping_customers_alg = GroupingCustomersAlgorithms::AVG_DISTANCES,
78 ShortestPathAlgorithms _shortest_path_alg = ShortestPathAlgorithms::NEAREST_NEIGHBOUR);
79
81 int Number_of_K_Means_Iterations = 40;
83 float percentage_kmeans = 0.91;
84
85 BPAlgorithms getBPAlgorithm();
86 GroupingCustomersAlgorithms getGroupingCustomerAlgorithm();
87 ShortestPathAlgorithms getShortestPathAlgorithm();
88
89 private:
90 BPAlgorithms bp_algorithm;
91 GroupingCustomersAlgorithms grouping_customers_algorithm;
92 ShortestPathAlgorithms shortest_path_algorithm;
93};
94
96 class BoxConfiguration
97{
98 private:
100 vector<pair<Box, int>> box_types_count_vect;
101 vector<Box> box_types_vect;
102
103 public:
108 void addBox(Box b, long count = -1);
109
110 vector<pair<Box, int>> getBoxesWCountVector();
111
112 vector<Box> getBoxesVector();
115 Box getFirstBox();
116};
117
118 class CartConfiguration
119{
120 private:
122 vector<Cart> cart_pattern;
123
125 vector<CartShelf> cart_shelf_vect;
126
127 float cart_width = 0;
128 float cart_height = 0;
129 float cart_depth = 0;
130
131 // TODO not used...
132 float usable_capacity = 0;
133
134 int number_of_shelves = 0;
135
136 public:
146 CartConfiguration(float _cart_width, float _cart_height, float _cart_depth, float _usable_capacity, int _number_of_shelves);
147
150 Cart getCartPattern();
151
154 void removeCartShelves();
155
158 void addCartShelf(float _shelf_width, float _shelf_height, float _shelf_depth, float _usable_capacity);
159};
160
161//================================NOT SURE / waddress.h ====================================================
163 struct SECTOR_ADDR_T
164{
165 string section{}; // G00,V02,GP1,P00,... (may vary depending on usage)
166 int y_coord = 0; // floor row[Y-axis]
167 int z_coord = 0; // regal_floor(00-04/15)[Z-axis]
168 int x_coord = 0; // cell[X-axis]
169 int x_coord_original = 0; // original x coord right from the address
170 int y_coord_original = 0; // original y coord right from the address
171 int z_coord_original = 0; // original z coord right from the address
172
173 inline bool operator==(const SECTOR_ADDR_T &lhs)
174 {
175 return (lhs.x_coord == x_coord && lhs.y_coord == y_coord);
176 }
177};
178
180 class WAddress
181{
182 public:
185 WAddress(string raw_sector_addr);
186
188 ~WAddress();
189
192 SECTOR_ADDR_T getWarehouseWAddress();
193
196 string getRawSectorAddress();
197
198 private:
200 SECTOR_ADDR_T parsed_sector_addr;
201
203 string raw_sector_addr;
204};
205
206//================================NOT SURE / warehouse.h ===================================================
208 class Warehouse
209{
210 private:
212 int width_x;
213
215 int height_y;
216
217 public:
219 Warehouse();
220 ~Warehouse();
221
224 int getDistanceBetweenAddresses(WAddress first_addr, WAddress second_addr);
225
231 int getDistanceBetweenAddresses(SECTOR_ADDR_T first_addr, SECTOR_ADDR_T second_addr);
232};
233
234//============================== NOT SURE / general_declarations.h==========================================
236 class ItemSpecification
237{
238 public:
240 enum class Type
241 {
242 Unit,
243 Carton,
244 Pallet
245 };
246
256 ItemSpecification(int _Product, ItemSpecification::Type _Unit, int _PackageType, int _ContentQty, float _X, float _Y, float _Z, float _Weight);
257 ItemSpecification(){};
258 ~ItemSpecification();
259
260 int Product;
261 ItemSpecification::Type Unit;
262 int PackageType;
263 int ContentQty;
264 float X;
265 float Y;
266 float Z;
267 float Weight;
268 float Volume;
269};
270
272 class OItem
273{
274 private:
276 float weight;
278 float volume;
279
280 public:
281 int Customer;
282 int Product;
283 string Address; // the address as used in real warehouse
284 int Qty;
286 WAddress *waddress;
287
289 map<ItemSpecification::Type, ItemSpecification> item_spec;
290
296 OItem(int Customer, int Product, string AddressCode, int Qty);
297 OItem() = default;
298 ~OItem();
299
301 void addItemSpecification(ItemSpecification itspec) { this->item_spec.insert({itspec.Unit, itspec}); }
302
305 float getWeight();
308 float getVolume();
309
311 void countWeightAndVolume();
312};
313
317 class BoxItem
318{
319 private:
320 public:
323 int count_of_units = 0;
324 ItemSpecification item_specification;
325 OItem order_item;
326
327 BoxItem(ItemSpecification _item_specification, OItem _order_item);
328 BoxItem() = default;
329
331 void countUnitsUp(int num);
332 void setNumOfUnits(int num);
333 int getCountOfUnits();
334
335 int getVolume();
336};
337
339 typedef struct items_into_boxes_decomposition
340{
341 vector<Box> full_box_vect;
342 vector<Box> one_item_box_vect;
343} ITEMS_IN_BOXES_DECOMP_T;
344
346 class CartShelf
347{
348 private:
349 float used_width = 0;
350
351 ITEMS_IN_BOXES_DECOMP_T boxes;
352
353 float width;
354 float height;
355 float depth;
356
357 public:
358 CartShelf(float width, float height = MAXFLOAT, float depth = MAXFLOAT);
359
360 void addBox_oneItemized(Box box);
361
362 void addBox_fullItemized(Box box);
363
364 ITEMS_IN_BOXES_DECOMP_T *getBoxes();
365
366 float getWidth();
367 float getHeight();
368 float getDepth();
369 float getFreeWidth();
370};
371
373 class Customer
374{
375 private:
376 float total_weight = 0.0f;
377 float total_volume = 0.0f;
378
381 int customer_id = -1;
382
384 vector<Box> box_vect;
385
386 public:
388 vector<OItem> item_vect;
389
390 ~Customer();
391
392 Customer(int cust_id) : customer_id(cust_id){};
393
395 void addOItem(OItem o_item);
396
398 void countTotalWeightAndVolume();
399
400 void decompIntoBoxes(BoxConfiguration &bc, SolverConfiguration &sc);
401
402 vector<Box> getBoxesDecomp();
403
404 void setBoxesDecomp(vector<Box> _box_vect);
405
406 float getTotalWeight();
407 float getTotalVolume();
408 int getCustomerID();
409};
410
413 class CartOItem
414{
415 private:
417 OItem oitem_ref;
418
419 public:
420 int RealQty = 0;
421 CartOItem(OItem &_oitem_ref);
422 void addToRealQty(int qty_to_add);
423 int getRealQty();
424
425 OItem getOItem() const;
426};
427
429 class Cart
430{
431 private:
433 vector<Customer> customer_vect;
434
436 vector<OItem> item_vect; // TODO remove
437 vector<CartOItem> cartoitem_vect;
438 void addOItemWithQty(OItem oitem, int qty);
439
441 vector<CartShelf> cart_shelves_vect;
442
444 float cart_free_space;
446 int free_boxes = 9;
447
449 int estimated_walked_distance = 0;
450
451 bool loadingCustomer_old(Customer &customer);
452 bool loadingCustomer_new(SolverConfiguration &sc, Customer &customer, bool can_be_partly_loaded = false, vector<Box> *non_loaded_boxes = NULL);
453
454 public:
455 Cart();
458 Cart(vector<CartShelf> cart_shelf_vect);
459
460 ~Cart();
461
465 bool loadCustomer(SolverConfiguration &sc, Customer &customer, bool can_be_partly_loaded = false, vector<Box> *non_loaded_boxes = NULL);
466
469 float getCartFreeSpace();
470
473 vector<Customer> getCustomerVector();
474
477 vector<OItem> getItemVector();
478 vector<CartOItem> getCartOItemVector();
479
480 vector<CartShelf> getCartShelvesVector();
482 void setCartOItemVector(vector<CartOItem> _cartoitem_vect);
483
486 void addToEstimatedWalkedDistance(int dist);
487
488 int getEstimatedWalkedDistance();
489};
490
491//===================== SHOULD BE PUBLIC ======================================================
493 class Box
494{
495 private:
498 float capacity = 0;
499
501 float free_capacity = 0;
502
504 float used_capacity = 0;
505
507 map<int, BoxItem> product_boxitem_map;
508
509 public:
511 float width, height, depth, max_weight;
512 string name;
513 float usable_capacity_percentage = 1;
514
521 Box(float width, float height, float depth, float max_weight, string name, float _usable_capacity_percentage = 1);
522 Box() = default;
523 ~Box();
524
526 float getCapacity();
527
529 float getFreeCapacity();
530
532 float getUsedCapacity();
533
535 map<int, BoxItem> getItemsInTheBox();
536
539 bool addItem(BoxItem &boxItem);
540
543 bool isEmpty();
544};
545
547 class CartsLoader
548{
549 private:
551 Warehouse warehouse;
552
554 vector<OItem> item_vect;
555
557 map<int, Customer> id_customer_map;
558
560 list<Cart> loaded_cart_list;
561
567 short chooseBestAlgorithm(
568 SolverConfiguration &solver_conf,
569 CartConfiguration &cart_conf,
570 multimap<int, Customer, greater<int>> volume_customer_map);
571
572 public:
573 CartsLoader(Warehouse &warehouse);
574 ~CartsLoader();
575
577 void loadItemsAndSpec(string path_or_text);
578
580 void loadingCartsRun(SolverConfiguration &solver_conf, CartConfiguration &cart_conf, BoxConfiguration &box_conf);
581
583 string exportCartsToJson(bool export_shelves_boxes = true, bool export_sorted_items = true);
584 void testUsedData(string path);
585 string getStats();
586 list<Cart> getLoadedCartsList();
587
588 // FIXME for testing
589 int getWholeDistance()
590 {
591 int dst = 0;
592 for (auto cart : this->loaded_cart_list)
593 dst += cart.getEstimatedWalkedDistance();
594 return dst;
595 };
596 int getAvgOfOnePiecedCustomersToCart()
597 {
598 int num = 0;
599 int max = 0;
600 for (auto cart : this->loaded_cart_list)
601 for (auto shelf : cart.getCartShelvesVector())
602 {
603 int tmp = 0;
604 for (auto box : shelf.getBoxes()->one_item_box_vect)
605 {
606 num += box.getItemsInTheBox().size();
607 tmp += box.getItemsInTheBox().size();
608 }
609 if (tmp > max)
610 max = tmp;
611 }
612 return (int)(num / this->loaded_cart_list.size());
613 }
614};
615
616//===============================================================================================
617#endif
BPAlgorithms
BPAlgorithms
type for specifing algorithm for solving BPP
Definition: WarehousePickingOpt.h:38
GroupingCustomersAlgorithms
GroupingCustomersAlgorithms
type for specifing algorithm for solving grouping of customers items to carts
Definition: WarehousePickingOpt.h:49
ITEMS_IN_BOXES_DECOMP_T
struct items_into_boxes_decomposition ITEMS_IN_BOXES_DECOMP_T
structure
ShortestPathAlgorithms
ShortestPathAlgorithms
type for specifing algorithm for solving shortest path problem while sorting items in cart
Definition: WarehousePickingOpt.h:58
BoxConfiguration
the configuration of the boxes, which will be used
Definition: setup_configuration.h:83
BoxConfiguration::addBox
void addBox(Box b, long count=-1)
add a box and its count
BoxConfiguration::getFirstBox
Box getFirstBox()
get the first box in the box vect
BoxItem
class which serves as representation of item in the box unlike OItem it doesn't represent order item ...
Definition: WarehousePickingOpt.h:318
BoxItem::count_of_units
int count_of_units
the count of UNITS of this item in the box (even if this item represents package, this variable store...
Definition: WarehousePickingOpt.h:323
BoxItem::countUnitsUp
void countUnitsUp(int num)
increase the number stored in count variable
Definition: box_item.cpp:21
Box
Box that can be loaded to the cart and which contains picked items in the warehouse.
Definition: WarehousePickingOpt.h:494
Box::addItem
bool addItem(BoxItem &boxItem)
function for adding item to box
Definition: box.cpp:52
Box::getItemsInTheBox
map< int, BoxItem > getItemsInTheBox()
Definition: box.cpp:43
Box::getCapacity
float getCapacity()
Definition: box.cpp:30
Box::isEmpty
bool isEmpty()
function returning the empty state of the box
Definition: box.cpp:48
Box::getFreeCapacity
float getFreeCapacity()
Definition: box.cpp:34
Box::getUsedCapacity
float getUsedCapacity()
Definition: box.cpp:38
Box::width
float width
usable capacity in percentage
Definition: WarehousePickingOpt.h:511
CartConfiguration
Definition: setup_configuration.h:105
CartConfiguration::getCartPattern
Cart getCartPattern()
get the created cart pattern
CartConfiguration::removeCartShelves
void removeCartShelves()
removed all shelves from cart
CartConfiguration::CartConfiguration
CartConfiguration(float _cart_width, float _cart_height, float _cart_depth, float _usable_capacity, int _number_of_shelves)
constructor for a cart pattern, this pattern will be used while creating new carts,...
CartConfiguration::addCartShelf
void addCartShelf(float _shelf_width, float _shelf_height, float _shelf_depth, float _usable_capacity)
add shelf of given parameters
CartOItem
class representing part or whole of order item in cart, differ from OItem only by added RealQty integ...
Definition: WarehousePickingOpt.h:414
CartShelf
the shelf in cart, which contains boxes
Definition: WarehousePickingOpt.h:347
Cart
class representing one Cart loaded with items from customers
Definition: WarehousePickingOpt.h:430
Cart::loadCustomer
bool loadCustomer(SolverConfiguration &sc, Customer &customer, bool can_be_partly_loaded=false, vector< Box > *non_loaded_boxes=NULL)
function for attaching customer to some cart
Definition: cart.cpp:185
Cart::getItemVector
vector< OItem > getItemVector()
Definition: cart.cpp:202
Cart::setCartOItemVector
void setCartOItemVector(vector< CartOItem > _cartoitem_vect)
setter
Definition: cart.cpp:212
Cart::getCartFreeSpace
float getCartFreeSpace()
getter for whole free space on cart
Definition: cart.cpp:192
Cart::addToEstimatedWalkedDistance
void addToEstimatedWalkedDistance(int dist)
function for counting the distance which is any person supposed to walk when handling this cart
Definition: cart.cpp:217
Cart::getCustomerVector
vector< Customer > getCustomerVector()
getter for the built customer list
Definition: cart.cpp:197
CartsLoader
main class representing something like an interface for it
Definition: WarehousePickingOpt.h:548
CartsLoader::loadingCartsRun
void loadingCartsRun(SolverConfiguration &solver_conf, CartConfiguration &cart_conf, BoxConfiguration &box_conf)
start algorithm
Definition: carts_loader.cpp:368
CartsLoader::testUsedData
void testUsedData(string path)
Definition: carts_loader.cpp:121
CartsLoader::exportCartsToJson
string exportCartsToJson(bool export_shelves_boxes=true, bool export_sorted_items=true)
export created carts to json file, which is created in the given or root directory
Definition: carts_loader.cpp:213
CartsLoader::loadItemsAndSpec
void loadItemsAndSpec(string path_or_text)
function for loading up all items given in order with their specification
Definition: carts_loader.cpp:41
Customer
class representing the customer object (containing its items in warehouse - in order)
Definition: WarehousePickingOpt.h:374
Customer::item_vect
vector< OItem > item_vect
all items that belongs to the customer
Definition: WarehousePickingOpt.h:388
Customer::addOItem
void addOItem(OItem o_item)
add item to this customer
Definition: customer.cpp:17
Customer::countTotalWeightAndVolume
void countTotalWeightAndVolume()
function which counts volume and weight of all items
Definition: customer.cpp:23
ItemSpecification
Definition: WarehousePickingOpt.h:237
ItemSpecification::Type
Type
enum for item specification type (can be either Unit or Car as whole package of items)
Definition: WarehousePickingOpt.h:241
OItem
class representing the item in order (with its address, and all description) -> Order Item
Definition: WarehousePickingOpt.h:273
OItem::getWeight
float getWeight()
getter of item weight
Definition: oitem.cpp:25
OItem::countWeightAndVolume
void countWeightAndVolume()
function for counting the volume and weight of this item (because this item can include more units)
Definition: oitem.cpp:35
OItem::waddress
WAddress * waddress
address in its representation for algorithm proposes
Definition: WarehousePickingOpt.h:286
OItem::getVolume
float getVolume()
getter of item volume
Definition: oitem.cpp:30
OItem::addItemSpecification
void addItemSpecification(ItemSpecification itspec)
adding the item specification
Definition: WarehousePickingOpt.h:301
OItem::item_spec
map< ItemSpecification::Type, ItemSpecification > item_spec
item specification reference
Definition: WarehousePickingOpt.h:289
SolverConfiguration
object representing the setup for problem solving
Definition: setup_configuration.h:57
SolverConfiguration::SolverConfiguration
SolverConfiguration(BPAlgorithms _bp_alg=BPAlgorithms::FFD_1D_ORDER_ITEMS_NO_SPLIT, GroupingCustomersAlgorithms _grouping_customers_alg=GroupingCustomersAlgorithms::AVG_DISTANCES, ShortestPathAlgorithms _shortest_path_alg=ShortestPathAlgorithms::NEAREST_NEIGHBOUR)
constructor, when no params set the default are used
SolverConfiguration::Number_of_K_Means_Iterations
int Number_of_K_Means_Iterations
when selected K-means clustering, this is maximal number of iterations
Definition: setup_configuration.h:69
SolverConfiguration::percentage_kmeans
float percentage_kmeans
when selected K-means clustering, this is the optimal koeficient for multiplying portion (volume of w...
Definition: WarehousePickingOpt.h:83
WAddress
class representing the WAddress of product in warehouse
Definition: WarehousePickingOpt.h:181
WAddress::getRawSectorAddress
string getRawSectorAddress()
getter
Definition: waddress.cpp:47
WAddress::getWarehouseWAddress
SECTOR_ADDR_T getWarehouseWAddress()
Get the real Warehouse WAddress.
Definition: waddress.cpp:42
WAddress::~WAddress
~WAddress()
Destroy the WAddress object.
Definition: waddress.cpp:52
Warehouse
warehouse representation, distance computation
Definition: WarehousePickingOpt.h:209
Warehouse::getDistanceBetweenAddresses
int getDistanceBetweenAddresses(WAddress first_addr, WAddress second_addr)
function counting distance between two given addresses
Definition: warehouse.cpp:92
Warehouse::Warehouse
Warehouse()
constructor
Definition: warehouse.cpp:16
SECTOR_ADDR_T
this structure stores parsed address in usable form in computation
Definition: WarehousePickingOpt.h:164
items_into_boxes_decomposition
structure
Definition: WarehousePickingOpt.h:340