Page 1 of 1

Improving performance of distance matrix computation

Posted: Tue Mar 17, 2020 9:38 am
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?

Re: Improving performance of distance matrix computation

Posted: Tue Mar 17, 2020 11:23 am
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