| 27 | } |
| 28 | |
| 29 | void 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 | |
| 54 | SearchSpace::Neighbours const &SearchSpace::neighbours() const |
| 55 | { |