ArcGIS Desktop

  • 文档
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

VehicleRoutingProblemSolverProperties

  • 摘要
  • 说明
  • 属性
  • 方法概述
  • 方法
  • 代码示例

摘要

用于访问车辆配送 (VRP) 网络分析图层中的分析属性。GetSolverProperties 函数用于从车辆配送 (VRP) 网络分析图层中获取 VehicleRoutingProblemSolverProperties 对象。

说明

VehicleRoutingProblemSolverProperties 对象提供对车辆配送 (VRP) 网络分析图层中所有分析属性的读取和写入权限。该对象可用于修改车辆配送 (VRP) 图层的分析属性,并可重新求解相应图层以确定合适结果。使用创建车辆配送图层地理处理工具可创建新的车辆配送图层。通过从新的车辆配送图层获取 VehicleRoutingProblemSolverProperties 对象,可重新对现有图层进行后续分析,而无需每次分析都创建一个新图层,以节省时间。

修改 VehicleRoutingProblemSolverProperties 对象的属性后,可立即使用其他函数和地理处理工具分析相应图层。无需刷新或更新图层,通过上述对象进行的修改便可生效。

属性

属性说明数据类型
attributeParameters
(可读写)

用于获取或设置将在分析中使用的参数化属性。该属性返回一个 Python 字典。该字典关键字是由属性名称和参数名称这两个值组成的元组。字典中每个项目的值均为参数值。

参数化的网络属性用于对属性值的某个动态方面进行建模。例如,可使用某个参数对高度限制为 12 英尺的隧道进行建模。在这种情况下,应将以英尺为单位的车辆高度指定为参数值。如果车辆高度超过 12 英尺,此限制条件将评估为 True,从而限制车辆穿越隧道。类似的,桥梁还可以具有一个用来指定重量限制的参数。

尝试修改 attributeParameters 属性不会导致更新值。相反,您应始终使用新的字典对象来设置属性值。以下两个代码块将演示这两种方法的差异。

#Don't attempt to modify the attributeParameters property in place.
#This coding method won't work.
solverProps.attributeParameters[('HeightRestriction', 'RestrictionUsage')] = "PROHIBITED"
#Modify the attributeParameters property using a new dictionary object. #This coding method works. 
params = solverProps.attributeParameters params[('HeightRestriction', 'RestrictionUsage')] = "PROHIBITED"
solverProps.attributeParameters = params
如果网络分析图层没有参数化属性,则该属性将返回 None。

Dictionary
capacityCount
(可读写)

Provides the ability to get or set the number of capacity constraint dimensions required to describe the relevant limits of the vehicles.

Integer
defaultDate
(可读写)

Provides the ability to get or set the implied date for time field values that don't have a date specified with the time. If a time field for an order object, such as TimeWindowStart1, has a time-only value, the date is assumed to be the defaultDate property value. For example, if an order has a TimeWindowStart1 value of 9:00 AM and the defaultDate is set to datetime.date(2012, 3, 6), then the entire time value for the field is 9:00 A.M., March 6, 2012. The default date has no effect on time field values that already have a date.

The day of the week can also be specified as the default date using the following dates:

  • 今天 - 12/30/1899
  • 星期日 - 12/31/1899
  • 星期一 - 1/1/1900
  • 星期二 - 1/2/1900
  • 星期三 - 1/3/1900
  • 星期四 - 1/4/1900
  • 星期五 - 1/5/1900
  • 星期六 - 1/6/1900

For example, to specify that the implied date for time field values should be Tuesday, specify the property value as 1/2/1900.

DateTime
distanceAttribute
(可读写)

Provides the ability to get or set the distance cost attribute used to define the length along the elements of the network.

String
distanceFieldUnits
(可读写)

Provides the ability to get or set the distance units used by distance fields of the analysis layer's sublayers and tables (network analysis classes). The unit does not have to be the same as the unit of the network cost attribute specified as the timeAttribute property value. The following is a list of possible values:

  • Centimeters
  • Decimeters
  • Feet
  • Inches
  • Kilometers
  • Meters
  • Miles
  • Millimeters
  • NauticalMiles
  • Yards

String
excessTransitTimeImportance
(可读写)

Provides the ability to get or set the importance of reducing excess transit time. Excess transit time is the amount of time exceeding the time required to travel directly between the paired orders. The excess time results from breaks or travel to other orders or depots between visits to the paired orders. The following is a list of possible values:

  • High —The solver tries to find a solution with less excess transit time between paired orders at the expense of increasing the overall travel costs. It makes sense to use this setting if you are transporting people between paired orders and you want to shorten their ride time. This is characteristic of taxi services.
  • Medium —The solver looks for a balance between reducing excess transit time and reducing the overall solution cost.
  • Low —The solver tries to find a solution that minimizes overall solution cost, regardless of excess transit time. This setting is commonly used with courier services. Since couriers transport packages as opposed to people, they don't need to worry about ride time. Using Low allows the couriers to service paired orders in the proper sequence and minimize the overall solution cost.
String
outputPathShape
(可读写)

Provides the ability to get or set the shape type for the route features that are output by the solver. The following is a list of possible values:

  • TRUE_LINES_WITH_MEASURES —The output routes will have the exact shape of the underlying network sources. Furthermore, the output includes route measurements for linear referencing. The measurements increase from the first stop and record the cumulative impedance to reach a given position.
  • TRUE_LINES_WITHOUT_MEASURES —The output routes will have the exact shape of the underlying network sources.
  • STRAIGHT_LINES —The output route shape will be straight lines connecting orders and depot visits as per the route sequence.
  • NO_LINES —No shape will be generated for the output routes. You will also not be able to generate driving directions.
String
restrictions
(可读写)

用于获取或设置适用于分析的约束属性的列表。空列表 [] 表示没有约束属性用于分析。

String
solverName
(只读)

Returns the name of the solver being referenced by the Network Analyst layer used to obtain the solver properties object. The property always returns the string value Vehicle Routing Problem Solver when accessed from a VehicleRoutingProblemSolverProperties object.

String
timeAttribute
(可读写)

Provides the ability to get or set the time-based network cost attribute used to define the traversal time along the elements of the network. This cost attribute is minimized by the solver while finding the solution.

String
timeFieldUnits
(可读写)

Provides the ability to get or set the time unit used by the temporal fields of the analysis layer's sublayers and tables (network analysis classes). The unit does not have to be the same as the unit of the network cost attribute specified as the timeAttribute property value. The following is a list of possible values:

  • Days
  • Hours
  • Minutes
  • Seconds

String
timeWindowViolationImportance
(可读写)

Provides the ability to get or set the importance of honoring time windows without causing violations. A time window violation occurs when a route arrives at an order, depot, or break after a time window has closed. The violation is the interval between the end of the time window and the arrival time of a route. The following is a list of possible values:

  • High —The solver tries to find a solution that minimizes time window violations at the expense of increasing the overall travel time. Choose this option if arriving on time at orders is more important to you than minimizing your overall solution cost. This may be the case if you are meeting customers at your orders and you don't want to inconvenience them with tardy arrivals (another option is to use hard time windows that can't be violated at all).Given other constraints of a vehicle routing problem, it may be impossible to visit all the orders within their time windows. In this case, even using this option might produce violations.
  • Medium —The solver looks for a balance between meeting time windows and reducing the overall solution cost.
  • Low —The solver tries to find a solution that minimizes overall travel time, regardless of time windows. Choose this option if respecting time windows is less important than reducing your overall solution cost. You may want to use this setting if you have a growing backlog of service requests. For the purpose of servicing more orders in a day and reducing the backlog, you can choose this option even though customers will be inconvenienced with your fleet's late arrivals.
String
useHierarchy
(可读写)

当执行分析时控制等级属性的使用。以下是可能值列表:

  • USE_HIERARCHY — 使用等级属性进行分析。使用等级的结果是,求解程序更偏好高等级的边而不是低等级的边。分等级求解的速度更快,并且可用于模拟驾驶员在可能的情况下选择在高速公路而非地方道路上行驶(即使行程可能更远)的偏好。仅当 Network Analyst 图层引用的网络数据集具有等级属性时,此选项才适用。值 True 也可用于指定此选项。
  • NO_HIERARCHY —不使用等级属性进行分析。如果不使用等级属性,则会为网络数据集生成精确的路径。值 False 也可用于指定此选项。
String
uTurns
(可读写)

用于获取或设置策略,该策略指示求解程序如何处理停靠点之间的遍历网络期间所产生的交汇点处的 U 形转弯。以下是可能值列表:

  • ALLOW_UTURNS —无论在交汇点处有几条连接的边,均允许 U 形转弯。
  • NO_UTURNS —在所有交汇点处均禁止 U 形转弯,不管交汇点原子价如何。不过请注意,即使已选择该设置,在网络位置仍允许 U 形转弯;但是也可以通过设置个别网络位置的 CurbApproach 属性来禁止 U 形转弯。
  • ALLOW_DEAD_ENDS_ONLY —除仅有一条相邻边的交汇点(死角)外,其他交汇点均禁止 U 形转弯。
  • ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY —在恰好有两条相邻边相遇的交汇点处禁止 U 形转弯,但是交叉点(三条或三条以上相邻边的交汇点)和死角(仅有一条相邻边的交汇点)处允许。通常,网络在路段中间有多余的交汇点。此选项可防止车辆在这些位置出现 U 形转弯。
String

方法概述

方法说明
applyTravelMode (travel_mode)

根据出行模式对象更新网络分析图层的分析属性。随后可对更新的网络分析图层进行求解以完成分析。

方法

applyTravelMode (travel_mode)
参数说明数据类型
travel_mode

该变量引用一个源自网络数据集的出行模式对象。可通过调用 arcpy.na.GetTravelModes 函数获得出行模式对象的列表。

Object

创建网络分析图层后,将为其分配所有分析属性的默认值。可使用从网络分析图层获得的求解程序属性对象更新各个分析属性。出行模式存储了一组预定义的分析设置,用于帮助执行特定分析,例如,步行时间出行模式存储了执行基于时间的步行分析所需的分析设置。

使用 applyTravelMode 方法,可一次性应用在一个出行模式中定义的所有分析设置。在分析属性完成更新后,可对网络分析图层进行求解以完成分析。

如果在更新求解程序属性时出错,例如,当提供的出行模式所引用的属性在当前网络数据集中不存在,或不再适用于创建求解程序属性对象的相应网络分析图层所使用的网络数据集时,不会产生任何异常。此方法将成功执行,但当您尝试求解此类网络分析图层时会出现错误。

如果 travel_mode 参数不引用出行模式对象或字符串,则将产生 TypeError 异常。如果 travel_mode 参数引用字符串并且该字符串无法在内部转换成出行模式对象的有效字符串表示,将产生 ValueError 异常。

代码示例

VehicleRoutingProblemSolverProperties 示例 1

该脚本显示如何更新 ArcMap 内容列表中现有车辆配送图层的距离属性、默认日期、交汇点的 U 形转弯和输出 Shape 类型属性。它假设已经在新地图文档中根据旧金山地区的网络数据集创建名为 Store Delivery Routes 的车辆配送图层。

#Get the vehicle routing problem layer object from a layer named
#"Store Delivery Routes" in the table of contents
vrpLayer = arcpy.mapping.Layer("Store Delivery Routes")

#Get the solver properties object from the vehicle routing problem layer
solverProps = arcpy.na.GetSolverProperties(vrpLayer)

#Update the properties for the vehicle routing problem layer using the 
#solver properties object
solverProps.distanceAttribute = "Meters"
#Set the default date to be Monday
solverProps.defaultDate = datetime.date(1900,1,1)
solverProps.uTurns = "NO_UTURNS"
solverProps.outputPathShape = "STRAIGHT_LINES"
ApplyTravelMode 示例 2(工作流)

此脚本显示如何使用“货运时间”出行模式查找货车车队的路径。

#Import modules
import os
import arcpy

#Define variables
workspace = "C:/data/SanDiego.gdb"
output_folder = "C:/data/output"
nds = os.path.join(workspace, "Transportation", "Streets_ND")
orders = os.path.join(workspace, "Orders")
depots = os.path.join(workspace, "TruckDepots")
routes = os.path.join(workspace, "Drivers")
analysis_layer_name = "TruckRoutes"

#Set environment variables
arcpy.env.overwriteOutput = True

#Check out the network analyst extension
arcpy.CheckOutExtension("network")

#Create a new closest facility analysis layer
make_layer_result = arcpy.na.MakeVehicleRoutingProblemLayer(nds, analysis_layer_name,
                                                            "TravelTime")
analysis_layer = make_layer_result.getOutput(0)

#Add orders, depots and routes to the analysis layer using default field mappings         
sub_layer_names = arcpy.na.GetNAClassNames(analysis_layer)
order_layer_name = sub_layer_names["Orders"]
depot_layer_name = sub_layer_names["Depots"]
route_layer_name = sub_layer_names["Routes"]
arcpy.na.AddLocations(analysis_layer, order_layer_name, orders, "#", "#")
arcpy.na.AddLocations(analysis_layer, depot_layer_name, depots, "#", "#")
arcpy.na.AddLocations(analysis_layer, route_layer_name, routes, "#", "#")

#Get the Trucking Time travel mode from the network dataset
travel_modes = arcpy.na.GetTravelModes(nds)
trucking_mode = travel_modes["Trucking Time"]

#Apply the travel mode to the analysis layer
solver_properties = arcpy.na.GetSolverProperties(analysis_layer)
solver_properties.applyTravelMode(trucking_mode)

#Solve the analysis layer skipping any invalid orders and save the result as a layer file          
arcpy.na.Solve(analysis_layer, "SKIP")

output_layer = os.path.join(output_folder, analysis_layer_name + ".lyr")
arcpy.management.SaveToLayerFile(analysis_layer, output_layer, "RELATIVE")

arcpy.AddMessage("Completed")

相关主题

  • 车辆配送 (VRP) 分析

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明