| 132 | } |
| 133 | |
| 134 | bool Solution::operator==(Solution const &other) const |
| 135 | { |
| 136 | // clang-format off |
| 137 | bool const attributeChecks = distance_ == other.distance_ |
| 138 | && duration_ == other.duration_ |
| 139 | && distanceCost_ == other.distanceCost_ |
| 140 | && durationCost_ == other.durationCost_ |
| 141 | && timeWarp_ == other.timeWarp_ |
| 142 | && isGroupFeas_ == other.isGroupFeas_ |
| 143 | && routes_.size() == other.routes_.size() |
| 144 | && neighbours_ == other.neighbours_; |
| 145 | // clang-format on |
| 146 | |
| 147 | if (!attributeChecks) |
| 148 | return false; |
| 149 | |
| 150 | // The visits are the same for both solutions, but the vehicle |
| 151 | // assignments need not be. We check this via a mapping from the first |
| 152 | // client in each route to the vehicle type of that route. We need to |
| 153 | // base this on the visits since the route order can differ between |
| 154 | // solutions. |
| 155 | std::unordered_map<Client, VehicleType> client2vehType; |
| 156 | for (auto const &route : routes_) |
| 157 | client2vehType[route[0]] = route.vehicleType(); |
| 158 | |
| 159 | for (auto const &route : other.routes_) |
| 160 | if (client2vehType[route[0]] != route.vehicleType()) |
| 161 | return false; |
| 162 | |
| 163 | return true; |
| 164 | } |
| 165 | |
| 166 | Solution::Solution(ProblemData const &data, RandomNumberGenerator &rng) |
| 167 | : neighbours_(data.numLocations(), std::nullopt) |
nothing calls this directly
no test coverage detected