Learning Efficient Online 3D Bin Packing on Packing Configuration Trees

Overview

Learning Efficient Online 3D Bin Packing on Packing Configuration Trees

This repository is being continuously updated, please stay tuned!

Any code contribution is welcome! I am also looking for high-quality academic cooperation. If you are interested or have any problems, please contact me at [email protected].

We propose to enhance the practical applicability of online 3D-BPP via learning on a hierarchical packing configuration tree which makes the DRL model easy to deal with practical constraints and well-performing even with continuous solution space.

PCT

Paper

For more details, please see our paper Learning Efficient Online 3D Bin Packing on Packing Configuration Trees which has been accepted at ICLR 2022. If this code is useful for your work, please cite our paper:

@inproceedings{
zhao2022learning,
title={Learning Efficient Online 3D Bin Packing on Packing Configuration Trees},
author={Hang Zhao and Yang Yu and Kai Xu},
booktitle={International Conference on Learning Representations},
year={2022},
url={https://openreview.net/forum?id=bfuGjlCwAq}
}

Dependencies

  • Python>=3.7
  • NumPy
  • PyTorch>=1.7
  • gym

Quick start

For training online 3D-BPP on setting 2 (mentioned in our paper) with our PCT method and the default arguments:

python main.py 

The training data is generated on the fly.

Usage

Data

Describe your 3D container size and 3D item size in 'givenData.py'

For discrete settings:
container_size: A vector of length 3 describing the size of the container in the x, y, z dimension.
item_size_set:  A list records the size of each item. The size of each item is also described by a vector of length 3.

Training

For training online 3D BPP instances on setting 1 (80 internal nodes and 50 leaf nodes) nodes:

python main.py --setting 1 --internal-node-holder 80 --leaf_node_holder 50

Warm start

You can initialize a run using a pretrained model:

python main.py --load-model --model-path path/to/your model

Evaluation

To evaluate a model, you can add the --evaluate flag to evaluation.py:

python evaluation.py --evaluate --load-model --model-path path/to/your/model --load-dataset --dataset-path path/to/your/dataset

Help

python main.py -h

License

This source code is released only for academic use. Please do not use it for commercial purpose without authorization of the author.

TODO (This code will be fully published by March 2022)

1. Add heuristic baseline algorithm.
2. Add online 3D BPP environment under continuous domain. 
3. Add more user documentation and notes.
4. Add dataset and pretrained model.
5. Add other leaf node expansion schemes.
6. Feedback of various bugs is welcome.
Comments
  • AssertionError

    AssertionError

    Dear author: Thanks for your sharing! I am really interested in your work! When I type "python main.py --no-cuda ", I get that error after hours of training.

    Time version: 3-2022.03.19-12-45-46 is training Updates 15320, num timesteps 4902720, FPS 225 Last 10 training episodes: mean/median reward 7.9/8.0, min/max reward 7.1/8.4 The dist entropy 0.68102, the value loss 0.59049, the action loss 0.06197 The mean space ratio is 0.7919, the ratio threshold is0.946

    Traceback (most recent call last): File "main.py", line 61, in main(args) File "main.py", line 56, in main trainTool.train_n_steps(envs, args, device) File "/home/Online-3D-BPP-PCT/train_tools.py", line 66, in train_n_steps selectedlogProb, selectedIdx, dist_entropy, _ = self.PCT_policy(all_nodes, normFactor = factor) File "/home/.conda/envs/Online3D/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/Online-3D-BPP-PCT/model.py", line 22, in forward o, p, dist_entropy, hidden, _= self.actor(items, deterministic, normFactor = normFactor, evaluate = evaluate) File "/home/.conda/envs/Online3D/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/Online-3D-BPP-PCT/attention_model.py", line 129, in forward valid_length = valid_length) File "/home/Online-3D-BPP-PCT/attention_model.py", line 136, in _inner log_p, mask = self._get_log_p(fixed, mask) File "/home/Online-3D-BPP-PCT/attention_model.py", line 198, in _get_log_p assert not torch.isnan(log_p).any() AssertionError

    Python == 3.7.7, torch == 1.10.1, OS: Ubuntu 18.04

    opened by JSA-458 8
  • ValueError: cannot find context for 'fork'

    ValueError: cannot find context for 'fork'

    Dear author: Thanks for your sharing! I am really interested in your work! I'm a undergraduate student and new to reinforcement learning. When I type "python main.py --no-cuda ", I get that error quickly.

    Traceback (most recent call last): File "main.py", line 61, in main(args) File "main.py", line 43, in main envs = make_vec_envs(args, './logs/runinfo', True) File "G:\graduate design\code\Online-3D-BPP-PCT\envs.py", line 112, in make_vec_envs envs = ShmemVecEnv(envs, spaces, context='fork') File "G:\graduate design\code\Online-3D-BPP-PCT\wrapper\shmem_vec_env.py", line 30, in init ctx = mp.get_context(context) File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 238, in get_context return super().get_context(method) File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 192, in get_context raise ValueError('cannot find context for %r' % method) from None ValueError: cannot find context for 'fork'

    Thanks in advance.

    Regards

    opened by jia-fiee 8
  • The network structure

    The network structure

    Thank you very much for your selfless sharing. I noticed that you did not show the details of the network structure in the paper, but you showed your deep reinforcement learning network structure based on the ACKTR algorithm in the Online-3D-BPP-DRL(https://github.com/alexfrom0815/Online-3D-BPP-DRL) paper. Is the network structure of deep reinforcement learning the same in this PCT paper? Or do you have a suggestion for a quick way to see the structure of the PCT network? Thanks in advance for your reply. Best wishes for you!

    opened by TD-zane 6
  • RuntimeError: __class__ not set defining

    RuntimeError: __class__ not set defining

    Dear author: Thanks for your sharing! When I ran main.py, I got an error:

    Traceback (most recent call last): File "E:/User002/Online-3D-BPP-PCT-main/main.py", line 6, in from model import * File "E:\User002\Online-3D-BPP-PCT-main\model.py", line 4, in from attention_model import AttentionModel File "E:\User002\Online-3D-BPP-PCT-main\attention_model.py", line 9, in class AttentionModelFixed(NamedTuple): RuntimeError: class not set defining 'AttentionModelFixed' as <class 'attention_model.AttentionModelFixed'>. Was classcell propagated to type.new?

    Process finished with exit code 1

    python3.8 pytorch1.9.0

    opened by Chengjlzzz 6
  • AttributeError: 'PackingDiscrete' object has no attribute 'action_space'

    AttributeError: 'PackingDiscrete' object has no attribute 'action_space'

    Hi,

    When I type "python main.py ", I get that error quickly.

    Full error trace:

    Traceback (most recent call last): File "main.py", line 55, in main(args) File "main.py", line 40, in main envs = make_vec_envs(args, './logs/runinfo', True) File "G:\graduate design\code\Online-3D-BPP-PCT-main\envs.py", line 108, in make_vec_envs spaces = [env.observation_space, env.action_space] File "E:\anaconda\envs\Online3D\lib\site-packages\gym\core.py", line 229, in getattr return getattr(self.env, name) AttributeError: 'PackingDiscrete' object has no attribute 'action_space'

    Thanks in advance.

    Regards

    opened by TD-zane 6
  • KeyError: 'PctDiscrete-v0'

    KeyError: 'PctDiscrete-v0'

    Dear authors, while executing the main.py on a CPU mode, i get this error : "KeyError: 'PctDiscrete-v0' ", i was wondering if you could help me with this. sincerely I'm turning the code on win10, python 3.7, gym==0.15.7, torch == 1.10.1 This is the Traceback : Traceback (most recent call last): File "C:\Users\aketfi\Anaconda3\envs\3Dpacking\lib\site-packages\gym\envs\registration.py", line 132, in spec return self.env_specs[id] KeyError: 'PctDiscrete-v0'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "C:\Users\aketfi\Anaconda3\envs\3Dpacking\lib\multiprocessing\process.py", line 297, in _bootstrap self.run() File "C:\Users\aketfi\Anaconda3\envs\3Dpacking\lib\multiprocessing\process.py", line 99, in run self._target(*self._args, **self._kwargs) File "C:\Users\aketfi\Online-3D-BPP-PCT\wrapper\shmem_vec_env.py", line 131, in _subproc_worker env = env_fn_wrapper.x() File "C:\Users\aketfi\Online-3D-BPP-PCT\envs.py", line 46, in _thunk sample_right_bound = args.sample_right_bound File "C:\Users\aketfi\Anaconda3\envs\3Dpacking\lib\site-packages\gym\envs\registration.py", line 156, in make return registry.make(id, **kwargs) File "C:\Users\aketfi\Anaconda3\envs\3Dpacking\lib\site-packages\gym\envs\registration.py", line 100, in make spec = self.spec(path) File "C:\Users\aketfi\Anaconda3\envs\3Dpacking\lib\site-packages\gym\envs\registration.py", line 142, in spec raise error.UnregisteredEnv('No registered env with id: {}'.format(id))

    opened by amket2310 5
  • Is it possible to add

    Is it possible to add "preview" (like bpp-k) to the code?

    Dear author, Thanks for your sharing! I found the "BPP-K" function in your paper "Online 3D Bin Packing with Constrained Deep Reinforcement Learning" is not added to the code. Is it possible to join the preview function to the code? Thanks for your sharing again!

    opened by Chengjlzzz 4
  • AssertionError: You must specify a action space

    AssertionError: You must specify a action space

    Dear authors:

    I am trying to reproduce your experiments claimed in your ICLR paper. But I got an error "You must specify a action space", the whole error information can be found below. Would you mind please providing some helpful information for this?

    /home/liwj/gitcode/Online-3D-BPP-PCT/attention_model.py:9: DeprecationWarning: class not set defining 'AttentionModelFixed' as <class 'attention_model.AttentionModelFixed'>. Was classcell propagated to type.new? class AttentionModelFixed(NamedTuple): Please input the experiment name pct [(1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 1, 4), (1, 1, 5), (1, 2, 1), (1, 2, 2), (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 1), (1, 3, 2), (1, 3, 3), (1, 3, 4), (1, 3, 5), (1, 4, 1), (1, 4, 2), (1, 4, 3), (1, 4, 4), (1, 4, 5), (1, 5, 1), (1, 5, 2), (1, 5, 3), (1, 5, 4), (1, 5, 5), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 1, 5), (2, 2, 1), (2, 2, 2), (2, 2, 3), (2, 2, 4), (2, 2, 5), (2, 3, 1), (2, 3, 2), (2, 3, 3), (2, 3, 4), (2, 3, 5), (2, 4, 1), (2, 4, 2), (2, 4, 3), (2, 4, 4), (2, 4, 5), (2, 5, 1), (2, 5, 2), (2, 5, 3), (2, 5, 4), (2, 5, 5), (3, 1, 1), (3, 1, 2), (3, 1, 3), (3, 1, 4), (3, 1, 5), (3, 2, 1), (3, 2, 2), (3, 2, 3), (3, 2, 4), (3, 2, 5), (3, 3, 1), (3, 3, 2), (3, 3, 3), (3, 3, 4), (3, 3, 5), (3, 4, 1), (3, 4, 2), (3, 4, 3), (3, 4, 4), (3, 4, 5), (3, 5, 1), (3, 5, 2), (3, 5, 3), (3, 5, 4), (3, 5, 5), (4, 1, 1), (4, 1, 2), (4, 1, 3), (4, 1, 4), (4, 1, 5), (4, 2, 1), (4, 2, 2), (4, 2, 3), (4, 2, 4), (4, 2, 5), (4, 3, 1), (4, 3, 2), (4, 3, 3), (4, 3, 4), (4, 3, 5), (4, 4, 1), (4, 4, 2), (4, 4, 3), (4, 4, 4), (4, 4, 5), (4, 5, 1), (4, 5, 2), (4, 5, 3), (4, 5, 4), (4, 5, 5), (5, 1, 1), (5, 1, 2), (5, 1, 3), (5, 1, 4), (5, 1, 5), (5, 2, 1), (5, 2, 2), (5, 2, 3), (5, 2, 4), (5, 2, 5), (5, 3, 1), (5, 3, 2), (5, 3, 3), (5, 3, 4), (5, 3, 5), (5, 4, 1), (5, 4, 2), (5, 4, 3), (5, 4, 4), (5, 4, 5), (5, 5, 1), (5, 5, 2), (5, 5, 3), (5, 5, 4), (5, 5, 5)] Traceback (most recent call last): File "main.py", line 61, in main(args) File "main.py", line 43, in main envs = make_vec_envs(args, './logs/runinfo', True) File "/home/liwj/gitcode/Online-3D-BPP-PCT/envs.py", line 104, in make_vec_envs sample_right_bound=args.sample_right_bound File "/home/liwj/.conda/envs/pytorch-wenjie/lib/python3.7/site-packages/gym/envs/registration.py", line 601, in make env = PassiveEnvChecker(env) File "/home/liwj/.conda/envs/pytorch-wenjie/lib/python3.7/site-packages/gym/wrappers/env_checker.py", line 24, in init ), "You must specify a action space. https://www.gymlibrary.ml/content/environment_creation/" AssertionError: You must specify a action space. https://www.gymlibrary.ml/content/environment_creation/

    opened by Jayleelwj 3
  • Struggling to achieve the same performance in the discrete and continuous environment

    Struggling to achieve the same performance in the discrete and continuous environment

    Hi, excellent work on your paper and thank you so much for sharing your code! This is fascinating research! I wanted to explore your work more through the code, but I was struggling to achieve the same performance in the discrete environment and the continuous environment. I think the error is lines 160 and 164 in PCTContinuous0/bin3D.py. The break statements should be indented. This gives me the same performance between discrete and continuous :)

    opened by Jackson-Crandell 2
  • How to modify

    How to modify "internal nodes" to update the stacking space?

    Thank you for your sharing, it's an incredible job! I‘ve read your paper and am interested in the real-world experiments. I found that the size of the new box can be defined by the class bincreator, but I'd love to know how you "correct the descriptor of the corresponding internal node b ∈ B with the offset position". Could you please give a specific location in the code? Finally, I would also like to know what your LICENSE is and if I can modify it for further study and research. Thank you whatever and best wishes for you!

    opened by LugwigButMrLu 2
  • Online learning or Offline learning

    Online learning or Offline learning

    Hello,I have a question about whether this project is online or offline learning: as far as I understand, online learning is usually input one piece of data at a time (not one batch) , directly update the weights after training.While offline learning, similar to batch learning, updates the weights after a batch of training.Can we input one data for training at a time in the training of this project?

    Thank you in advance for your reply, and best wishes to you!

    opened by TD-zane 2
  • leaf node generation for real-world experiments

    leaf node generation for real-world experiments

    Hello Great work. I am curious on the following two aspects of the work in real-world use-case.

    1. Validity of the tree and leaf nodes after placing an item: In real-world scenarios, the actual pose where the robot placed the object and the pose given by the policy might differ a little because of manipulation errors and noise. Additionally, there's also a chance that the current object being placed might move or disturb the previously placed objects. In these scenarios, some of the existing nodes in the tree might not be valid(as corner points might have moved by small amount) and so the whole tree structure need to be regenerated to represent the current state of the place bin accurately. How do you address this? As far as I understood from the paper(correct me if I am wrong), only the leaf nodes are removed if they are not valid but what about the internal & leaf nodes whose values are slightly off?

    2. Orientation representation in state: While considering a new incoming item(Sx,Sy,Sz), if we want to consider the placement with more than one orientation for the item, how are these orientation values encoded into the state representation.

    opened by gokul-gokz 0
Owner
null
Api for getting bin info and getting encrypted card details for adyen.

Bin Info And Adyen Cse Enc Python api for getting bin info and getting encrypted

Roldex Stark 8 Dec 30, 2022
Official Pytorch implementation of Online Continual Learning on Class Incremental Blurry Task Configuration with Anytime Inference (ICLR 2022)

The Official Implementation of CLIB (Continual Learning for i-Blurry) Online Continual Learning on Class Incremental Blurry Task Configuration with An

NAVER AI 34 Oct 26, 2022
This repo is a C++ version of yolov5_deepsort_tensorrt. Packing all C++ programs into .so files, using Python script to call C++ programs further.

yolov5_deepsort_tensorrt_cpp Introduction This repo is a C++ version of yolov5_deepsort_tensorrt. And packing all C++ programs into .so files, using P

null 41 Dec 27, 2022
A fast, scalable, high performance Gradient Boosting on Decision Trees library, used for ranking, classification, regression and other machine learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.

Website | Documentation | Tutorials | Installation | Release Notes CatBoost is a machine learning method based on gradient boosting over decision tree

CatBoost 6.9k Jan 4, 2023
A fast, scalable, high performance Gradient Boosting on Decision Trees library, used for ranking, classification, regression and other machine learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.

Website | Documentation | Tutorials | Installation | Release Notes CatBoost is a machine learning method based on gradient boosting over decision tree

CatBoost 5.7k Feb 12, 2021
Colar: Effective and Efficient Online Action Detection by Consulting Exemplars, CVPR 2022.

Colar: Effective and Efficient Online Action Detection by Consulting Exemplars This repository is the official implementation of Colar. In this work,

LeYang 246 Dec 13, 2022
Python implementation of cover trees, near-drop-in replacement for scipy.spatial.kdtree

This is a Python implementation of cover trees, a data structure for finding nearest neighbors in a general metric space (e.g., a 3D box with periodic

Patrick Varilly 28 Nov 25, 2022
Code for: Gradient-based Hierarchical Clustering using Continuous Representations of Trees in Hyperbolic Space. Nicholas Monath, Manzil Zaheer, Daniel Silva, Andrew McCallum, Amr Ahmed. KDD 2019.

gHHC Code for: Gradient-based Hierarchical Clustering using Continuous Representations of Trees in Hyperbolic Space. Nicholas Monath, Manzil Zaheer, D

Nicholas Monath 35 Nov 16, 2022
A python library to build Model Trees with Linear Models at the leaves.

A python library to build Model Trees with Linear Models at the leaves.

Marco Cerliani 212 Dec 30, 2022
This is the paddle code for SeBoW(Self-Born wiring for neural trees), a kind of neural tree born form a large search space

SeBoW: Self-Born Wiring for neural trees(PaddlePaddle version) This is the paddle code for SeBoW(Self-Born wiring for neural trees), a kind of neural

HollyLee 13 Dec 8, 2022
This program writes christmas wish programmatically. It is using turtle as a pen pointer draw christmas trees and stars.

Introduction This is a simple program is written in python and turtle library. The objective of this program is to wish merry Christmas programmatical

Gunarakulan Gunaretnam 1 Dec 25, 2021
Simulate genealogical trees and genomic sequence data using population genetic models

msprime msprime is a population genetics simulator based on tskit. Msprime can simulate random ancestral histories for a sample of individuals (consis

Tskit developers 150 Dec 14, 2022
TreeSubstitutionCipher - Encryption system based on trees and substitution

Tree Substitution Cipher Generation Algorithm: Generate random tree. Tree nodes

stepa 1 Jan 8, 2022
TART - A PyTorch implementation for Transition Matrix Representation of Trees with Transposed Convolutions

TART This project is a PyTorch implementation for Transition Matrix Representati

Lee Sael 2 Jan 19, 2022
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

This is the Vowpal Wabbit fast online learning code. Why Vowpal Wabbit? Vowpal Wabbit is a machine learning system which pushes the frontier of machin

Vowpal Wabbit 8.1k Jan 6, 2023
Efficient-GlobalPointer - Pytorch Efficient GlobalPointer

引言 感谢苏神带来的模型,原文地址:https://spaces.ac.cn/archives/8877 如何运行 对应模型EfficientGlobalPoi

powerycy 40 Dec 14, 2022
Sequential Model-based Algorithm Configuration

SMAC v3 Project Copyright (C) 2016-2018 AutoML Group Attention: This package is a reimplementation of the original SMAC tool (see reference below). Ho

AutoML-Freiburg-Hannover 778 Jan 5, 2023
My personal Home Assistant configuration.

About This is my personal Home Assistant configuration. My guiding princile is to have full local control of all my devices. I intend everything to ru

Chris Turra 13 Jun 7, 2022