TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
legalize.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
#pragma once
3
// (D) Legalisation (design doc 04 §3 D): Tetris-style greedy, largest parts first, each part moved to the
4
// nearest legal position (minimum Euclidean displacement over a lattice searched in rings) from its target.
5
// Candidates are screened with the conservative occupancy raster and always confirmed by the exact test.
6
#include <string>
7
8
#include "
place/legality.hpp
"
9
10
namespace
tmk::place
{
11
12
struct
LegaliseStats
{
13
int
placed
= 0;
// parts that were (re)placed
14
int
kept
= 0;
// parts already legal and left untouched (only_illegal mode)
15
int
failed
= 0;
// parts with no legal position found (left at their original position)
16
double
max_disp_mm
= 0,
mean_disp_mm
= 0;
17
long
exact_checks
= 0,
raster_checks
= 0;
18
long
evictions
= 0;
19
long
lookahead_rejects
= 0;
// spots refused because they left no room for a waiting big part // rip-up-and-re-place steps (full mode)
20
long
raster_disagree
= 0;
// raster said free but the exact test failed (must stay 0: the raster is conservative)
21
std::vector<std::string>
failures
;
22
std::vector<int>
failed_parts
;
23
};
24
25
// `only_illegal`: parts that are already legal (inside the board, conflict-free) stay where they are and only
26
// the others are re-placed (refine mode). `cell` is the raster cell (0 = automatic, 0.05–0.1 mm).
27
// `first`: parts to place before all others (e.g. the failures of an earlier attempt).
28
LegaliseStats
legalise
(
const
Problem
& p,
Placement
& pl,
bool
only_illegal,
Coord
cell = 0,
const
std::vector<int>* first =
nullptr
);
29
30
}
// namespace tmk::place
legality.hpp
Placement legality (design doc 04 §3 D/E): exact integer tests of courtyards, through-hole obstacles,...
tmk::place
Definition
anneal.hpp:34
tmk::place::legalise
LegaliseStats legalise(const Problem &p, Placement &pl, bool only_illegal, Coord cell=0, const std::vector< int > *first=nullptr)
only_illegal: parts that are already legal (inside the board, conflict-free) stay where they are and ...
tmk::Coord
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition
units.hpp:12
tmk::place::LegaliseStats
Definition
legalize.hpp:12
tmk::place::LegaliseStats::failed_parts
std::vector< int > failed_parts
Definition
legalize.hpp:22
tmk::place::LegaliseStats::failures
std::vector< std::string > failures
Definition
legalize.hpp:21
tmk::place::LegaliseStats::placed
int placed
parts that were (re)placed
Definition
legalize.hpp:13
tmk::place::LegaliseStats::evictions
long evictions
Definition
legalize.hpp:18
tmk::place::LegaliseStats::failed
int failed
parts with no legal position found (left at their original position)
Definition
legalize.hpp:15
tmk::place::LegaliseStats::exact_checks
long exact_checks
Definition
legalize.hpp:17
tmk::place::LegaliseStats::mean_disp_mm
double mean_disp_mm
Definition
legalize.hpp:16
tmk::place::LegaliseStats::raster_disagree
long raster_disagree
raster said free but the exact test failed (must stay 0: the raster is conservative)
Definition
legalize.hpp:20
tmk::place::LegaliseStats::raster_checks
long raster_checks
Definition
legalize.hpp:17
tmk::place::LegaliseStats::max_disp_mm
double max_disp_mm
Definition
legalize.hpp:16
tmk::place::LegaliseStats::lookahead_rejects
long lookahead_rejects
spots refused because they left no room for a waiting big part // rip-up-and-re-place steps (full mod...
Definition
legalize.hpp:19
tmk::place::LegaliseStats::kept
int kept
parts already legal and left untouched (only_illegal mode)
Definition
legalize.hpp:14
tmk::place::Placement
Definition
legality.hpp:13
tmk::place::Problem
Definition
problem.hpp:112
place
legalize.hpp
Generated by
1.15.0