Skip to content

Commit 0562eea

Browse files
committed
Add fixed items
1 parent dd78c9b commit 0562eea

42 files changed

Lines changed: 1709 additions & 480 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"objective": "open-dimension-x",
3+
"bin_types": [
4+
{
5+
"type": "polygon",
6+
"copies": 1,
7+
"copies_min": 1,
8+
"vertices": [
9+
{
10+
"x": 0,
11+
"y": 0
12+
},
13+
{
14+
"x": 40,
15+
"y": 0
16+
},
17+
{
18+
"x": 40,
19+
"y": 30
20+
},
21+
{
22+
"x": 0,
23+
"y": 30
24+
}
25+
],
26+
"fixed_items": [
27+
{
28+
"item_type_id": 0,
29+
"angle": 0,
30+
"mirror": false,
31+
"bl_corner": {"x": 10, "y": 10}
32+
}
33+
]
34+
}
35+
],
36+
"item_types": [
37+
{
38+
"type": "polygon",
39+
"vertices": [
40+
{
41+
"x": 0,
42+
"y": 0
43+
},
44+
{
45+
"x": 10,
46+
"y": 0
47+
},
48+
{
49+
"x": 10,
50+
"y": 20
51+
},
52+
{
53+
"x": 0,
54+
"y": 20
55+
}
56+
]
57+
},
58+
{
59+
"type": "polygon",
60+
"allow_mirroring": true,
61+
"vertices": [
62+
{
63+
"x": 0,
64+
"y": 0
65+
},
66+
{
67+
"x": 10,
68+
"y": 0
69+
},
70+
{
71+
"x": 10,
72+
"y": 10
73+
},
74+
{
75+
"x": 0,
76+
"y": 10
77+
}
78+
]
79+
}
80+
]
81+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"bins": [
3+
{
4+
"copies": 1,
5+
"id": 0,
6+
"items": [
7+
{
8+
"angle": 0.0,
9+
"id": 1,
10+
"item_shapes": [
11+
{
12+
"shape": [
13+
{
14+
"type": "LineSegment",
15+
"xe": 10.0,
16+
"xs": 0.0,
17+
"ye": 0.0,
18+
"ys": 0.0
19+
},
20+
{
21+
"type": "LineSegment",
22+
"xe": 10.0,
23+
"xs": 10.0,
24+
"ye": 10.0,
25+
"ys": 0.0
26+
},
27+
{
28+
"type": "LineSegment",
29+
"xe": 0.0,
30+
"xs": 10.0,
31+
"ye": 10.0,
32+
"ys": 10.0
33+
},
34+
{
35+
"type": "LineSegment",
36+
"xe": 0.0,
37+
"xs": 0.0,
38+
"ye": 0.0,
39+
"ys": 10.0
40+
}
41+
]
42+
}
43+
],
44+
"mirror": false,
45+
"x": 0.0,
46+
"y": 0.0
47+
},
48+
{
49+
"angle": 0.0,
50+
"id": 0,
51+
"item_shapes": [
52+
{
53+
"shape": [
54+
{
55+
"type": "LineSegment",
56+
"xe": 20.0,
57+
"xs": 10.0,
58+
"ye": 10.0,
59+
"ys": 10.0
60+
},
61+
{
62+
"type": "LineSegment",
63+
"xe": 20.0,
64+
"xs": 20.0,
65+
"ye": 30.0,
66+
"ys": 10.0
67+
},
68+
{
69+
"type": "LineSegment",
70+
"xe": 10.0,
71+
"xs": 20.0,
72+
"ye": 30.0,
73+
"ys": 30.0
74+
},
75+
{
76+
"type": "LineSegment",
77+
"xe": 10.0,
78+
"xs": 10.0,
79+
"ye": 10.0,
80+
"ys": 30.0
81+
}
82+
]
83+
}
84+
],
85+
"mirror": false,
86+
"x": 10.0,
87+
"y": 10.0
88+
}
89+
],
90+
"shape": [
91+
{
92+
"type": "LineSegment",
93+
"xe": 40.0,
94+
"xs": 0.0,
95+
"ye": 0.0,
96+
"ys": 0.0
97+
},
98+
{
99+
"type": "LineSegment",
100+
"xe": 40.0,
101+
"xs": 40.0,
102+
"ye": 30.0,
103+
"ys": 0.0
104+
},
105+
{
106+
"type": "LineSegment",
107+
"xe": 0.0,
108+
"xs": 40.0,
109+
"ye": 30.0,
110+
"ys": 30.0
111+
},
112+
{
113+
"type": "LineSegment",
114+
"xe": 0.0,
115+
"xs": 0.0,
116+
"ye": 0.0,
117+
"ys": 30.0
118+
}
119+
]
120+
}
121+
]
122+
}

include/packingsolver/box/instance.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,27 @@ struct ItemType
141141
inline Volume space() const { return volume(); }
142142

143143
inline bool can_rotate(int rotation) const { return ((rotations >> rotation) & 1); }
144+
145+
/** Number of fixed copies of the item type (pre-placed in bin types). */
146+
ItemPos copies_fixed = 0;
144147
};
145148

146149
std::ostream& operator<<(
147150
std::ostream& os,
148151
const ItemType& item_type);
149152

153+
struct FixedItem
154+
{
155+
/** Item type. */
156+
ItemTypeId item_type_id;
157+
158+
/** Bottom-left corner of the item. */
159+
Point bl_corner;
160+
161+
/** Rotation of the item. */
162+
int rotation;
163+
};
164+
150165
/**
151166
* Bin type structure for a problem of type 'box'.
152167
*/
@@ -167,6 +182,9 @@ struct BinType
167182
/** Maximum weight. */
168183
Weight maximum_weight = std::numeric_limits<Weight>::infinity();
169184

185+
/** Fixed items pre-placed in every bin of this type. */
186+
std::vector<FixedItem> fixed_items;
187+
170188
/*
171189
* Computed attributes
172190
*/

include/packingsolver/box/instance_builder.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ class InstanceBuilder
6262
* This method is used in the column generation procedure.
6363
*/
6464
void add_bin_type(
65-
const BinType& bin_type,
66-
BinPos copies);
65+
const Instance& original_instance,
66+
BinTypeId original_bin_type_id,
67+
BinPos copies,
68+
BinPos copies_min = 0);
6769

6870
/**
6971
* For each bin type, set an infinite x.
@@ -120,7 +122,8 @@ class InstanceBuilder
120122
* This method is used in the column generation procedure.
121123
*/
122124
void add_item_type(
123-
const ItemType& item_type,
125+
const Instance& original_instance,
126+
ItemTypeId original_item_type_id,
124127
Profit profit,
125128
ItemPos copies);
126129

@@ -175,6 +178,12 @@ class InstanceBuilder
175178
/** Instance. */
176179
Instance instance_;
177180

181+
/** Mapping from original bin type IDs to sub-instance bin type IDs. */
182+
std::vector<BinTypeId> orig_to_sub_bin_type_ids_;
183+
184+
/** Mapping from original item type IDs to sub-instance item type IDs. */
185+
std::vector<ItemTypeId> orig_to_sub_item_type_ids_;
186+
178187
};
179188

180189
}

include/packingsolver/boxstacks/instance.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,30 @@ struct ItemType
219219
inline Volume space() const { return volume(); }
220220

221221
inline bool can_rotate(int rotation) const { return ((rotations >> rotation) & 1); }
222+
223+
/** Number of fixed copies of the item type (pre-placed in bin types). */
224+
ItemPos copies_fixed = 0;
222225
};
223226

224227
std::ostream& operator<<(
225228
std::ostream& os,
226229
const ItemType& item_type);
227230

231+
struct FixedItem
232+
{
233+
/** Item type. */
234+
ItemTypeId item_type_id;
235+
236+
/** Position of the bottom-left corner of the stack. */
237+
Point bl_corner;
238+
239+
/** Initial z-coordinate of the item. */
240+
Length z_start;
241+
242+
/** Rotation of the item. */
243+
int rotation;
244+
};
245+
228246
/**
229247
* Bin type structure for a problem of type 'boxstacks'.
230248
*/
@@ -258,6 +276,9 @@ struct BinType
258276
/** Semi-trailer truck data. */
259277
SemiTrailerTruckData semi_trailer_truck_data;
260278

279+
/** Fixed items pre-placed in every bin of this type. */
280+
std::vector<FixedItem> fixed_items;
281+
261282
/*
262283
* Computed attributes
263284
*/

include/packingsolver/boxstacks/instance_builder.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ class InstanceBuilder
9191
* This method is used in the column generation procedure.
9292
*/
9393
void add_bin_type(
94-
const BinType& bin_type,
95-
BinPos copies);
94+
const Instance& original_instance,
95+
BinTypeId original_bin_type_id,
96+
BinPos copies,
97+
BinPos copies_min = 0);
9698

9799
/**
98100
* For each bin type, set an infinite x.
@@ -174,7 +176,8 @@ class InstanceBuilder
174176
* This method is used in the column generation procedure.
175177
*/
176178
void add_item_type(
177-
const ItemType& item_type,
179+
const Instance& original_instance,
180+
ItemTypeId original_item_type_id,
178181
Profit profit,
179182
ItemPos copies);
180183

@@ -229,6 +232,12 @@ class InstanceBuilder
229232
/** Instance. */
230233
Instance instance_;
231234

235+
/** Mapping from original bin type IDs to sub-instance bin type IDs. */
236+
std::vector<BinTypeId> orig_to_sub_bin_type_ids_;
237+
238+
/** Mapping from original item type IDs to sub-instance item type IDs. */
239+
std::vector<ItemTypeId> orig_to_sub_item_type_ids_;
240+
232241
};
233242

234243
}

0 commit comments

Comments
 (0)