jamesbremner / pack Goto Github PK
View Code? Open in Web Editor NEW2D and 3D bin packing
License: MIT License
2D and 3D bin packing
License: MIT License
The code is based on Arash Sharif's 2012 packit4me, which is no longer supported. I have modified the modified Sharif's code to: - build on windows using codeblocks - utilize C++11 features, particularly shared pointers - merge fragmented unused space in the bins - record locations of items in bins - output 2D cutting list - output 3D packing visualization display - optional limit to exactly one bin - positional constraints An approximation algorithmis used, called first-fit decreasing (FFD). The elements are sorted in decreasing order of size, and the bins are kept in a fixed order. Each element is placed into the first bin that it fits into, without exceeding the bin capacity. How good is the approximation? The algorithm is guaranteed to return a solution that uses no more than 11/9 of the optimal number of bins (Johnson 1973). For example, on problems of 90 items, where the items are uniformly distributed from zero to one million, and the bin capacity is one million, the algorith uses an average of 47.732 bins. On these same problem instances, the optimal solution averages 47.680 bins. The FFD solution is optimal 94.694% of the time on these problem instances. (Korf 2002 http://www.aaai.org/Papers/AAAI/2002/AAAI02-110.pdf) ------------------------------------------------------------------------------------------------ This project is a library for best-fit bin packing. It is designed to be one native call and it will figure out the best way to pack 1d, 2d or 3d bin(s) with item(s). The bins should be passed in the following format: "id:dim_unit:quantity:size1xsize2xsize3:weight" The items passed like so: "id:dim_unit:constraints:quantity:size1xsize2xsize3:weight" id could be a stock or order number. example: 53443:5x5x5 constraints are for each item and if the item can be rotated: constraint = position_constraint + rotation_constraint position constraint 0 : anywhere 100 : bottom only 200 : top only rotation constraint 0 : Any 1 : Length axis only 2 : Width axis only 3 : Height axis only 7 : No rotation allowed Dependencies: 1. To compile the algorithm you need to make sure you have boost for c++ installed A simple example application demonstrates how to use this code in a standalone application. Source code at https://github.com/JamesBremner/Pack/blob/master/SourceFiles/example.cpp and codeblocks project at https://github.com/JamesBremner/Pack/blob/master/build/codeblocks/example.cbp This code can handle both 2D and 3D packing problems, but it is focussed on 3D problems. Pack2 ( https://github.com/JamesBremner/pack2 ) is optimized for 2D problems.
When testing the file after building, I get the following error:
packit4me2 -b 0:ft:1:5x5x5 -i 0:ft:0:1:1x1x1 -s b -o result
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >'
what(): unrecognised option '-b'
In Visual Studio 2015 I had a compiler error C2398: conversion from 'std::chrono::system_clock::rep' to 'unsigned int' requires a narrowing conversion.
This error arises in BoxPacker2D::packThem method here:
// randomize
std::default_random_engine engine
{
std::chrono::system_clock::now().time_since_epoch().count() };
Changing the case of initialization from braces to parentheses has solved the problem for me:
// randomize
std::default_random_engine engine
(
std::chrono::system_clock::now().time_since_epoch().count() );
About initializers and kinds of initialization one can read here.
In your main.cpp file, I cannot find stdafx.h and what is cWord? whether you lose some files in the project
As well as returning the "No bin capable of holding all items" error, the onebin option should return the best pack - as many as possible items in the largest bin and extras listed as unpacked
I would expect the ''weight' argument for bins to be a weight limit and for items to be packed until the weight limit of the bin is reached or bin fills up.
Currently it seems the algorithm is paying no attention to weight or weight limits.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.