ArcObjects Library Reference

Set Vehicle Routing Problem Properties Snippet

Set Vehicle Routing Problem solver parameters, including settings.

[C#]
/// <summary>Set Vehicle Routing Problem solver parameters, including settings.</summary>
/// <param name="naSolver">An INASolver interface.</param>
/// <param name="capacityCount"></param>
/// <param name="defaultDate"></param>
/// <param name="excessTransitTimePenaltyFactor"></param>
/// <param name="timeWindowViolationPenaltyFactor"></param>
/// <param name="distanceUnits"></param>
/// <param name="timeUnits"></param>
/// <returns>An INAVRPSolver with default parameters set.</returns>
public ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver SetVehicleRoutingProblemProperties(ESRI.ArcGIS.NetworkAnalyst.INASolver naSolver, int capacityCount, System.DateTime defaultDate,
       double excessTransitTimePenaltyFactor, double timeWindowViolationPenaltyFactor, ESRI.ArcGIS.Geodatabase.esriNetworkAttributeUnits distanceUnits,
        ESRI.ArcGIS.Geodatabase.esriNetworkAttributeUnits timeUnits)
{

    // Set Vehicle Routing Problem solver parameters, including settings for...
    ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver naVRPSolver = (ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver)naSolver;

    // Date and Time Settings
    naVRPSolver.DefaultDate = defaultDate;
    naVRPSolver.TimeFieldUnits = timeUnits;
    naVRPSolver.TimeWindowViolationPenaltyFactor = timeWindowViolationPenaltyFactor;
    naVRPSolver.ExcessTransitTimePenaltyFactor = excessTransitTimePenaltyFactor;

    // Distance Units for NAClass fields
    naVRPSolver.DistanceFieldUnits = distanceUnits;

    // OD Matrix and Route Settings
    naVRPSolver.InternalODCostMatrixType = ESRI.ArcGIS.NetworkAnalyst.esriNAODCostMatrixType.esriNAODCostMatrixFull;
    naVRPSolver.ExternalODCostMatrix = null;

    // Output
    naVRPSolver.OutputLines = ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineTrueShape;

    return naVRPSolver;
}
[Visual Basic .NET]
''' <summary>Set Vehicle Routing Problem solver parameters, including settings.</summary>
''' <param name="naSolver">An INASolver interface.</param>
''' <param name="capacityCount"></param>
''' <param name="defaultDate"></param>
''' <param name="excessTransitTimePenaltyFactor"></param>
''' <param name="timeWindowViolationPenaltyFactor"></param>
''' <param name="distanceUnits"></param>
''' <param name="timeUnits"></param>
''' <returns>An INAVRPSolver with default parameters set.</returns>
''' <remarks></remarks>
Public Function SetVehicleRoutingProblemProperties(ByVal naSolver As ESRI.ArcGIS.NetworkAnalyst.INASolver, _
                                                   ByVal capacityCount As System.Int32, _
                                                   ByVal defaultDate As System.DateTime, _
                                                   ByVal excessTransitTimePenaltyFactor As System.Double, _
                                                   ByVal timeWindowViolationPenaltyFactor As System.Double, _
                                                   ByVal distanceUnits As ESRI.ArcGIS.Geodatabase.esriNetworkAttributeUnits, _
                                                   ByVal timeUnits As ESRI.ArcGIS.Geodatabase.esriNetworkAttributeUnits) _
                                                   As ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver

    ' Set Vehicle Routing Problem solver parameters, including settings for... 
    Dim naVRPSolver As ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver = DirectCast(naSolver, ESRI.ArcGIS.NetworkAnalyst.INAVRPSolver)

    ' Date and Time Settings 
    naVRPSolver.DefaultDate = defaultDate
    naVRPSolver.TimeFieldUnits = timeUnits
    naVRPSolver.TimeWindowViolationPenaltyFactor = timeWindowViolationPenaltyFactor
    naVRPSolver.ExcessTransitTimePenaltyFactor = excessTransitTimePenaltyFactor

    ' Distance Units for NAClass fields 
    naVRPSolver.DistanceFieldUnits = distanceUnits

    ' OD Matrix and Route Settings 
    naVRPSolver.InternalODCostMatrixType = ESRI.ArcGIS.NetworkAnalyst.esriNAODCostMatrixType.esriNAODCostMatrixFull
    naVRPSolver.ExternalODCostMatrix = Nothing

    ' Output 
    naVRPSolver.OutputLines = ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineTrueShape

    Return naVRPSolver
End Function


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Geodatabase
  • ESRI.ArcGIS.NetworkAnalyst
  • ESRI.ArcGIS.System