How xiong5heng/gopt works
Project Type and Purpose
• GOPT is a research codebase that implements a deep‐reinforcement‐learning (DRL) solution for online 3D bin‐packing.
• It uses a custom “Packing” environment and a Transformer‐based policy network, built on top of PyTorch and the Tianshou RL library.
File Structure
• Top‐level scripts:
• ts_train.py – starts training
• ts_test.py – runs evaluation and optional rendering
• arguments.py, tools.py – parsing command lines, helper routines
• model.py – defines the Transformer policy
• masked_a2c.py / masked_ppo.py – wrappers for specific algorithms
• mycollector.py – custom data collector for Tianshou
• render.py – visualization code
• Configuration:
• cfg/config.yaml & cfg/default.yaml – all hyperparameters (env name, bin size, learning rates)
• Custom Environment:
• Vendored Tianshou library:
• tianshou/… – data buffers, policies, trainers, utilities
Key Technologies and Layers
• Configuration layer (YAML files + arguments.py)
• Environment layer (envs/Packing)
• Policy/model layer (model.py + Tianshou policy classes)
• Data collection & replay buffers (mycollector.py + tianshou/data/buffer)
• Trainer layer (tianshou/trainer + ts_train.py)
• Evaluation & rendering (ts_test.py + render.py)
• External frameworks: PyTorch, Tianshou, optional Ray for parallel envs
Main Components and Their Interactions
a. Configuration Loader
• Reads cfg/config.yaml
• Feeds parameters to environment, model, trainer
b. Environment Component
• Wraps into Tianshou Gym-style envs
c. Policy (Transformer)
• model.py defines architecture
• Uses features from env (bin state, item state)
d. Data Collector
• mycollector.py interacts policy and env to gather experiences
• Sends data to Tianshou’s replay buffer
e. Replay Buffer & Sampling
• tianshou/data/buffer handles prioritized or standard buffer
f. Trainer
• tianshou/trainer/onpolicy or offpolicy updates the policy
g. Evaluation & Rendering
• ts_test.py runs episodes with trained policy
• render.py shows 3D packing sequence
h. Scripts
• ts_train.py ties config → env → collector → trainer
• ts_test.py ties config → env → policy → renderer
• Optional: annotate the scripts (ts_train.py, ts_test.py) that orchestrate each flow