Skip to content

Commit

Permalink
Merge pull request #21 from fontanf/bugfix/many-items
Browse files Browse the repository at this point in the history
Increase number of items type from int64_t to int32_t
  • Loading branch information
fontanf authored Apr 21, 2024
2 parents 58f7c2f + cc46e86 commit 98afbd9
Show file tree
Hide file tree
Showing 18 changed files with 104 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ Time: 1.00226

Visualize:
```
python3 packingsolver/scripts/visualize_rectangleguillotine.py ATP35_solution.csv
python3 scripts/visualize_rectangleguillotine.py ATP35_solution.csv
```

10 changes: 10 additions & 0 deletions data/onedimensional/users/2024-04-20_1_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ID,X,COST,COPIES
0,6950,6950,48
1,1918,767,10
2,1938,775,1
3,2012,805,1
4,1975,790,1
5,1918,767,11
6,1928,771,1
7,1903,761,1
8,4481,1792,1
9 changes: 9 additions & 0 deletions data/onedimensional/users/2024-04-20_1_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ID,X,COPIES,NESTING_LENGTH
0,2512,24,-4
1,2527,12,-4
2,2502,2,-4
3,2465,2,-4
4,2902,1,-4
5,3689,3,-4
6,1893,3,-4
7,1897,1,-4
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-20_1_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
6 changes: 6 additions & 0 deletions data/onedimensional/users/2024-04-20_2_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ID,X,COST,COPIES
0,3000,3000,23
1,7000,7000,23
2,1800,1800,23
3,800,800,23
4,400,400,23
7 changes: 7 additions & 0 deletions data/onedimensional/users/2024-04-20_2_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ID,X,COPIES,NESTING_LENGTH
0,1290,2,-5
1,1496,3,-5
2,2751,3,-5
3,3351,7,-5
4,1950,4,-5
5,2250,4,-5
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-20_2_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-21_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,X,COST,COPIES
0,6000,6000,43554
8 changes: 8 additions & 0 deletions data/onedimensional/users/2024-04-21_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ID,X,COPIES,NESTING_LENGTH
0,837,820,-4
1,1587,26640,-4
2,1987,372,-4
3,2487,15602,-4
4,727,40,-4
5,1627,40,-4
6,747,40,-4
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-21_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
28 changes: 28 additions & 0 deletions data/onedimensional/users/2024-04-21_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,0,13320,0,0,6000
ITEM,3,13320,0,0,2487
ITEM,1,13320,0,2491,1587
ITEM,1,13320,0,4082,1587
BIN,0,124,1,0,6000
ITEM,2,124,1,0,1987
ITEM,2,124,1,1991,1987
ITEM,2,124,1,3982,1987
BIN,0,231,2,0,6000
ITEM,3,231,2,0,2487
ITEM,3,231,2,2491,2487
BIN,0,820,3,0,6000
ITEM,0,820,3,0,837
ITEM,3,820,3,841,2487
ITEM,3,820,3,3332,2487
BIN,0,40,4,0,6000
ITEM,6,40,4,0,747
ITEM,3,40,4,751,2487
ITEM,3,40,4,3242,2487
BIN,0,40,5,0,6000
ITEM,3,40,5,0,2487
ITEM,3,40,5,2491,2487
ITEM,4,40,5,4982,727
BIN,0,20,6,0,6000
ITEM,3,20,6,0,2487
ITEM,5,20,6,2491,1627
ITEM,5,20,6,4122,1627
4 changes: 2 additions & 2 deletions include/packingsolver/algorithms/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ using Seed = int64_t;
using Counter = int64_t;

using ItemTypeId = int16_t;
using ItemPos = int16_t;
using ItemPos = int32_t;
using GroupId = int16_t;
using StackabilityId = int64_t;
using StackId = int16_t;
using StackId = int32_t;
using Length = int64_t;
using Area = int64_t;
using Volume = int64_t;
Expand Down
2 changes: 1 addition & 1 deletion include/packingsolver/boxstacks/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class Instance
inline const ItemType& item_type(ItemTypeId item_type_id) const { return item_types_[item_type_id]; }

/** Get the number of items. */
inline ItemTypeId number_of_items() const { return number_of_items_; }
inline ItemPos number_of_items() const { return number_of_items_; }

/** Get the number of groups. */
inline StackId number_of_groups() const { return groups_.size(); }
Expand Down
6 changes: 3 additions & 3 deletions include/packingsolver/irregular/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ class Instance
inline const ItemType& item_type(ItemTypeId item_type_id) const { return item_types_[item_type_id]; }

/** Get the number of items. */
inline ItemTypeId number_of_items() const { return number_of_items_; }
inline ItemPos number_of_items() const { return number_of_items_; }

/** Get the number rectangular of items. */
inline ItemTypeId number_of_rectangular_items() const { return number_of_rectangular_items_; }
inline ItemPos number_of_rectangular_items() const { return number_of_rectangular_items_; }

/** Get the number circular of items. */
inline ItemTypeId number_of_circular_items() const { return number_of_circular_items_; }
inline ItemPos number_of_circular_items() const { return number_of_circular_items_; }

/** Get the total area of the items. */
inline AreaDbl item_area() const { return item_area_; }
Expand Down
2 changes: 1 addition & 1 deletion include/packingsolver/onedimensional/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Instance
inline const ItemType& item_type(ItemTypeId item_type_id) const { return item_types_[item_type_id]; }

/** Get the number of items. */
inline ItemTypeId number_of_items() const { return number_of_items_; }
inline ItemPos number_of_items() const { return number_of_items_; }

/** Get the total length of the items. */
inline Area item_length() const { return item_length_; }
Expand Down
2 changes: 1 addition & 1 deletion include/packingsolver/rectangle/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class Instance
inline const ItemType& item_type(ItemTypeId item_type_id) const { return item_types_[item_type_id]; }

/** Get the number of items. */
inline ItemTypeId number_of_items() const { return number_of_items_; }
inline ItemPos number_of_items() const { return number_of_items_; }

/** Get the number of groups. */
inline StackId number_of_groups() const { return groups_.size(); }
Expand Down
2 changes: 1 addition & 1 deletion include/packingsolver/rectangleguillotine/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class Instance
inline const ItemType& item_type(ItemTypeId item_type_id) const { return item_types_[item_type_id]; }

/** Get the number of items. */
inline ItemTypeId number_of_items() const { return number_of_items_; }
inline ItemPos number_of_items() const { return number_of_items_; }

/** Get the number of stacks. */
inline StackId number_of_stacks() const { return item_type_ids_.size(); }
Expand Down
18 changes: 18 additions & 0 deletions test/onedimensional/onedimensional_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,21 @@ TEST(OneDimensional, Users_2024_04_09)
Solution solution(instance, (directory / "2024-04-09_solution.csv").string());
EXPECT_EQ(!(output.solution_pool.best() < solution), true);
}

TEST(OneDimensional, Users_2024_04_21)
{
InstanceBuilder instance_builder;
fs::path directory = fs::path("data") / "onedimensional" / "users";
instance_builder.read_item_types((directory / "2024-04-21_items.csv").string());
instance_builder.read_bin_types((directory / "2024-04-21_bins.csv").string());
instance_builder.read_parameters((directory / "2024-04-21_parameters.csv").string());
Instance instance = instance_builder.build();

OptimizeParameters optimize_parameters;
optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime;
optimize_parameters.use_column_generation = 1;
Output output = optimize(instance, optimize_parameters);

Solution solution(instance, (directory / "2024-04-21_solution.csv").string());
EXPECT_EQ(!(output.solution_pool.best() < solution), true);
}

0 comments on commit 98afbd9

Please sign in to comment.