Skip to content

Commit e655843

Browse files
committed
Remove C++20 requirement (now requires C++11)
1 parent d1717f4 commit e655843

File tree

3 files changed

+70
-74
lines changed

3 files changed

+70
-74
lines changed

packingsolver/rectangleguillotine/branching_scheme.cpp

+59-63
Original file line numberDiff line numberDiff line change
@@ -215,26 +215,26 @@ BranchingScheme::Front BranchingScheme::front(
215215
{
216216
switch (insertion.df) {
217217
case -1: case -2: {
218-
return {.i = last_bin(node, insertion.df), .o = last_bin_orientation(node, insertion.df),
219-
.x1_prev = 0, .x3_curr = insertion.x3, .x1_curr = insertion.x1,
220-
.y2_prev = 0, .y2_curr = insertion.y2};
218+
return {last_bin(node, insertion.df), last_bin_orientation(node, insertion.df),
219+
0, insertion.x3, insertion.x1,
220+
0, insertion.y2};
221221
} case 0: {
222-
return {.i = last_bin(node, insertion.df), .o = last_bin_orientation(node, insertion.df),
223-
.x1_prev = node.x1_curr, .x3_curr = insertion.x3, .x1_curr = insertion.x1,
224-
.y2_prev = 0, .y2_curr = insertion.y2};
222+
return {last_bin(node, insertion.df), last_bin_orientation(node, insertion.df),
223+
node.x1_curr, insertion.x3, insertion.x1,
224+
0, insertion.y2};
225225
} case 1: {
226-
return {.i = last_bin(node, insertion.df), .o = last_bin_orientation(node, insertion.df),
227-
.x1_prev = node.x1_prev, .x3_curr = insertion.x3, .x1_curr = insertion.x1,
228-
.y2_prev = node.y2_curr, .y2_curr = insertion.y2};
226+
return {last_bin(node, insertion.df), last_bin_orientation(node, insertion.df),
227+
node.x1_prev, insertion.x3, insertion.x1,
228+
node.y2_curr, insertion.y2};
229229
} case 2: {
230-
return {.i = last_bin(node, insertion.df), .o = last_bin_orientation(node, insertion.df),
231-
.x1_prev = node.x1_prev, .x3_curr = insertion.x3, .x1_curr = insertion.x1,
232-
.y2_prev = node.y2_prev, .y2_curr = insertion.y2};
230+
return {last_bin(node, insertion.df), last_bin_orientation(node, insertion.df),
231+
node.x1_prev, insertion.x3, insertion.x1,
232+
node.y2_prev, insertion.y2};
233233
} default: {
234234
assert(false);
235-
return {.i = -1, .o = CutOrientation::Vertical,
236-
.x1_prev = -1, .x3_curr = -1, .x1_curr = -1,
237-
.y2_prev = -1, .y2_curr = -1};
235+
return {-1, CutOrientation::Vertical,
236+
-1, -1, -1,
237+
-1, -1};
238238
}
239239
}
240240
}
@@ -631,9 +631,9 @@ void BranchingScheme::insertion_1_item(
631631
}
632632

633633
Insertion insertion {
634-
.j1 = j, .j2 = -1, .df = df,
635-
.x1 = x, .y2 = y, .x3 = x,
636-
.x1_max = x1_max(father, df), .y2_max = y2_max(father, df, x), .z1 = 0, .z2 = 0};
634+
j, -1, df,
635+
x, y, x,
636+
x1_max(father, df), y2_max(father, df, x), 0, 0};
637637
LOG(info, insertion << std::endl);
638638

639639
// Check defect intersection
@@ -693,9 +693,9 @@ void BranchingScheme::insertion_2_items(
693693
}
694694

695695
Insertion insertion {
696-
.j1 = j1, .j2 = j2, .df = df,
697-
.x1 = x, .y2 = y, .x3 = x,
698-
.x1_max = x1_max(father, df), .y2_max = y2_max(father, df, x), .z1 = 0, .z2 = 2};
696+
j1, j2, df,
697+
x, y, x,
698+
x1_max(father, df), y2_max(father, df, x), 0, 2};
699699
LOG(info, insertion << std::endl);
700700

701701
update(father, insertions, insertion, info);
@@ -724,9 +724,9 @@ void BranchingScheme::insertion_defect(
724724
}
725725

726726
Insertion insertion {
727-
.j1 = -1, .j2 = -1, .df = df,
728-
.x1 = x, .y2 = y, .x3 = x,
729-
.x1_max = x1_max(father, df), .y2_max = y2_max(father, df, x), .z1 = 1, .z2 = 1};
727+
-1, -1, df,
728+
x, y, x,
729+
x1_max(father, df), y2_max(father, df, x), 1, 1};
730730
LOG(info, insertion << std::endl);
731731

732732
update(father, insertions, insertion, info);
@@ -1388,11 +1388,8 @@ bool BranchingScheme::BranchingScheme::check(const std::vector<Solution::Node>&
13881388

13891389
Solution BranchingScheme::to_solution(
13901390
const Node& node,
1391-
const Solution& solution_dummy) const
1391+
const Solution&) const
13921392
{
1393-
(void)solution_dummy;
1394-
//std::cout << node << std::endl;
1395-
13961393
// Get nodes, items and bins
13971394
std::vector<SolutionNode> nodes;
13981395
std::vector<NodeItem> items;
@@ -1412,17 +1409,17 @@ Solution BranchingScheme::to_solution(
14121409

14131410
SolutionNodeId id = (n->df >= 0)? nodes.size() + 2 - n->df: nodes.size() + 2;
14141411
if (n->j1 != -1)
1415-
items.push_back({.j = n->j1, .node = id});
1412+
items.push_back({n->j1, id});
14161413
if (n->j2 != -1)
1417-
items.push_back({.j = n->j2, .node = id});
1414+
items.push_back({n->j2, id});
14181415

14191416
// Add new solution nodes
14201417
SolutionNodeId f = (n->df <= 0)? -first_stage_orientations.size(): nodes_curr[n->df];
14211418
Depth d = (n->df < 0)? 0: n->df;
14221419
SolutionNodeId c = nodes.size() - 1;
14231420
do {
14241421
c++;
1425-
nodes.push_back({.f = f});
1422+
nodes.push_back({f, -1});
14261423
f = c;
14271424
d++;
14281425
nodes_curr[d] = nodes.size() - 1;
@@ -1441,8 +1438,7 @@ Solution BranchingScheme::to_solution(
14411438
Length h = instance_.bin(i).height(o);
14421439
SolutionNodeId id = res.size();
14431440
bins.push_back(id);
1444-
res.push_back({.id = id, .f = -1, .d = 0, .i = i,
1445-
.l = 0, .r = w, .b = 0, .t = h, .children = {}, .j = -1});
1441+
res.push_back({id, -1, 0, i, 0, w, 0, h, {}, -1, false, -1});
14461442
}
14471443
for (SolutionNodeId id = 0; id < (SolutionNodeId)nodes.size(); ++id) {
14481444
SolutionNodeId f = (nodes[id].f >= 0)? nodes[id].f: bins[(-nodes[id].f)-1];
@@ -1479,23 +1475,23 @@ Solution BranchingScheme::to_solution(
14791475
res[c_last].r = res[f].r;
14801476
} else {
14811477
SolutionNodeId id = res.size();
1482-
res.push_back({.id = id, .f = f,
1483-
.d = static_cast<Depth>(res[f].d+1), .i = res[f].i,
1484-
.l = res[c_last].r, .r = res[f].r,
1485-
.b = res[f].b, .t = res[f].t,
1486-
.children = {}, .j = -1});
1478+
res.push_back({id, f,
1479+
static_cast<Depth>(res[f].d+1), res[f].i,
1480+
res[c_last].r, res[f].r,
1481+
res[f].b, res[f].t,
1482+
{}, -1, false, -1});
14871483
res[f].children.push_back(id);
14881484
}
14891485
} else if ((res[f].d == 1 || res[f].d == 3) && res[f].t != res[c_last].t) {
14901486
if (res[f].t - res[c_last].t < parameters_.min_waste) {
14911487
res[c_last].t = res[f].t;
14921488
} else {
14931489
SolutionNodeId id = res.size();
1494-
res.push_back({.id = id, .f = f,
1495-
.d = static_cast<Depth>(res[f].d+1), .i = res[f].i,
1496-
.l = res[f].l, .r = res[f].r,
1497-
.b = res[c_last].t, .t = res[f].t,
1498-
.children = {}, .j = -1});
1490+
res.push_back({id, f,
1491+
static_cast<Depth>(res[f].d+1), res[f].i,
1492+
res[f].l, res[f].r,
1493+
res[c_last].t, res[f].t,
1494+
{}, -1, false, -1});
14991495
res[f].children.push_back(id);
15001496
}
15011497
}
@@ -1523,33 +1519,33 @@ Solution BranchingScheme::to_solution(
15231519
res[id].l, res[id].r, res[id].b, res[id].b + t, i, o);
15241520
if (k == -1) { // First item of the third-level sub-plate
15251521
SolutionNodeId c1 = res.size();
1526-
res.push_back({.id = c1, .f = id,
1527-
.d = static_cast<Depth>(res[id].d + 1), .i = res[id].i,
1528-
.l = res[id].l, .r = res[id].r,
1529-
.b = res[id].b, .t = res[id].b + t,
1530-
.children = {}, .j = j});
1522+
res.push_back({c1, id,
1523+
static_cast<Depth>(res[id].d + 1), res[id].i,
1524+
res[id].l, res[id].r,
1525+
res[id].b, res[id].b + t,
1526+
{}, j, false, -1});
15311527
res[id].children.push_back(c1);
15321528
SolutionNodeId c2 = res.size();
1533-
res.push_back({.id = c2, .f = id,
1534-
.d = static_cast<Depth>(res[id].d+1), .i = res[id].i,
1535-
.l = res[id].l, .r = res[id].r,
1536-
.b = res[id].b + t, .t = res[id].t,
1537-
.children = {}, .j = -1});
1529+
res.push_back({c2, id,
1530+
static_cast<Depth>(res[id].d+1), res[id].i,
1531+
res[id].l, res[id].r,
1532+
res[id].b + t, res[id].t,
1533+
{}, -1, false, -1});
15381534
res[id].children.push_back(c2);
15391535
} else {
15401536
SolutionNodeId c1 = res.size();
1541-
res.push_back({.id = c1, .f = id,
1542-
.d = static_cast<Depth>(res[id].d+1), .i = res[id].i,
1543-
.l = res[id].l, .r = res[id].r,
1544-
.b = res[id].b, .t = res[id].t - t,
1545-
.children = {}, .j = -1});
1537+
res.push_back({c1, id,
1538+
static_cast<Depth>(res[id].d+1), res[id].i,
1539+
res[id].l, res[id].r,
1540+
res[id].b, res[id].t - t,
1541+
{}, -1, false, -1});
15461542
res[id].children.push_back(c1);
15471543
SolutionNodeId c2 = res.size();
1548-
res.push_back({.id = c2, .f = id,
1549-
.d = static_cast<Depth>(res[id].d+1), .i = res[id].i,
1550-
.l = res[id].l, .r = res[id].r,
1551-
.b = res[id].t - t, .t = res[id].t,
1552-
.children = {}, .j = j});
1544+
res.push_back({c2, id,
1545+
static_cast<Depth>(res[id].d+1), res[id].i,
1546+
res[id].l, res[id].r,
1547+
res[id].t - t, res[id].t,
1548+
{}, j, false, -1});
15531549
res[id].children.push_back(c2);
15541550
}
15551551
}

packingsolver/rectangleguillotine/branching_scheme.hpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class BranchingScheme
7272
struct Insertion
7373
{
7474
/** Id of the item at the bottom of the third-level sub-plate, -1 if none. */
75-
ItemTypeId j1 = -1;
75+
ItemTypeId j1;
7676
/** Id of the item at the top of the third-level sub-plate, -1 if none. */
77-
ItemTypeId j2 = -1;
77+
ItemTypeId j2;
7878

7979
/**
8080
* Depth of the father in the tree representation of the solution:
@@ -84,36 +84,36 @@ class BranchingScheme
8484
* * -1: new bin, first stage veritical
8585
* * -2: new bin, first stage horizontal
8686
*/
87-
Depth df = -1;
87+
Depth df;
8888

8989
/** Position of the current 1-cut. */
90-
Length x1 = 0;
90+
Length x1;
9191
/** Position of the current 2-cut. */
92-
Length y2 = 0;
92+
Length y2;
9393
/** Position of the current 3-cut. */
94-
Length x3 = 0;
94+
Length x3;
9595

9696
/**
9797
* x1_max_ is the maximum position of the current 1-cut.
9898
* It is used when otherwise, a 2-cut of the current 1-level sub-plate
9999
* would intersect a defect.
100100
*/
101-
Length x1_max = -1;
101+
Length x1_max;
102102

103103
/**
104104
* y2_max_ is the maximum position of the current 2-cut.
105105
* It is used when otherwise, a 3-cut of the current 2-level sub-plate
106106
* would intersect a defect.
107107
*/
108-
Length y2_max = -1;
108+
Length y2_max;
109109

110110
/**
111111
* z1_
112112
* * 0: to increase the width of the last 1-cut, it is necessary to add at
113113
* least the minimum waste.
114114
* * 1: the width of the last 1-cut can be increased by any value.
115115
*/
116-
Counter z1 = 0;
116+
Counter z1;
117117

118118
/**
119119
* z2_
@@ -123,7 +123,7 @@ class BranchingScheme
123123
* * 2: the height of the last 2-cut cannot be increased (case where it
124124
* contains of 4-cut with 2 items).
125125
*/
126-
Counter z2 = 0;
126+
Counter z2;
127127

128128
bool operator==(const Insertion& insertion) const;
129129
bool operator!=(const Insertion& insertion) const { return !(*this == insertion); }

packingsolver/variables.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
STDCPP = select({
22
"@bazel_tools//src/conditions:windows": ['/std:c++latest'],
3-
"//conditions:default": ["-std=c++14"]})
3+
"//conditions:default": ["-std=c++11"]})
44

55
COINOR_COPTS = select({
66
"//packingsolver:coinor_build": ["-DCOINOR_FOUND"],

0 commit comments

Comments
 (0)