MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / ProblemData

Method ProblemData

pyvrp/cpp/ProblemData.cpp:720–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718}
719
720ProblemData::ProblemData(std::vector<Client> clients,
721 std::vector<Depot> depots,
722 std::vector<VehicleType> vehicleTypes,
723 std::vector<Matrix<Distance>> distMats,
724 std::vector<Matrix<Duration>> durMats,
725 std::vector<ClientGroup> groups)
726 : dists_(std::move(distMats)),
727 durs_(std::move(durMats)),
728 clients_(std::move(clients)),
729 depots_(std::move(depots)),
730 vehicleTypes_(std::move(vehicleTypes)),
731 groups_(std::move(groups)),
732 numVehicles_(std::accumulate(vehicleTypes_.begin(),
733 vehicleTypes_.end(),
734 0,
735 [](auto sum, VehicleType const &type)
736 { return sum + type.numAvailable; })),
737 numLoadDimensions_(
738 clients_.empty()
739 // If there are no clients we look at the vehicle types. If both
740 // are empty we default to 0. Clients have pickups and deliveries
741 // but the client constructor already ensures those are of equal
742 // size (within a single client).
743 ? (vehicleTypes_.empty() ? 0 : vehicleTypes_[0].capacity.size())
744 : clients_[0].delivery.size()),
745 hasTimeWindows_(
746 std::any_of(clients_.begin(), clients_.end(), hasTimeWindow<Client>)
747 || std::any_of(depots_.begin(), depots_.end(), hasTimeWindow<Depot>)
748 || std::any_of(vehicleTypes_.begin(),
749 vehicleTypes_.end(),
750 hasTimeWindow<VehicleType>))
751{
752 for (auto const &client : clients_)
753 {
754 centroid_.first += static_cast<double>(client.x) / numClients();
755 centroid_.second += static_cast<double>(client.y) / numClients();
756 }
757
758 validate();
759}

Callers

nothing calls this directly

Calls 4

beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected