@@ -162,14 +162,6 @@ std::vector<ColIdx> VariableSizeBinPackingPricingSolver<Instance, InstanceBuilde
162
162
return {};
163
163
}
164
164
165
- template <typename Solution>
166
- struct VariableSizeBinPackingColumnExtra
167
- {
168
- Solution solution;
169
- BinTypeId bin_type_id;
170
- std::vector<ItemTypeId> kp2vbpp;
171
- };
172
-
173
165
template <typename Solution>
174
166
std::vector<Column> solution2column (
175
167
const Solution& solution)
@@ -178,23 +170,22 @@ std::vector<Column> solution2column(
178
170
BinPos m = solution.instance ().number_of_bin_types ();
179
171
for (BinPos bin_pos = 0 ; bin_pos < solution.number_of_different_bins (); ++bin_pos) {
180
172
BinTypeId bin_type_id = solution.bin (bin_pos).bin_type_id ;
181
- Solution solution_i (solution.instance ());
182
- solution_i.append (solution, bin_pos, 1 );
183
- VariableSizeBinPackingColumnExtra<Solution> extra {solution_i, bin_type_id, {}};
173
+ Solution extra_solution (solution.instance ());
174
+ extra_solution.append (solution, bin_pos, 1 );
184
175
Column column;
185
176
column.objective_coefficient = solution.instance ().bin_type (bin_type_id).cost ;
186
177
column.row_indices .push_back (bin_type_id);
187
178
column.row_coefficients .push_back (1 );
188
179
for (ItemTypeId item_type_id = 0 ;
189
180
item_type_id < solution.instance ().number_of_item_types ();
190
181
++item_type_id) {
191
- if (extra. solution .item_copies (item_type_id) > 0 ) {
182
+ if (extra_solution .item_copies (item_type_id) > 0 ) {
192
183
column.row_indices .push_back (m + item_type_id);
193
184
column.row_coefficients .push_back (
194
- extra. solution .item_copies (item_type_id));
185
+ extra_solution .item_copies (item_type_id));
195
186
}
196
187
}
197
- column.extra = std::shared_ptr<void >(new VariableSizeBinPackingColumnExtra< Solution>(extra ));
188
+ column.extra = std::shared_ptr<void >(new Solution (extra_solution ));
198
189
columns.push_back (column);
199
190
}
200
191
return columns;
@@ -243,7 +234,9 @@ std::vector<Column> VariableSizeBinPackingPricingSolver<Instance, InstanceBuilde
243
234
244
235
// Retrieve column.
245
236
for (const Solution& kp_solution: kp_solution_pool.solutions ()) {
246
- VariableSizeBinPackingColumnExtra<Solution> extra {kp_solution, bin_type_id, kp2vbpp};
237
+ if (kp_solution.number_of_bins () == 0 )
238
+ continue ;
239
+
247
240
Column column;
248
241
column.objective_coefficient = instance_.bin_type (bin_type_id).cost ;
249
242
column.row_indices .push_back (bin_type_id);
@@ -253,13 +246,20 @@ std::vector<Column> VariableSizeBinPackingPricingSolver<Instance, InstanceBuilde
253
246
for (ItemTypeId kp_item_type_id = 0 ;
254
247
kp_item_type_id < kp_instance.number_of_item_types ();
255
248
++kp_item_type_id) {
256
- if (extra. solution .item_copies (kp_item_type_id) > 0 ) {
257
- column.row_indices .push_back (m + extra. kp2vbpp [kp_item_type_id]);
258
- column.row_coefficients .push_back (extra. solution .item_copies (kp_item_type_id));
249
+ if (kp_solution .item_copies (kp_item_type_id) > 0 ) {
250
+ column.row_indices .push_back (m + kp2vbpp[kp_item_type_id]);
251
+ column.row_coefficients .push_back (kp_solution .item_copies (kp_item_type_id));
259
252
// std::cout << duals[m + extra->kp2vbpp[kp_j]] << std::endl;
260
253
}
261
254
}
262
- column.extra = std::shared_ptr<void >(new VariableSizeBinPackingColumnExtra<Solution>(extra));
255
+ Solution extra_solution (instance_);
256
+ extra_solution.append (
257
+ kp_solution,
258
+ 0 ,
259
+ 1 ,
260
+ {bin_type_id},
261
+ kp2vbpp);
262
+ column.extra = std::shared_ptr<void >(new Solution (extra_solution));
263
263
// std::cout << column << std::endl;
264
264
columns.push_back (column);
265
265
}
0 commit comments