py3dbc 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py3dbc-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sarth Satpute
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
py3dbc-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,259 @@
1
+ Metadata-Version: 2.4
2
+ Name: py3dbc
3
+ Version: 1.0.0
4
+ Summary: 3D Bin Packing for Containers - Maritime optimization with ship stability physics
5
+ Home-page: https://github.com/SarthSatpute/py3dbc
6
+ Author: Sarth Satpute
7
+ Author-email: your.email@example.com
8
+ License: MIT
9
+ Project-URL: Bug Tracker, https://github.com/SarthSatpute/py3dbc/issues
10
+ Project-URL: Documentation, https://github.com/SarthSatpute/py3dbc#readme
11
+ Project-URL: Source Code, https://github.com/SarthSatpute/py3dbc
12
+ Keywords: 3d-bin-packing,container-optimization,maritime,ship-stability,logistics,cargo
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: py3dbp>=1.1.0
28
+ Requires-Dist: pandas>=1.3.0
29
+ Requires-Dist: numpy>=1.21.0
30
+ Dynamic: author
31
+ Dynamic: author-email
32
+ Dynamic: classifier
33
+ Dynamic: description
34
+ Dynamic: description-content-type
35
+ Dynamic: home-page
36
+ Dynamic: keywords
37
+ Dynamic: license
38
+ Dynamic: license-file
39
+ Dynamic: project-url
40
+ Dynamic: requires-dist
41
+ Dynamic: requires-python
42
+ Dynamic: summary
43
+
44
+ <div align="center">
45
+
46
+ # 🚢 py3dbc
47
+
48
+ ### 3D Bin Packing for Containers
49
+
50
+ *Maritime optimization library with ship stability physics*
51
+
52
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
53
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
54
+ [![Based on py3dbp](https://img.shields.io/badge/extends-py3dbp-orange)](https://github.com/jerry800416/3D-bin-packing)
55
+
56
+ ---
57
+
58
+ </div>
59
+
60
+ ## 📖 What is py3dbc?
61
+
62
+ **py3dbc** (3D Bin Packing for Containers) extends the popular [py3dbp](https://github.com/jerry800416/3D-bin-packing) library with **maritime-specific features** for container ship cargo optimization.
63
+
64
+ While py3dbp handles general 3D packing, it doesn't account for **ship stability physics** or **maritime safety regulations**. py3dbc bridges this gap.
65
+
66
+ ---
67
+
68
+ ## 🎯 Key Features
69
+
70
+ ### ⚓ Ship Stability Validation
71
+ - Real-time **metacentric height (GM)** calculations
72
+ - Ensures ships won't capsize due to poor weight distribution
73
+ - Validates safety after every container placement
74
+
75
+ ### 🛡️ Maritime Safety Constraints
76
+ - **Hazmat Separation:** Keeps dangerous goods at safe distances
77
+ - **Reefer Power:** Allocates refrigerated containers to powered slots
78
+ - **Weight Limits:** Enforces tier capacity and stacking restrictions
79
+ - **Regulatory Compliance:** Follows IMO and maritime standards
80
+
81
+ ### 📦 Container Types
82
+ - General cargo (standard containers)
83
+ - Reefer containers (refrigerated, need power)
84
+ - Hazmat containers (dangerous goods, need separation)
85
+ - Automatic TEU calculation (20ft = 1 TEU, 40ft = 2 TEU)
86
+
87
+ ### 🏗️ Realistic Ship Structure
88
+ - Discrete **bay/row/tier** slot grid (matches real ship geometry)
89
+ - 3D coordinates for each slot
90
+ - Stack weight tracking per position
91
+
92
+ ---
93
+
94
+ ## 🚀 Quick Start
95
+
96
+ ### Installation
97
+
98
+ ```bash
99
+ pip install py3dbp pandas numpy
100
+ git clone https://github.com/yourusername/py3dbc.git
101
+ cd py3dbc
102
+ pip install -e .
103
+ ```
104
+
105
+ ### Basic Usage
106
+
107
+ ```python
108
+ from py3dbc.maritime.ship import ContainerShip
109
+ from py3dbc.maritime.container import MaritimeContainer
110
+ from py3dbc.maritime.packer import MaritimePacker
111
+
112
+ # Create ship
113
+ ship = ContainerShip(
114
+ ship_name='FEEDER_01',
115
+ bays=7, rows=14, tiers=7,
116
+ stability_params={'kg_lightship': 6.5, 'gm_min': 0.3, ...}
117
+ )
118
+
119
+ # Create containers
120
+ containers = [
121
+ MaritimeContainer('GEN001', '20ft', 'general', 22.5, dimensions),
122
+ MaritimeContainer('REF001', '20ft', 'reefer', 18.0, dimensions),
123
+ MaritimeContainer('HAZ001', '20ft', 'hazmat', 14.5, dimensions)
124
+ ]
125
+
126
+ # Optimize placement
127
+ packer = MaritimePacker(ship)
128
+ result = packer.pack(containers, strategy='heavy_first')
129
+
130
+ # Check results
131
+ print(f"Success Rate: {result['metrics']['placement_rate']}%")
132
+ print(f"Ship Stable: {result['metrics']['is_stable']}")
133
+ print(f"Final GM: {result['metrics']['gm']}m")
134
+ ```
135
+
136
+ ---
137
+
138
+ ## 🧮 How It Works
139
+
140
+ ### Stability Physics
141
+
142
+ py3dbc calculates **metacentric height (GM)** using naval architecture principles:
143
+
144
+ ```
145
+ GM = KB + BM - KG
146
+
147
+ Where:
148
+ KB = Center of buoyancy (ship constant)
149
+ BM = Metacentric radius (ship geometry)
150
+ KG = Center of gravity (changes as cargo loads)
151
+
152
+ If GM < minimum → Ship is unstable (placement rejected)
153
+ ```
154
+
155
+ ### Optimization Process
156
+
157
+ 1. **Sort containers** (heavy first, by priority, or hazmat first)
158
+ 2. **For each container:**
159
+ - Find available slots
160
+ - Check constraints (weight, power, separation, stability)
161
+ - Score valid slots (tier preference, centerline, stability margin)
162
+ - Place in best slot
163
+ 3. **Update ship state** (weight, GM, occupancy)
164
+ 4. **Repeat** until all containers placed or no valid slots remain
165
+
166
+ ---
167
+
168
+ ## 📊 Performance
169
+
170
+ Tested on realistic scenarios:
171
+ - **91% placement rate** (576 of 632 containers)
172
+ - **84% slot utilization** (vs 60-70% manual planning)
173
+ - **100% stability compliance** (GM always above minimum)
174
+ - **Processes 600+ containers in under 2 minutes**
175
+
176
+ ---
177
+
178
+ ## 🔧 Use Cases
179
+
180
+ - **Port Operations:** Automated cargo loading plans
181
+ - **Maritime Logistics:** Pre-planning container placement
182
+ - **Safety Validation:** Verify manual loading plans meet stability requirements
183
+ - **Training/Education:** Demonstrate naval architecture principles
184
+ - **Research:** Maritime optimization algorithms
185
+
186
+ ---
187
+
188
+ ## 📚 Documentation
189
+
190
+ ### Main Classes
191
+
192
+ **MaritimeContainer**
193
+ - Extends py3dbp's `Item` class
194
+ - Adds cargo type, hazmat class, reefer flag, TEU value
195
+
196
+ **ContainerShip**
197
+ - Extends py3dbp's `Bin` class
198
+ - Adds bay/row/tier grid structure, stability parameters
199
+
200
+ **MaritimePacker**
201
+ - Optimization engine with constraint validation
202
+ - Multiple strategies: heavy_first, priority, hazmat_first
203
+
204
+ **StabilityCalculator**
205
+ - Naval architecture physics (GM/KG calculations)
206
+ - Real-time stability validation
207
+
208
+ **MaritimeConstraintChecker**
209
+ - Validates weight limits, hazmat separation, reefer power
210
+ - Ensures regulatory compliance
211
+
212
+ ---
213
+
214
+ ## 🎓 Academic Use
215
+
216
+ py3dbc was developed as part of a B.Tech final year project at **K.K. Wagh Institute of Engineering, Nashik**.
217
+
218
+ **Project:** CargoOptix - Automated Ship Load Balancing System
219
+ **Objective:** Combine constraint-based optimization with naval architecture physics
220
+ **Result:** Practical maritime optimization system with real-time safety validation
221
+
222
+ ---
223
+
224
+ ## 🤝 Contributing
225
+
226
+ Contributions welcome! Areas for enhancement:
227
+ - Genetic algorithm implementation
228
+ - Multi-port discharge sequencing
229
+ - Crane scheduling integration
230
+ - Real-time weight sensor integration
231
+ - Machine learning for slot prediction
232
+
233
+ ---
234
+
235
+ ## 📄 License
236
+
237
+ This project is licensed under the MIT License - see [LICENSE](LICENSE) file.
238
+
239
+
240
+ ---
241
+
242
+
243
+ ---
244
+
245
+ ## 📞 Contact
246
+
247
+ **Project Repository:** [github.com/SarthSatpute/py3dbc](https://github.com/SarthSatpute/py3dbc)
248
+ **Issues/Questions:** Open an issue on GitHub
249
+ **Related Project:** [CargoOptix]([https://github.com/SarthSatpute/CargoOptix]) - Full web application using py3dbc
250
+
251
+ ---
252
+
253
+ <div align="center">
254
+
255
+ **Built with ❤️ for safer, more efficient maritime operations**
256
+
257
+ ⭐ Star this repo if you find it useful!
258
+
259
+ </div>
py3dbc-1.0.0/README.md ADDED
@@ -0,0 +1,216 @@
1
+ <div align="center">
2
+
3
+ # 🚢 py3dbc
4
+
5
+ ### 3D Bin Packing for Containers
6
+
7
+ *Maritime optimization library with ship stability physics*
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
11
+ [![Based on py3dbp](https://img.shields.io/badge/extends-py3dbp-orange)](https://github.com/jerry800416/3D-bin-packing)
12
+
13
+ ---
14
+
15
+ </div>
16
+
17
+ ## 📖 What is py3dbc?
18
+
19
+ **py3dbc** (3D Bin Packing for Containers) extends the popular [py3dbp](https://github.com/jerry800416/3D-bin-packing) library with **maritime-specific features** for container ship cargo optimization.
20
+
21
+ While py3dbp handles general 3D packing, it doesn't account for **ship stability physics** or **maritime safety regulations**. py3dbc bridges this gap.
22
+
23
+ ---
24
+
25
+ ## 🎯 Key Features
26
+
27
+ ### ⚓ Ship Stability Validation
28
+ - Real-time **metacentric height (GM)** calculations
29
+ - Ensures ships won't capsize due to poor weight distribution
30
+ - Validates safety after every container placement
31
+
32
+ ### 🛡️ Maritime Safety Constraints
33
+ - **Hazmat Separation:** Keeps dangerous goods at safe distances
34
+ - **Reefer Power:** Allocates refrigerated containers to powered slots
35
+ - **Weight Limits:** Enforces tier capacity and stacking restrictions
36
+ - **Regulatory Compliance:** Follows IMO and maritime standards
37
+
38
+ ### 📦 Container Types
39
+ - General cargo (standard containers)
40
+ - Reefer containers (refrigerated, need power)
41
+ - Hazmat containers (dangerous goods, need separation)
42
+ - Automatic TEU calculation (20ft = 1 TEU, 40ft = 2 TEU)
43
+
44
+ ### 🏗️ Realistic Ship Structure
45
+ - Discrete **bay/row/tier** slot grid (matches real ship geometry)
46
+ - 3D coordinates for each slot
47
+ - Stack weight tracking per position
48
+
49
+ ---
50
+
51
+ ## 🚀 Quick Start
52
+
53
+ ### Installation
54
+
55
+ ```bash
56
+ pip install py3dbp pandas numpy
57
+ git clone https://github.com/yourusername/py3dbc.git
58
+ cd py3dbc
59
+ pip install -e .
60
+ ```
61
+
62
+ ### Basic Usage
63
+
64
+ ```python
65
+ from py3dbc.maritime.ship import ContainerShip
66
+ from py3dbc.maritime.container import MaritimeContainer
67
+ from py3dbc.maritime.packer import MaritimePacker
68
+
69
+ # Create ship
70
+ ship = ContainerShip(
71
+ ship_name='FEEDER_01',
72
+ bays=7, rows=14, tiers=7,
73
+ stability_params={'kg_lightship': 6.5, 'gm_min': 0.3, ...}
74
+ )
75
+
76
+ # Create containers
77
+ containers = [
78
+ MaritimeContainer('GEN001', '20ft', 'general', 22.5, dimensions),
79
+ MaritimeContainer('REF001', '20ft', 'reefer', 18.0, dimensions),
80
+ MaritimeContainer('HAZ001', '20ft', 'hazmat', 14.5, dimensions)
81
+ ]
82
+
83
+ # Optimize placement
84
+ packer = MaritimePacker(ship)
85
+ result = packer.pack(containers, strategy='heavy_first')
86
+
87
+ # Check results
88
+ print(f"Success Rate: {result['metrics']['placement_rate']}%")
89
+ print(f"Ship Stable: {result['metrics']['is_stable']}")
90
+ print(f"Final GM: {result['metrics']['gm']}m")
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 🧮 How It Works
96
+
97
+ ### Stability Physics
98
+
99
+ py3dbc calculates **metacentric height (GM)** using naval architecture principles:
100
+
101
+ ```
102
+ GM = KB + BM - KG
103
+
104
+ Where:
105
+ KB = Center of buoyancy (ship constant)
106
+ BM = Metacentric radius (ship geometry)
107
+ KG = Center of gravity (changes as cargo loads)
108
+
109
+ If GM < minimum → Ship is unstable (placement rejected)
110
+ ```
111
+
112
+ ### Optimization Process
113
+
114
+ 1. **Sort containers** (heavy first, by priority, or hazmat first)
115
+ 2. **For each container:**
116
+ - Find available slots
117
+ - Check constraints (weight, power, separation, stability)
118
+ - Score valid slots (tier preference, centerline, stability margin)
119
+ - Place in best slot
120
+ 3. **Update ship state** (weight, GM, occupancy)
121
+ 4. **Repeat** until all containers placed or no valid slots remain
122
+
123
+ ---
124
+
125
+ ## 📊 Performance
126
+
127
+ Tested on realistic scenarios:
128
+ - **91% placement rate** (576 of 632 containers)
129
+ - **84% slot utilization** (vs 60-70% manual planning)
130
+ - **100% stability compliance** (GM always above minimum)
131
+ - **Processes 600+ containers in under 2 minutes**
132
+
133
+ ---
134
+
135
+ ## 🔧 Use Cases
136
+
137
+ - **Port Operations:** Automated cargo loading plans
138
+ - **Maritime Logistics:** Pre-planning container placement
139
+ - **Safety Validation:** Verify manual loading plans meet stability requirements
140
+ - **Training/Education:** Demonstrate naval architecture principles
141
+ - **Research:** Maritime optimization algorithms
142
+
143
+ ---
144
+
145
+ ## 📚 Documentation
146
+
147
+ ### Main Classes
148
+
149
+ **MaritimeContainer**
150
+ - Extends py3dbp's `Item` class
151
+ - Adds cargo type, hazmat class, reefer flag, TEU value
152
+
153
+ **ContainerShip**
154
+ - Extends py3dbp's `Bin` class
155
+ - Adds bay/row/tier grid structure, stability parameters
156
+
157
+ **MaritimePacker**
158
+ - Optimization engine with constraint validation
159
+ - Multiple strategies: heavy_first, priority, hazmat_first
160
+
161
+ **StabilityCalculator**
162
+ - Naval architecture physics (GM/KG calculations)
163
+ - Real-time stability validation
164
+
165
+ **MaritimeConstraintChecker**
166
+ - Validates weight limits, hazmat separation, reefer power
167
+ - Ensures regulatory compliance
168
+
169
+ ---
170
+
171
+ ## 🎓 Academic Use
172
+
173
+ py3dbc was developed as part of a B.Tech final year project at **K.K. Wagh Institute of Engineering, Nashik**.
174
+
175
+ **Project:** CargoOptix - Automated Ship Load Balancing System
176
+ **Objective:** Combine constraint-based optimization with naval architecture physics
177
+ **Result:** Practical maritime optimization system with real-time safety validation
178
+
179
+ ---
180
+
181
+ ## 🤝 Contributing
182
+
183
+ Contributions welcome! Areas for enhancement:
184
+ - Genetic algorithm implementation
185
+ - Multi-port discharge sequencing
186
+ - Crane scheduling integration
187
+ - Real-time weight sensor integration
188
+ - Machine learning for slot prediction
189
+
190
+ ---
191
+
192
+ ## 📄 License
193
+
194
+ This project is licensed under the MIT License - see [LICENSE](LICENSE) file.
195
+
196
+
197
+ ---
198
+
199
+
200
+ ---
201
+
202
+ ## 📞 Contact
203
+
204
+ **Project Repository:** [github.com/SarthSatpute/py3dbc](https://github.com/SarthSatpute/py3dbc)
205
+ **Issues/Questions:** Open an issue on GitHub
206
+ **Related Project:** [CargoOptix]([https://github.com/SarthSatpute/CargoOptix]) - Full web application using py3dbc
207
+
208
+ ---
209
+
210
+ <div align="center">
211
+
212
+ **Built with ❤️ for safer, more efficient maritime operations**
213
+
214
+ ⭐ Star this repo if you find it useful!
215
+
216
+ </div>
@@ -0,0 +1,24 @@
1
+ """
2
+ py3dbc - 3D Bin Packing for Containers
3
+ Maritime container ship load optimization with stability physics
4
+ """
5
+
6
+ __version__ = "1.0.0"
7
+ __author__ = "Sarth Satpute"
8
+ __license__ = "MIT"
9
+
10
+ # Import main classes for easy access
11
+ from py3dbc.maritime.container import MaritimeContainer
12
+ from py3dbc.maritime.ship import ContainerShip, Slot
13
+ from py3dbc.maritime.packer import MaritimePacker
14
+ from py3dbc.maritime.constraints import MaritimeConstraintChecker
15
+ from py3dbc.physics.stability import StabilityCalculator
16
+
17
+ __all__ = [
18
+ "MaritimeContainer",
19
+ "ContainerShip",
20
+ "Slot",
21
+ "MaritimePacker",
22
+ "MaritimeConstraintChecker",
23
+ "StabilityCalculator",
24
+ ]
@@ -0,0 +1,16 @@
1
+ """
2
+ Maritime extensions for container ship optimization
3
+ """
4
+
5
+ from .container import MaritimeContainer
6
+ from .ship import ContainerShip, Slot
7
+ from .constraints import MaritimeConstraintChecker
8
+ from .packer import MaritimePacker
9
+
10
+ __all__ = [
11
+ 'MaritimeContainer',
12
+ 'ContainerShip',
13
+ 'Slot',
14
+ 'MaritimeConstraintChecker',
15
+ 'MaritimePacker'
16
+ ]