This document is archived and information here might be outdated.  Recommended version.


How to speed up VRP solves (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Spatial query and analysis > Network analysis > Programming with the ArcGIS Network Analyst extension > How to speed up VRP solves

How to speed up VRP solves


Speeding up VRP solves

The OD Cost Matrix internal to a Vehicle Routing Problem (VRP) can be configured to be reused on subsequent solves of the same VRP. This reduces the time it takes to solve a VRP.
To speed up solving VRPs by reusing previous results on subsequent solves, perform the following steps:
  1. Retrieve the internal OD Cost Matrix Result object.
  2. Set the result to save its matrix when persisting the VRP layer.
  3. Set the internal OD result of the VRP layer to only update for added/removed orders or depots.
These steps are shown in the following code:
[C#]
public void SetVRPLayerToSaveODInUpdateMode(ESRI.ArcGIS.NetworkAnalyst.INALayer
    vrpLayer)
{
    // Retrieve the internal OD cost matrix result object.
    var vrpResult=vrpLayer.Context.Result as
        ESRI.ArcGIS.NetworkAnalyst.INAVRPResult;
    var odResult=vrpResult.InternalODCostMatrix as
        ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixResult;

    // Set the result to save its matrix when persisting the VRP layer.
    odResult.SaveMatrixOnPersist=true;

    // Set the internal OD result of the VRP layer to only update for added/removed orders or depots.
    var vrpSolverSettings=vrpLayer.Context.Solver as
        ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver;
    vrpSolverSettings.InternalODCostMatrixType =
        ESRI.ArcGIS.NetworkAnalyst.esriNAODCostMatrixType.esriNAODCostMatrixUpdate;
}
[VB.NET]
Public Sub SetVRPLayerToSaveODInUpdateMode(ByVal vrpLayer As ESRI.ArcGIS.NetworkAnalyst.INALayer)
    ' Retrieve the internal OD cost matrix result object.
    Dim vrpResult=TryCast(vrpLayer.Context.Result, ESRI.ArcGIS.NetworkAnalyst.INAVRPResult)
    Dim odResult=TryCast(vrpResult.InternalODCostMatrix, ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixResult)
    
    ' Set the result to save its matrix when persisting the VRP layer.
    odResult.SaveMatrixOnPersist=True
    
    ' Set the internal OD result of the VRP layer to only update for added/removed orders or depots.
    Dim vrpSolverSettings=TryCast(vrpLayer.Context.Solver, ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver)
    vrpSolverSettings.InternalODCostMatrixType=ESRI.ArcGIS.NetworkAnalyst.esriNAODCostMatrixType.esriNAODCostMatrixUpdate
End Sub


See Also:

What is ArcGIS Network Analyst extension?
About the ArcGIS Network Analyst extension Tutorial
Essential ArcGIS Network Analyst extension vocabulary
NetworkAnalyst
ArcGIS Network Analyst extension Object Model Diagram
Samples:




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
Engine Developer Kit Engine: Network Analyst
ArcGIS Desktop Advanced: Network Analyst ArcGIS Desktop Advanced: Network Analyst
ArcGIS Desktop Standard: Network Analyst ArcGIS Desktop Standard: Network Analyst
ArcGIS Desktop Basic: Network Analyst ArcGIS Desktop Basic: Network Analyst