spyrrow 0.8.0__cp314-cp314-win32.whl
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.
- spyrrow/__init__.py +5 -0
- spyrrow/__init__.pyi +153 -0
- spyrrow/py.typed +0 -0
- spyrrow/spyrrow.cp314-win32.pyd +0 -0
- spyrrow-0.8.0.dist-info/METADATA +11 -0
- spyrrow-0.8.0.dist-info/RECORD +8 -0
- spyrrow-0.8.0.dist-info/WHEEL +4 -0
- spyrrow-0.8.0.dist-info/licenses/LICENSE.txt +21 -0
spyrrow/__init__.py
ADDED
spyrrow/__init__.pyi
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from typing import TypeAlias, Optional
|
|
2
|
+
from datetime import timedelta
|
|
3
|
+
|
|
4
|
+
Point: TypeAlias = tuple[float, float]
|
|
5
|
+
|
|
6
|
+
class Item:
|
|
7
|
+
id: str
|
|
8
|
+
demand: int
|
|
9
|
+
shape: list[Point]
|
|
10
|
+
allowed_orientations: list[float]
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
id: str,
|
|
15
|
+
shape: list[Point],
|
|
16
|
+
demand: int,
|
|
17
|
+
allowed_orientations: list[float] | None,
|
|
18
|
+
):
|
|
19
|
+
"""
|
|
20
|
+
An Item represents any closed 2D shape by its outer boundary.
|
|
21
|
+
|
|
22
|
+
Spyrrow doesn't support hole(s) inside the shape as of yet. Therefore no Item can be nested inside another.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
id (str): The Item identifier
|
|
26
|
+
Needs to be unique accross all Items of a StripPackingInstance
|
|
27
|
+
shape: An ordered list of (x,y) defining the shape boundary. The shape is represented as a polygon formed by this list of points.
|
|
28
|
+
The origin point can be included twice as the finishing point. If not, [last point, first point] is infered to be the last straight line of the shape.
|
|
29
|
+
demand: The quantity of identical Items to be placed inside the strip. Should be strictly positive.
|
|
30
|
+
allowed_orientations (list[float]|None): List of angles in degrees allowed.
|
|
31
|
+
An empty list is equivalent to [0.].
|
|
32
|
+
A None value means that the item is free to rotate
|
|
33
|
+
The algorithmn is only very weakly sensible to the length of the list given.
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def to_json_str(self) -> str:
|
|
38
|
+
"""Return a string of the JSON representation of the object"""
|
|
39
|
+
|
|
40
|
+
class PlacedItem:
|
|
41
|
+
"""
|
|
42
|
+
An object representing where a copy of an Item was placed inside the strip.
|
|
43
|
+
|
|
44
|
+
Attributes:
|
|
45
|
+
id (str): The Item identifier referencing the items of the StripPackingInstance
|
|
46
|
+
rotation (float): The rotation angle in degrees, assuming that the original Item was defined with 0° as its rotation angle.
|
|
47
|
+
Use the origin (0.0,0.0) as the rotation point.
|
|
48
|
+
translation (tuple[float,float]): the translation vector in the X-Y axis. To apply after the rotation
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
id: str
|
|
52
|
+
translation: Point
|
|
53
|
+
rotation: float
|
|
54
|
+
|
|
55
|
+
class StripPackingSolution:
|
|
56
|
+
"""
|
|
57
|
+
An object representing the solution to a given StripPackingInstance.
|
|
58
|
+
|
|
59
|
+
Can not be directly instanciated. Result from StripPackingInstance.solve.
|
|
60
|
+
|
|
61
|
+
Attributes:
|
|
62
|
+
width (float): the width of the strip found to contains all Items. In the same unit as input.
|
|
63
|
+
placed_items (list[PlacedItem]): a list of all PlacedItems, describing how Items are placed in the solution
|
|
64
|
+
density (float): the fraction of the final strip used by items.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
width: float
|
|
68
|
+
density: float
|
|
69
|
+
placed_items: list[PlacedItem]
|
|
70
|
+
|
|
71
|
+
class StripPackingConfig:
|
|
72
|
+
early_termination: bool
|
|
73
|
+
seed: int
|
|
74
|
+
exploration_time: timedelta
|
|
75
|
+
compression_time: timedelta
|
|
76
|
+
quadtree_depth: int
|
|
77
|
+
num_workers:Optional[int]
|
|
78
|
+
min_items_separation: Optional[float]
|
|
79
|
+
|
|
80
|
+
def __init__(
|
|
81
|
+
self,
|
|
82
|
+
early_termination: bool = True,
|
|
83
|
+
quadtree_depth: int = 4,
|
|
84
|
+
min_items_separation: Optional[float] = None,
|
|
85
|
+
total_computation_time: Optional[int] = 600,
|
|
86
|
+
exploration_time: Optional[int] = None,
|
|
87
|
+
compression_time: Optional[int] = None,
|
|
88
|
+
num_workers:Optional[int]= None,
|
|
89
|
+
seed: Optional[int] = None,
|
|
90
|
+
) -> None:
|
|
91
|
+
"""Initializes a configuration object for the strip packing algorithm.
|
|
92
|
+
|
|
93
|
+
Either `total_computation_time`, or both `exploration_time` and `compression_time`, must be provided.
|
|
94
|
+
Providing all three or only one of the latter two raises an error.
|
|
95
|
+
If `total_computation_time` is provided, 80% of it is allocated to exploration and 20% to compression.
|
|
96
|
+
If `seed` is not provided, a random seed will be generated.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
early_termination (bool, optional): Whether to allow early termination of the algorithm. Defaults to True.
|
|
101
|
+
quadtree_depth (int, optional): Maximum depth of the quadtree used by the collision detection engine jagua-rs.
|
|
102
|
+
Must be positive, common values are 3,4,5. Defaults to 4.
|
|
103
|
+
min_items_separation (Optional[float], optional): Minimum required distance between packed items. Defaults to None.
|
|
104
|
+
total_computation_time (Optional[int], optional): Total time budget in seconds.
|
|
105
|
+
Used if `exploration_time` and `compression_time` are not provided. Defaults to 600.
|
|
106
|
+
exploration_time (Optional[int], optional): Time in seconds allocated to exploration. Defaults to None.
|
|
107
|
+
compression_time (Optional[int], optional): Time in seconds allocated to compression. Defaults to None.
|
|
108
|
+
num_workers (Optional[int], optional): Number of threads used by the collision detection engine during exploration.
|
|
109
|
+
When set to None, detect the number of logical CPU cores on the execution plateform. Defaults to None.
|
|
110
|
+
seed (Optional[int], optional): Optional random seed to give reproductibility. If None, a random seed is generated. Defaults to None.
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
ValueError: If the combination of time arguments is invalid.
|
|
114
|
+
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
def to_json_str(self)->str:
|
|
118
|
+
"""Return a string of the JSON representation of the object
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
str
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
class StripPackingInstance:
|
|
125
|
+
name: str
|
|
126
|
+
strip_height: float
|
|
127
|
+
items: list[Item]
|
|
128
|
+
|
|
129
|
+
def __init__(self, name: str, strip_height: float, items: list[Item]):
|
|
130
|
+
"""
|
|
131
|
+
An Instance of a Strip Packing Problem.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
name (str): The name of the instance. Required by the underlying sparrow library.
|
|
135
|
+
An empty string '' can be used, if the user doesn't have a use for this name.
|
|
136
|
+
strip_height (float): the fixed height of the strip. The unit should be compatible with the Item
|
|
137
|
+
items (list[Item]): The Items which defines the instances. All Items should be defined with the same scale ( same length unit).
|
|
138
|
+
Raises:
|
|
139
|
+
ValueError
|
|
140
|
+
"""
|
|
141
|
+
def to_json_str(self) -> str:
|
|
142
|
+
"""Return a string of the JSON representation of the object"""
|
|
143
|
+
|
|
144
|
+
def solve(self, config: StripPackingConfig) -> StripPackingSolution:
|
|
145
|
+
"""
|
|
146
|
+
The method to solve the instance.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
config (StripPackingConfig): The configuration object to control how the instance is solved.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
a StripPackingSolution
|
|
153
|
+
"""
|
spyrrow/py.typed
ADDED
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spyrrow
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
License-File: LICENSE.txt
|
|
8
|
+
Author-email: Paul Durand-Lupinski <paul.durand-lupinski@reeverse-systems.com>
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Project-URL: documentation, https://spyrrow.readthedocs.io/
|
|
11
|
+
Project-URL: source, https://github.com/PaulDL-RS/spyrrow
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
spyrrow-0.8.0.dist-info/METADATA,sha256=VqdpFe_-2OjZz_0YnLJpG1ac78qUBECOWk6Qn1I4ykI,480
|
|
2
|
+
spyrrow-0.8.0.dist-info/WHEEL,sha256=8HN3N__kOX50d01M5g7gDrPP9KRQGBqXq8p0TJZtkmI,93
|
|
3
|
+
spyrrow-0.8.0.dist-info/licenses/LICENSE.txt,sha256=Ugi_fLJkCPA3DrzIdQnHifz5MwSyxuzTsNWUFRMQvMM,1096
|
|
4
|
+
spyrrow/__init__.py,sha256=MajlSBAliv8o8SqAqLgJARyi3egmvNIaXKTDXxvIAFY,111
|
|
5
|
+
spyrrow/__init__.pyi,sha256=wsVvDG45Aq5nHfaqFKBkPL1a0aZCa2_ABKsGH97CXGg,6594
|
|
6
|
+
spyrrow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
spyrrow/spyrrow.cp314-win32.pyd,sha256=QTRccWR92jI-_VrBfT2R9wHt8Gdeef-hkIlXJwOHsxg,1082368
|
|
8
|
+
spyrrow-0.8.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Paul Durand-Lupinski
|
|
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.
|