A simple implementation process of Java code for three-dimensional packing problem

Source: Internet
Author: User

Date: July 2016
Bamboo Forest Spring Rain
qq:6996899

(i) Preface

diligently yards farming for many years, also no less in the csdn up and down things, has not contributed anything, suddenly slightly feel guilty. Just recently, the leadership assigned to design a similar warehouse management software, which involves the retailer warehouse merchandise packaging out of the library part of the problem is only encountered in commodity packing. will be thinking and share with you, if there is inappropriate, hope timely correction, can contact QQ or direct message.
  
(ii) Background and business narrative

After the customer finishes the order, the retailer stores the goods out of the warehouse, and the warehouse staff packs the items purchased by the retailer into the different types of boxes provided by the retailers and sends them to the customers.
Customers under the order contains a variety of sizes of goods, some can not be inverted, like glass bottles of drinks, fragile items, with gravity sensor equipment, are not inverted.
Suppliers provide different types of boxes to facilitate the packaging of goods two times.
The packing workers need to put different types of goods into the appropriate boxes according to the actual situation.

(iii) Description of the issue

First of all, boxing workers in the packing process need to order commodity selection box type, to assess the volume of goods and the correct ratio of box volume, this process is extremely resource-intensive, to the warehouse operation difficulties and reduce the efficiency of the operation.
Secondly, the delivery of goods will appear in the case of unreasonable packing, for example, the customer just buy a small volume of goods, received is indeed a very large and empty boxes, waste of resources at the same time, also to the user confusion, while the retailer's professionalism has also been questioned.

(iv) purpose of preparation and application of the reader

In order to help the author realize the algorithm process can clear the idea, do not lose direction.

(v) Demand (self-collation, if any deviation, forgive me)

1, the automatic calculation of an order requires a variety of sizes of the box how many.
2, the product must not be inverted (rotate 180 degrees, upside down). But some items can be laid down (rotated 90 degrees, horizontally placed).
3, as far as possible without wasting the box resources, the box as full as possible.

(vi) Definition

Term definition:

1, Box type: The model of the box, record the length and width of the box interior space higher properties. The length and Width height of box type refers to the length and width height of the box.
2, Conventional box type: The most commonly used box model, in line with most goods, as well as easy to transport the volume.
3, Special type: The most infrequently used box type, inconvenient transportation and stacking. For example: The Extra-large box type of the clothes bar, oversized refrigerator, oversized box type.
4, General Index: box-type Ordernum attribute, used to indicate priority use of the box, and the non-recommended special box. (The larger the number, the more conventional)
5, Volume: Refers to the capacity of the box.
6. Remaining Volume: How much space is left after the box is loaded into a product, and the remaining space of the box is represented by a number of smaller boxes with a good structure.
7, Volume: Refers to the volume of a commodity. (There is only one item in each box, and the remaining space will be divided into smaller 3 boxes)
8, full: The box status is full when no other items in the order are placed in the box.
9, not full: The box can also put down the order of any other small items, the box status is not full.
10, Box: There is still some space in the box, but the smallest product volume in the order is larger than the remaining volume of the box.
11, Compliance: In particular, a group of goods and a certain type of the compliance, the smaller the value, the more consistent. Compliance formula: 0-(Residual volume + volume – General index) The greater the number, the higher the compliance.

Rule definition:

1, all boxes are standard box or cube. The length and width height is the length and width of the inner circumference (measured from the inside of the box, minus the thickness of the box wall if measured from outside the box).
2, all goods are described as rectangles, the length and width of the height of the periphery length and width.
3, when packing, priority to place large items. If the big goods in the case of dissatisfaction, consider the minor commodity, until full.
4, when packing, preferred to select the small volume of the box. If the volume of a smaller box can be loaded with goods, the remaining volume will be smaller, indicating that the box is more suitable for the product. Second, preference is given to the box with the largest number of regular indices. (The larger the value, the more conventional, the smaller the value, the non-regular box or even the special box)
5, if the goods in the order have been loaded, the box is not full, try to replace the smaller volume of the box. If the box is changed back to the original box type.
6, if the goods in the order have been loaded, there is a burst box, try to replace the small one box, and then continue to pack the remaining items. If the box is now the smallest, replace it with more boxes.
7, the box type according to the degree of compliance values from large to small order. If the box can be filled, priority should be given to the case with a large compliance value.
8, the box type according to the volume from small to large order. If the box is not satisfied first try small box type.
9, the box priority to place large items, and then place the next big goods, and finally put the smallest items in the order.
10, first try to use a single box to complete an order of goods packaging, and then try to use multi-box to complete an order of merchandise packaging.
11, if all the boxes can not be loaded in a single box of all the items in the order, will be enabled multiple boxes to install goods. (Individual feature boxes may only be positive for a particular item, and the box type may not participate in the logical operation at this time.) )

(vii) Data model

Entity Relationship ER

Entity List

Entity Properties

    1. Order

    2. Order Items

    3. Commodity

    4. Box

    5. Box type

    6. Order box-Clear item

    7. Customer

(vii) Implementation process

One-time boxing process for a single product

The length and width of the product and the height of the box are as follows:

Figure A
A single item is loaded into the box as shown in the following:

The remaining space generated after loading into the box is as follows:

In cases where a product can be loaded into a box, each time it is loaded, it can produce three new spaces, the new box. The size of the three new boxes can be calculated.

If the above scheme, the length of the product, width or height of any one dimension of the value of the box is greater than the length, width or height, indicating that the box does not fit the product, you need to use other placement solutions to solve the problem. Three other programmes are listed below, together with four of the above programmes.

Other Placement Solutions

Assume that the product can not be inverted (in fact, the product in the rectangular shape, inverted and normal placement occupy space, so do not consider the situation), the second scenario is the previous one (figure III of the previous chapter) horizontal rotation 90 degrees, if the horizontal rotation of 180 degrees of goods occupy space and do not rotate no difference, so the situation is not considered, By summarizing the four scenarios, the remaining three scenarios are listed below.

Second scenario

The goods inside the box will be rotated 90 degrees to the right to get three new boxes (remaining space) in case the goods are properly placed (face up):

The third option

If the goods do not mind to put down (lie flat), then there will be a third option, in the normal display of goods (face up) case, the left tilt 90 degrees, to get the following three remaining space:

Fourth scenario

If the goods do not mind to put down (lie flat), then there will be a fourth option, in the case of the product is placed in the third scenario, the right to rotate 90 degrees, to get the following three remaining space:

(eight) Summary

Above, the one-time packing process is decomposed, each need a commodity and an empty box, and will produce three new smaller remaining space. These three pieces of space can also be considered as new chests. and new suitable for their own space-sized merchandise to match.

So, this is a recursive algorithm, the method of entering a commodity and a box, each recursive will produce three new boxes, new boxes can be loaded into other smaller goods.

This cycle is so repeated that the process will end automatically until every new box is loaded with the smallest items, or if no goods can be loaded into the box. This is a recursive export condition.

In fact, of course, it is not so simple, the products shown in Figure II are at least divided into 4 kinds of methods, each need to try, in order to obtain the most reasonable remaining space; There is also an order multi-commodity multi-box.

(ix) problems that may exist

1, the box is not actually filled (the definition of "full" is not defined in this article).
2, the user will think the system recommended packing scheme is not too reasonable arrangement. The special box is matched to the regular product. For example: There may be a particularly slender box type, and a commodity is exactly the length of the width of the match, a lot of pieces of code, just fill, this is a very wonderful ending, need special consideration.
3, some boxes and goods need to be manually matched, because some boxes are designed specifically for the designated products.

(10) Epilogue

Programmers are always immersed in their own world, ignoring their friends, parents, wives and children, the recent floods in the south, and the stubborn father just recognization back, life is always so many unhappy.

If this article has a bit of value, it is for the people I need to be thankful for ...
  
The above is only for the individual immature ideas, if there is inappropriate, please correct me! It's easier said than done, the code is being tidied up, and then affixed ...

A simple implementation process of Java code for three-dimensional packing problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.