wadaboa / 3d-bpp Goto Github PK
View Code? Open in Web Editor NEW3D bin packing solutions with layers and superitems, for Artificial Intelligence in Industry class at UNIBO
License: MIT License
3D bin packing solutions with layers and superitems, for Artificial Intelligence in Industry class at UNIBO
License: MIT License
Hi, I would like to ask, if it is possible to solve 3D online bin packing problem?
Or if anyone knows about any solution for 3D online bin packing problem, please, write :)
How can I get from main a list of all the locations of the boxes placed in the container when I use maxrects
Hi,
If I want to use this project in container loading,
for example, I hvae 4 containers with (2280,2550,12000) size (width,height,length) , I want to loading 24 small boxes with some sizes and these boxes may be loaded 3 or 4 containers.
I found the "cg" and "bl" only support only one container loading, how can I solve such cases?
Thanks
I want to use multiple pallets for a problem statement, what changes should I make to config python file?
bl_bin_pool = main.main(bl_order, procedure="bl", tlim=20)
, error appears:TypeError Traceback (most recent call last)
Input In [24], in <cell line: 1>()
----> 1 bl_bin_pool = main.main(bl_order, procedure="bl", tlim=20)
2 bl_bin_pool.get_original_layer_pool().to_dataframe()
File ~/Documents/3d-bpp/src/main.py:194, in main(order, procedure, max_iters, superitems_horizontal, superitems_horizontal_type, superitems_max_vstacked, density_tol, filtering_two_dims, filtering_max_coverage_all, filtering_max_coverage_single, tlim, enable_solver_output, height_tol, cg_use_height_groups, cg_mr_warm_start, cg_max_iters, cg_max_stag_iters, cg_sp_mr, cg_sp_np_type, cg_sp_p_type, cg_return_only_last)
192 # Call the right packing procedure
193 if procedure == "bl":
--> 194 layer_pool = baseline.baseline(superitems_pool, config.PALLET_DIMS, tlim=tlim)
195 elif procedure == "mr":
196 layer_pool = maxrects_warm_start(
197 superitems_pool, height_tol=height_tol, density_tol=density_tol, add_single=False
198 )
File ~/Documents/3d-bpp/src/baseline.py:166, in baseline(superitems_pool, pallet_dims, tlim, num_workers)
164 # Call the baseline model
165 logger.info("Solving baseline model")
--> 166 sol, solve_time = baseline_model(
167 fsi, ws, ds, hs, pallet_dims, tlim=tlim, num_workers=num_workers
168 )
169 logger.info(f"Solved baseline model in {solve_time:.2f} seconds")
File ~/Documents/3d-bpp/src/baseline.py:62, in baseline_model(fsi, ws, ds, hs, pallet_dims, tlim, num_workers)
58 # Constraints
59 # Ensure that every item is included in exactly one layer
60 for i in range(n_items):
61 model.Add(
---> 62 cp_model.LinearExpr.Sum(
63 fsi[s, i] * zsl[s, l] for s in range(n_superitems) for l in range(max_layers)
64 )
65 == 1
66 )
68 # Define the height of layer l
69 for l in range(max_layers):
File ~/Documents/nguyens-RL/nguyens-RL/lib/python3.9/site-packages/ortools/sat/python/cp_model.py:182, in LinearExpr.Sum(cls, expressions)
179 @classmethod
180 def Sum(cls, expressions):
181 """Creates the expression sum(expressions)."""
--> 182 if len(expressions) == 1:
183 return expressions[0]
184 return _SumArray(expressions)
Hi,
When I run dashboard.py, there has following error:
pyarrow.lib.ArrowInvalid: ("Could not convert 'Total' with type str: tried to convert to int64", 'Conversion failed for column layer with type object')
I think it may be caused by layer column value in bin.layer_pool.describe() is mixed which are int and string.
I transfer the layer value type:
df = bin.layer_pool.describe()
df["layer"] = df["layer"] .apply(str)
It's ok.
I'm not sure if it's a version problem that's causing these problems.
Anyway, this is the problem I encountered and the solution. I hope other people with the same problem can refer to it.
Thanks
Hi,
this is a very thankful job, u done.
I tried to play with it, but some error occurs.
In baseline.py, when reached the notebook section [35] the following error occurs: TypeError: object of type 'generator' has no len()
Conda installed python is 3.11 instead given in Dockerfile
ortools==8.2.8710 isn't installable
In every case of calling ortools 'cp_model.LinearExpr.Sum' function it returns this error.
Can You help to solve this?
Thanks
[35]
bl_bin_pool = main.main(bl_order, procedure="bl", tlim=20)
bl_bin_pool.get_original_layer_pool().to_dataframe()
2023-09-11 09:29:04.210 | INFO | baseline:baseline:165 - Solving baseline model
2023-09-11 09:29:04.201 | INFO | main:main:169 - BL procedure starting
2023-09-11 09:29:04.202 | INFO | main:main:179 - BL iteration 1/1
2023-09-11 09:29:04.205 | DEBUG | superitems:_gen_single_items_superitems:639 - Generated 20 superitems with a single item
2023-09-11 09:29:04.205 | INFO | superitems:gen_superitems:623 - Generating horizontal superitems of type 'two-width'
2023-09-11 09:29:04.206 | DEBUG | superitems:_gen_superitems_horizontal:685 - Generated 0 horizontal superitems with 2 items
2023-09-11 09:29:04.207 | DEBUG | superitems:_gen_superitems_horizontal:692 - Generated 0 horizontal superitems with 4 items
2023-09-11 09:29:04.207 | INFO | superitems:gen_superitems:626 - Generating vertical superitems with maximum stacking of 4
2023-09-11 09:29:04.208 | DEBUG | superitems:_gen_superitems_vertical:770 - Generated 15 wide vertical superitems
2023-09-11 09:29:04.209 | DEBUG | superitems:_gen_superitems_vertical:772 - Generated 0 deep vertical superitems
2023-09-11 09:29:04.209 | INFO | superitems:gen_superitems:628 - Generated 35 superitems
2023-09-11 09:29:04.209 | INFO | superitems:gen_superitems:630 - Remaining superitems after filtering by pallet dimensions: 35
2023-09-11 09:29:04.210 | INFO | baseline:baseline:165 - Solving baseline model
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[35], line 1
----> 1 bl_bin_pool = main.main(bl_order, procedure="bl", tlim=20)
2 bl_bin_pool.get_original_layer_pool().to_dataframe()
File ~/work/src/main.py:194, in main(order, procedure, max_iters, superitems_horizontal, superitems_horizontal_type, superitems_max_vstacked, density_tol, filtering_two_dims, filtering_max_coverage_all, filtering_max_coverage_single, tlim, enable_solver_output, height_tol, cg_use_height_groups, cg_mr_warm_start, cg_max_iters, cg_max_stag_iters, cg_sp_mr, cg_sp_np_type, cg_sp_p_type, cg_return_only_last)
192 # Call the right packing procedure
193 if procedure == "bl":
--> 194 layer_pool = baseline.baseline(superitems_pool, config.PALLET_DIMS, tlim=tlim)
195 elif procedure == "mr":
196 layer_pool = maxrects_warm_start(
197 superitems_pool, height_tol=height_tol, density_tol=density_tol, add_single=False
198 )
File ~/work/src/baseline.py:166, in baseline(superitems_pool, pallet_dims, tlim, num_workers)
164 # Call the baseline model
165 logger.info("Solving baseline model")
--> 166 sol, solve_time = baseline_model(
167 fsi, ws, ds, hs, pallet_dims, tlim=tlim, num_workers=num_workers
168 )
169 logger.info(f"Solved baseline model in {solve_time:.2f} seconds")
171 # Build the layer pool from the model's solution
File ~/work/src/baseline.py:62, in baseline_model(fsi, ws, ds, hs, pallet_dims, tlim, num_workers)
58 # Constraints
59 # Ensure that every item is included in exactly one layer
60 for i in range(n_items):
61 model.Add(
---> 62 cp_model.LinearExpr.Sum(
63 fsi[s, i] * zsl[s, l] for s in range(n_superitems) for l in range(max_layers)
64 )
65 == 1
66 )
68 # Define the height of layer l
69 for l in range(max_layers):
File /opt/conda/lib/python3.11/site-packages/ortools/sat/python/cp_model.py:183, in LinearExpr.Sum(cls, expressions)
180 @classmethod
181 def Sum(cls, expressions):
182 """Creates the expression sum(expressions)."""
--> 183 if len(expressions) == 1:
184 return expressions[0]
185 return _SumArray(expressions)
TypeError: object of type 'generator' has no len()
I tried to convert it to a docker container with the following params:
The Dockerfile:
FROM jupyter/base-notebook
# Name your environment and choose the python version
ARG env_name=python3.9.6
ARG py_ver=3.9.6
COPY --chown=${NB_UID}:${NB_GID} /init/requirements.txt /tmp/
COPY --chown=${NB_UID}:${NB_GID} /init/environment.yml /tmp/
RUN mamba env create -p "${CONDA_DIR}/envs/${env_name}" -f /tmp/environment.yml && \
mamba clean --all -f -y
# Create Python kernel and link it to jupyter
RUN "${CONDA_DIR}/envs/${env_name}/bin/python" -m ipykernel install --user --name="${env_name}" && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
RUN "${CONDA_DIR}/envs/${env_name}/bin/pip" install --no-cache-dir \
'flake8'
USER root
RUN apt update -y
RUN apt install git -y
RUN pip install --no-cache-dir -r /tmp/requirements.txt
#USER ${NB_UID}
RUN pip install git+https://github.com/IsaGrue/nb_black.git
USER root
RUN activate_custom_env_script=/usr/local/bin/before-notebook.d/activate_custom_env.sh && \
echo "#!/bin/bash" > ${activate_custom_env_script} && \
echo "eval \"$(conda shell.bash activate "${env_name}")\"" >> ${activate_custom_env_script} && \
chmod +x ${activate_custom_env_script}
USER ${NB_UID}
RUN echo "conda activate ${env_name}" >> "${HOME}/.bashrc"
The docker-compose.yaml
version: "3"
services:
app:
container_name: 3dp-packing
build:
context: .
dockerfile: ./Dockerfile
# command: flask --app ./src/hello --debug run --host=0.0.0.0 --port=8080
image: 3dp-packing:latest
volumes:
- ${PWD}/work:/home/jovyan/work
ports:
- 8888:8888
- 8787:8787
requirements.txt
numpy
pandas
ortools==9.5.2237
matplotlib
ipympl==0.7.0
rectpack
tqdm==4.60.0
scipy
seaborn
streamlit==1.8.1
watchdogs==1.8.2
loguru==0.5.3
environment.yaml
name: 3d-bpp
channels:
- conda-forge
- defaults
dependencies:
- black==21.7b0
- loguru==0.5.3
- matplotlib==3.4.2
- nb_black==1.0.7
- numpy
- pandas
- pip==21.2.1
- python==3.9.6
- seaborn==0.11.2
- tqdm==4.61.2
- streamlit==0.85.1
- pip:
- ortools==9.5.2237
- rectpack==0.2.2
When running this line of code:
bl_bin_pool = main.main(bl_order, procedure="bl", tlim=20)
bl_bin_pool.get_original_layer_pool().to_dataframe()
I get this error:
---> 18 self.dimensions = utils.Dimension(width, depth, height, weight)
AttributeError: module 'utils' has no attribute 'Dimension'
How can I solve it?
got a Keyerror when using the baseline algorithm
File c:\Users\g7morsj22l\Documents\02_Code_Repos\3d-bpp\src\baseline.py:174, in baseline(superitems_pool, pallet_dims, tlim, num_workers)
172 layer_pool = layers.LayerPool(superitems_pool, pallet_dims)
173 for l in range(max_layers):
--> 174 if sol[f"o_{l}"] > 0:
175 superitems_in_layer = [s for s in range(n_superitems) if sol[f"z_{s}_{l}"] == 1]
176 layer = utils.build_layer_from_model_output(
177 superitems_pool, superitems_in_layer, sol, pallet_dims
Hi,
first of all, thanks a lot for sharing.
Regarding the improved part you mentioned in your report, is it in the work plan in the near future?
I would like to know how to make the project support 3D rotation, can you give me some advices?
Thanks,
Zhe.
Hello,
Do you have a running configuration for any >= Python 3.7 case?
Best,
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.