Skip to content

Commit c5d4a10

Browse files
authored
Add problem type irregular (#38)
* Update irregular branching scheme * Update README
1 parent b14a853 commit c5d4a10

20 files changed

+1915
-655
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ PackingSolver solves the following problem types:
2626

2727
![Example](img/onedimensional.png?raw=true "Example onedimensional")
2828

29+
* `irregular`
30+
* Items: two-dimensional polygons
31+
32+
![Example](img/irregular.png?raw=true "Example irregular")
33+
2934
## Problem type `rectangleguillotine`
3035

3136
Features:
@@ -98,6 +103,19 @@ Features:
98103
* Maximum weight
99104
* Item type / Bin type eligibility
100105

106+
## Problem type `irregular`
107+
108+
Features:
109+
* Objectives:
110+
* Knapsack
111+
* Open dimension X
112+
* Open dimension Y
113+
* Bin packing
114+
* Bin packing with leftovers
115+
* Variable-sized bin packing
116+
* Item types
117+
* Discrete rotations
118+
101119
## Usage
102120

103121
For macOS, CLP needs to be installed manually with [Homebrew](https://brew.sh/):

extern/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ if (PackingSolver_USE_KNITRO)
5656
FetchContent_Declare(
5757
knitrocpp
5858
GIT_REPOSITORY https://github.com/fontanf/knitrocpp.git
59-
GIT_TAG 6c63e3f3931329e2c1a2c22ce465fe8667516a36)
60-
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../knitrocpp/"
61-
FetchContent_MakeAvailable(knitrocpp
62-
EXCLUDE_FROM_ALL)
59+
GIT_TAG 6c63e3f3931329e2c1a2c22ce465fe8667516a36
60+
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../knitrocpp/"
61+
EXCLUDE_FROM_ALL)
62+
FetchContent_MakeAvailable(knitrocpp)
6363
endif()

img/irregular.png

61.5 KB
Loading

include/packingsolver/irregular/instance.hpp

+14-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace irregular
99

1010
using LengthDbl = double;
1111
using AreaDbl = double;
12+
using ElementPos = int64_t;
1213

1314
/**
1415
* Structure for a point.
@@ -21,6 +22,8 @@ struct Point
2122
/** y-coordiante. */
2223
LengthDbl y;
2324

25+
Point rotate(Angle angle) const;
26+
2427
bool operator==(const Point& point) const { return x == point.x && y == point.y; }
2528

2629
std::string to_string() const;
@@ -49,10 +52,6 @@ LengthDbl cross_product(
4952
const Point& vector_1,
5053
const Point& vector_2);
5154

52-
Point rotate(
53-
const Point& point,
54-
Angle angle);
55-
5655
Angle angle(
5756
const Point& vector);
5857

@@ -99,13 +98,11 @@ struct ShapeElement
9998
/** Length of the element. */
10099
LengthDbl length() const;
101100

101+
ShapeElement rotate(Angle angle) const;
102+
102103
std::string to_string() const;
103104
};
104105

105-
ShapeElement rotate(
106-
const ShapeElement& element,
107-
Angle angle);
108-
109106
enum class ShapeType
110107
{
111108
Circle,
@@ -158,6 +155,10 @@ struct Shape
158155
/* Check if the shape is connected and in anticlockwise direction. */
159156
bool check() const;
160157

158+
Shape rotate(Angle angle) const;
159+
160+
Shape identity_line_axial_symmetry() const;
161+
161162
std::string to_string(Counter indentation) const;
162163
};
163164

@@ -364,7 +365,7 @@ class Instance
364365
inline AreaDbl previous_bin_area(BinPos bin_pos) const { return previous_bins_area_[bin_pos]; }
365366

366367
/** Get the total area of the bins. */
367-
inline Area bin_area() const { return bin_area_; }
368+
inline AreaDbl bin_area() const { return bin_area_; }
368369

369370
/** Get the number of defects. */
370371
inline DefectId number_of_defects() const { return number_of_defects_; }
@@ -374,12 +375,12 @@ class Instance
374375
*/
375376

376377
/** Get the x of a bin type depending on its orientation. */
377-
inline Length x_max(
378+
inline LengthDbl x_max(
378379
const BinType& bin_type,
379380
Direction o) const;
380381

381382
/** Get the y of a bin type depending on its orientation. */
382-
inline Length y_max(
383+
inline LengthDbl y_max(
383384
const BinType& bin_type,
384385
Direction o) const;
385386

@@ -496,14 +497,14 @@ class Instance
496497
/////////////////////////////// Inlined methods ////////////////////////////////
497498
////////////////////////////////////////////////////////////////////////////////
498499

499-
Length Instance::x_max(
500+
LengthDbl Instance::x_max(
500501
const BinType& bin_type,
501502
Direction o) const
502503
{
503504
return (o == Direction::X)? bin_type.x_max: bin_type.y_max;
504505
}
505506

506-
Length Instance::y_max(
507+
LengthDbl Instance::y_max(
507508
const BinType& bin_type,
508509
Direction o) const
509510
{

src/irregular/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ target_sources(PackingSolver_irregular PRIVATE
66
solution.cpp
77
algorithm_formatter.cpp
88
optimize.cpp
9-
covering_with_rectangles.cpp
10-
clustering.cpp
9+
polygon_trapezoidation.cpp
1110
branching_scheme.cpp)
1211
target_include_directories(PackingSolver_irregular PUBLIC
1312
${PROJECT_SOURCE_DIR}/include)

0 commit comments

Comments
 (0)