VehicleRoutingProblemSolverProperties (arcpy.na)
摘要
用于访问车辆配送 (VRP) 网络分析图层中的分析属性。GetSolverProperties 函数用于从车辆配送 (VRP) 网络分析图层中获取 VehicleRoutingProblemSolverProperties 对象。
讨论
VehicleRoutingProblemSolverProperties 对象提供对车辆配送 (VRP) 网络分析图层中所有分析属性的读取和写入权限。该对象可用于修改车辆配送 (VRP) 图层的分析属性,并可重新求解相应图层以确定合适结果。使用 Make Vehicle Routing Problem Layer 地理处理工具可创建新的车辆配送图层。通过从新的车辆配送图层获取 VehicleRoutingProblemSolverProperties 对象,可重新对现有图层进行后续分析,而无需每次分析都创建一个新图层,以节省时间。
修改 VehicleRoutingProblemSolverProperties 对象的属性后,可立即使用其他函数和地理处理工具分析相应图层。无需刷新或更新图层,通过上述对象进行的修改便可生效。
属性
属性 | 说明 | 数据类型 |
attributeParameters (读写) | Provides the ability to get or set the parameterized attributes to be used in the analysis. The property returns a Python dictionary. The dictionary key is a two-value tuple consisting of the attribute name and the parameter name. The value for each item in the dictionary is the parameter value. Parameterized network attributes are used to model some dynamic aspect of an attribute's value. For example, a tunnel with a height restriction of 12 feet can be modeled using a parameter. In this case, the vehicle's height in feet should be specified as the parameter value. If the vehicle is taller than 12 feet, this restriction will then evaluate to true, thereby restricting travel through the tunnel. Similarly, a bridge could have a parameter to specify a weight restriction. Attempting to modify the attributeParameters property in place won't result in updated values. Instead, you should always use a new dictionary object to set values for the property. The following two code blocks demonstrate the difference between these two approaches.
| 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:
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:
| 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:
| 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:
| String |
restrictions (读写) | Provides the ability to get or set a list of restriction attributes that are applied for the analysis. An empty list, [], indicates that no restriction attributes are used for the analysis. | 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:
| 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:
| String |
useHierarchy (读写) | Controls the use of the hierarchy attribute while performing the analysis. The following is a list of possible values:
| String |
uTurns (读写) | Provides the ability to get or set the policy that indicates how the U-turns at junctions that could occur during network traversal between stops are being handled by the solver. The following is a list of possible values:
| String |
代码实例
该脚本显示如何更新 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"