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

Method validate

pyvrp/cpp/ProblemData.cpp:569–702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567size_t ProblemData::numLoadDimensions() const { return numLoadDimensions_; }
568
569void ProblemData::validate() const
570{
571 // Client checks.
572 for (size_t idx = numDepots(); idx != numLocations(); ++idx)
573 {
574 ProblemData::Client const &client = location(idx);
575
576 if (client.delivery.size() != numLoadDimensions_)
577 {
578 auto const *msg = "Client has inconsistent delivery size.";
579 throw std::invalid_argument(msg);
580 }
581
582 if (client.pickup.size() != numLoadDimensions_)
583 {
584 auto const *msg = "Client has inconsistent pickup size.";
585 throw std::invalid_argument(msg);
586 }
587
588 if (!client.group)
589 continue;
590
591 if (*client.group >= numGroups())
592 throw std::out_of_range("Client references invalid group.");
593
594 auto const &group = groups_[*client.group];
595 if (std::find(group.begin(), group.end(), idx) == group.end())
596 {
597 auto const *msg = "Client not in the group it references.";
598 throw std::invalid_argument(msg);
599 }
600
601 if (client.required && group.mutuallyExclusive)
602 {
603 auto const *msg = "Required client in mutually exclusive group.";
604 throw std::invalid_argument(msg);
605 }
606 }
607
608 // Depot checks.
609 if (depots_.empty())
610 throw std::invalid_argument("Expected at least one depot.");
611
612 // Group checks.
613 for (size_t idx = 0; idx != numGroups(); ++idx)
614 {
615 auto const &group = groups_[idx];
616
617 if (group.empty())
618 throw std::invalid_argument("Empty client group not understood.");
619
620 for (auto const client : group)
621 {
622 if (client < numDepots() || client >= numLocations())
623 throw std::out_of_range("Group references invalid client.");
624
625 ProblemData::Client const &clientData = location(client);
626 if (!clientData.group || *clientData.group != idx)

Callers

nothing calls this directly

Calls 7

hasTimeOverlapFunction · 0.85
numRowsMethod · 0.80
numColsMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected