Skip to content

Commit 397ca3d

Browse files
committed
Implement scaling in irregular solver
1 parent 9ef90b9 commit 397ca3d

File tree

13 files changed

+838
-717
lines changed

13 files changed

+838
-717
lines changed

data/irregular/users/2024-08-08_solution.json

Lines changed: 302 additions & 302 deletions
Large diffs are not rendered by default.

data/irregular/users/2024-08-08_sub_1_solution.json

Lines changed: 149 additions & 146 deletions
Large diffs are not rendered by default.

data/irregular/users/2024-08-08_sub_2_solution.json

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
]
9898
}
9999
],
100+
"mirror": false,
100101
"x": 0.0,
101102
"y": 0.0
102103
},
@@ -108,92 +109,93 @@
108109
"shape": [
109110
{
110111
"type": "LineSegment",
111-
"xe": 19.68503949,
112-
"xs": 39.37007886000001,
112+
"xe": 19.68503961,
113+
"xs": 39.37007898,
113114
"ye": 19.68503949,
114115
"ys": 19.685039370000002
115116
},
116117
{
117118
"type": "LineSegment",
118-
"xe": 19.68503948,
119-
"xs": 19.68503949,
119+
"xe": 19.6850396,
120+
"xs": 19.68503961,
120121
"ye": 17.71653555,
121122
"ys": 19.68503949
122123
},
123124
{
124125
"type": "LineSegment",
125-
"xe": 37.40157491,
126-
"xs": 19.68503948,
126+
"xe": 37.401575030000004,
127+
"xs": 19.6850396,
127128
"ye": 17.716535450000002,
128129
"ys": 17.71653555
129130
},
130131
{
131132
"type": "LineSegment",
132-
"xe": 37.401574870000005,
133-
"xs": 37.40157491,
133+
"xe": 37.40157499,
134+
"xs": 37.401575030000004,
134135
"ye": 10.82677167,
135136
"ys": 17.716535450000002
136137
},
137138
{
138139
"type": "LineSegment",
139-
"xe": 19.68503944,
140-
"xs": 37.401574870000005,
140+
"xe": 19.68503956,
141+
"xs": 37.40157499,
141142
"ye": 10.82677178,
142143
"ys": 10.82677167
143144
},
144145
{
145146
"type": "LineSegment",
146-
"xe": 19.685039420000003,
147-
"xs": 19.68503944,
147+
"xe": 19.685039540000002,
148+
"xs": 19.68503956,
148149
"ye": 8.85826784,
149150
"ys": 10.82677178
150151
},
151152
{
152153
"type": "LineSegment",
153-
"xe": 37.401574860000004,
154-
"xs": 19.685039420000003,
154+
"xe": 37.40157498000001,
155+
"xs": 19.685039540000002,
155156
"ye": 8.85826773,
156157
"ys": 8.85826784
157158
},
158159
{
159160
"type": "LineSegment",
160-
"xe": 37.40157482000001,
161-
"xs": 37.401574860000004,
161+
"xe": 37.40157494,
162+
"xs": 37.40157498000001,
162163
"ye": 1.96850395,
163164
"ys": 8.85826773
164165
},
165166
{
166167
"type": "LineSegment",
167-
"xe": 19.685039380000003,
168-
"xs": 37.40157482000001,
168+
"xe": 19.685039500000002,
169+
"xs": 37.40157494,
169170
"ye": 1.9685040600000001,
170171
"ys": 1.96850395
171172
},
172173
{
173174
"type": "LineSegment",
174-
"xe": 19.685039370000002,
175-
"xs": 19.685039380000003,
175+
"xe": 19.68503949,
176+
"xs": 19.685039500000002,
176177
"ye": 1.2e-07,
177178
"ys": 1.9685040600000001
178179
},
179180
{
180181
"type": "LineSegment",
181-
"xe": 39.370078740000004,
182-
"xs": 19.685039370000002,
182+
"xe": 39.37007886000001,
183+
"xs": 19.68503949,
183184
"ye": 0.0,
184185
"ys": 1.2e-07
185186
},
186187
{
187188
"type": "LineSegment",
188-
"xe": 39.37007886000001,
189-
"xs": 39.370078740000004,
189+
"xe": 39.37007898,
190+
"xs": 39.37007886000001,
190191
"ye": 19.685039370000002,
191192
"ys": 0.0
192193
}
193194
]
194195
}
195196
],
196-
"x": 19.685039370000002,
197+
"mirror": false,
198+
"x": 19.68503949,
197199
"y": 0.0
198200
},
199201
{
@@ -204,92 +206,93 @@
204206
"shape": [
205207
{
206208
"type": "LineSegment",
207-
"xe": 39.37007886000001,
208-
"xs": 59.055118230000005,
209+
"xe": 39.37007899,
210+
"xs": 59.05511836,
209211
"ye": 19.68503949,
210212
"ys": 19.685039370000002
211213
},
212214
{
213215
"type": "LineSegment",
214-
"xe": 39.370078850000006,
215-
"xs": 39.37007886000001,
216+
"xe": 39.37007898,
217+
"xs": 39.37007899,
216218
"ye": 17.71653555,
217219
"ys": 19.68503949
218220
},
219221
{
220222
"type": "LineSegment",
221-
"xe": 57.086614280000006,
222-
"xs": 39.370078850000006,
223+
"xe": 57.086614409999996,
224+
"xs": 39.37007898,
223225
"ye": 17.716535450000002,
224226
"ys": 17.71653555
225227
},
226228
{
227229
"type": "LineSegment",
228-
"xe": 57.08661424,
229-
"xs": 57.086614280000006,
230+
"xe": 57.08661437,
231+
"xs": 57.086614409999996,
230232
"ye": 10.82677167,
231233
"ys": 17.716535450000002
232234
},
233235
{
234236
"type": "LineSegment",
235-
"xe": 39.37007881,
236-
"xs": 57.08661424,
237+
"xe": 39.37007894,
238+
"xs": 57.08661437,
237239
"ye": 10.82677178,
238240
"ys": 10.82677167
239241
},
240242
{
241243
"type": "LineSegment",
242-
"xe": 39.37007879,
243-
"xs": 39.37007881,
244+
"xe": 39.37007892,
245+
"xs": 39.37007894,
244246
"ye": 8.85826784,
245247
"ys": 10.82677178
246248
},
247249
{
248250
"type": "LineSegment",
249-
"xe": 57.08661423000001,
250-
"xs": 39.37007879,
251+
"xe": 57.08661436,
252+
"xs": 39.37007892,
251253
"ye": 8.85826773,
252254
"ys": 8.85826784
253255
},
254256
{
255257
"type": "LineSegment",
256-
"xe": 57.086614190000006,
257-
"xs": 57.08661423000001,
258+
"xe": 57.08661432,
259+
"xs": 57.08661436,
258260
"ye": 1.96850395,
259261
"ys": 8.85826773
260262
},
261263
{
262264
"type": "LineSegment",
263-
"xe": 39.370078750000005,
264-
"xs": 57.086614190000006,
265+
"xe": 39.37007888,
266+
"xs": 57.08661432,
265267
"ye": 1.9685040600000001,
266268
"ys": 1.96850395
267269
},
268270
{
269271
"type": "LineSegment",
270-
"xe": 39.370078740000004,
271-
"xs": 39.370078750000005,
272+
"xe": 39.37007887,
273+
"xs": 39.37007888,
272274
"ye": 1.2e-07,
273275
"ys": 1.9685040600000001
274276
},
275277
{
276278
"type": "LineSegment",
277-
"xe": 59.05511811000001,
278-
"xs": 39.370078740000004,
279+
"xe": 59.05511824,
280+
"xs": 39.37007887,
279281
"ye": 0.0,
280282
"ys": 1.2e-07
281283
},
282284
{
283285
"type": "LineSegment",
284-
"xe": 59.055118230000005,
285-
"xs": 59.05511811000001,
286+
"xe": 59.05511836,
287+
"xs": 59.05511824,
286288
"ye": 19.685039370000002,
287289
"ys": 0.0
288290
}
289291
]
290292
}
291293
],
292-
"x": 39.370078740000004,
294+
"mirror": false,
295+
"x": 39.37007887,
293296
"y": 0.0
294297
}
295298
],

extern/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ FetchContent_MakeAvailable(optimizationtools)
1414
FetchContent_Declare(
1515
shape
1616
GIT_REPOSITORY https://github.com/fontanf/shape.git
17-
GIT_TAG f4e00d557956fb74f4e10a06af7dc9d1659147ec
17+
GIT_TAG 6e4d6131b9fe94acfbf98ce10ca78a0282f1a6bc
1818
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../shape/"
1919
EXCLUDE_FROM_ALL)
2020
FetchContent_MakeAvailable(shape)

include/packingsolver/algorithms/common.hpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,17 @@ using GuideId = int16_t;
4545

4646
inline bool strictly_lesser(double v1, double v2)
4747
{
48-
if (v1 >= v2)
49-
return false;
50-
return v2 - v1 > 1e-9 * (std::max)((std::max)(1e-5, std::abs(v1)), std::abs(v2));
48+
return v2 - v1 > 1e-6;
5149
}
5250

5351
inline bool strictly_greater(double v1, double v2)
5452
{
55-
if (v1 <= v2)
56-
return false;
57-
return v1 - v2 > 1e-9 * (std::max)((std::max)(1e-5, std::abs(v1)), std::abs(v2));
53+
return v1 - v2 > 1e-6;
5854
}
5955

6056
inline bool equal(double v1, double v2)
6157
{
62-
if (v1 == v2)
63-
return true;
64-
return std::abs(v1 - v2) <= 1e-9 * (std::max)((std::max)(1e-5, std::abs(v1)), std::abs(v2));
58+
return std::abs(v1 - v2) <= 1e-6;
6559
}
6660

6761
template<typename T>
@@ -78,6 +72,20 @@ double largest_power_of_two_lesser_or_equal(T value)
7872
return res;
7973
}
8074

75+
template<typename T>
76+
double smallest_power_of_two_greater_or_equal(T value)
77+
{
78+
double res = 1;
79+
if (res < value) {
80+
while (res < value)
81+
res *= 2;
82+
} else {
83+
while (res / 2 > value)
84+
res /= 2;
85+
}
86+
return res;
87+
}
88+
8189

8290
enum class OptimizationMode
8391
{

0 commit comments

Comments
 (0)