Improving performance of distance matrix computation

deals with computation of distance matrices
Post Reply
jakubkurchan
Posts: 5
Joined: Tue Mar 17, 2020 9:00 am

Improving performance of distance matrix computation

Post by jakubkurchan »

Hello,

I'm trying to compute a square matrix of 3951 locations. I'm sending a request to XDima with parameters:
  1. startLocations - list of all 3951 locations
  2. destinationLocations - same list of all 3951 locations
  3. label - just some random name
All the other parameters are default ones. The computation took well over one hour on my server. Can you perhaps offer a suggestion as to how I could speed it up?
User avatar
Bernd Welter
Site Admin
Posts: 2564
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Improving performance of distance matrix computation

Post by Bernd Welter »

Hi Jakub,
( samples in C# )

this is a brilliant usecase for the high performance routing. For this you need a proper routing profile which supports HIGH_PERFORMANCE_ROUTING:
If you work with the cloud services you can gather the profiles through XData2.listHighPerformanceRoutingNetworks:

Code: Select all

HighPerformanceRoutingNetworksListResponse res = svcData.listHighPerformanceRoutingNetworks(new ListHighPerformanceRoutingNetworksRequest()
 {
     resultFields = new ListHighPerformanceRoutingNetworksResultFields() { 
         profilesSpecified = true,
         profiles = true,
         highPerformanceRoutingNetworkOptionsSpecified = true,
         highPerformanceRoutingNetworkOptions = true
  }
}) ;
Then apply this to the xDima2.dimaRequest and its requestProfile. Ensure to set proper values for the distanceMatrixOptions, too. This refers to RoutingType.HIGH_PERFORMANCE_ROUTING but also to the
DistanceMatrixOptions.geographicRestrictions
DistanceMatrixOptions.timeConsideration
DistanceMatrixOptions.contentSnapshotId
Look at this:

Code: Select all

CreateDistanceMatrixRequest dimaRequest = new CreateDistanceMatrixRequest()
{
         startLocations = dictLocation.Values.Select(l => l.routeLocation).ToArray(),
     distanceMatrixOptions = new DistanceMatrixOptions()
    {
      routingTypeSpecified = true,
      routingType = RoutingType.HIGH_PERFORMANCE_ROUTING,
     },
     requestProfile = info.highPerformanceRoutingNetworkDescription.profile
 };
 if (info.highPerformanceRoutingNetworkDescription != null)
  {
       dimaRequest.distanceMatrixOptions.geographicRestrictions = info.highPerformanceRoutingNetworkDescription?.highPerformanceRoutingNetworkOptions?.geographicRestrictions;
       dimaRequest.distanceMatrixOptions.timeConsideration = info.highPerformanceRoutingNetworkDescription?.highPerformanceRoutingNetworkOptions?.timeConsideration;
       dimaRequest.distanceMatrixOptions.contentSnapshotId = info.highPerformanceRoutingNetworkDescription?.highPerformanceRoutingNetworkOptions?.contentSnapshotId;
   }
Attention: you can't create own searchgraphs in the cloud.
If you work on premise you might need xData.startCreateHighPerformanceRoutingNetwork.

Best regards,
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Post Reply