MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / setNeighbours

Method setNeighbours

pyvrp/cpp/search/SearchSpace.cpp:29–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void SearchSpace::setNeighbours(Neighbours neighbours)
30{
31 if (neighbours.size() != neighbours_.size())
32 throw std::runtime_error("Neighbourhood dimensions do not match.");
33
34 size_t numDepots = neighbours_.size() - clientOrder_.size();
35 for (size_t client = numDepots; client != neighbours.size(); ++client)
36 {
37 auto const beginPos = neighbours[client].begin();
38 auto const endPos = neighbours[client].end();
39
40 auto const pred
41 = [&](auto item) { return item == client || item < numDepots; };
42
43 if (std::any_of(beginPos, endPos, pred))
44 {
45 throw std::runtime_error("Neighbourhood of client "
46 + std::to_string(client)
47 + " contains itself or a depot.");
48 }
49 }
50
51 neighbours_ = neighbours;
52}
53
54SearchSpace::Neighbours const &SearchSpace::neighbours() const
55{

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected