Network Analyst Solver (arcpy)
Резюме
Предоставляет свойства анализа, применяемые в механизме расчета сетевого анализа.
Обсуждение
Эти свойства являются общими для всех механизмов расчета network analyst, например, свойство импеданса (impedance) может определяться при непосредственном описании слоя сетевого анализа. Однако некоторые свойства, например, UseTimeWindows, поддерживаются только отдельными механизмами расчета, указанное свойство поддерживается механизмом расчета маршрута. Свойства, доступные для объекта механизма расчета сетевого анализа, зависят от связанного со слоем механизма расчета. Используйте свойство solverName, чтобы установить механизм расчета, связанный со слоем сетевого анализа, и с помощью следующих ссылок определить доступные свойства объекта.
Пример кода
Описывает свойства объекта механизма расчета network analyst.
# Name: NALayerSolverProperties_ex01.py
# Description: Lists all the solver specific properties that can be
# derived by describing a network analysis layer.
import arcpy
# ============
# Helper functions
# ============
def printRoute(justify=35):
'''Displays information about a Route layer'''
arcpy.AddMessage("---- Route properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Find Best Sequence?",
props.findBestSequence))
arcpy.AddMessage(" %*s: %s" % (justify, "OrderingType",
props.orderingType))
arcpy.AddMessage(" %*s: %s" % (justify, "Use Time Windows?",
props.useTimeWindows))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.routesShape))
arcpy.AddMessage(" %*s: %s" % (justify, "Start Time", props.startTime))
def printClosestFac(justify=35):
'''Displays information about a Closest Facility layer'''
arcpy.AddMessage("---- Closest Facilty properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Travel Direction",
props.travelDirection))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Target Facility Count",
props.defaultTargetFacilityCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Cutoff",
props.defaultCutoff))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.cfRoutesShape))
def printServiceArea(justify=35):
'''Displays information about a Service Area layer'''
arcpy.AddMessage("---- Service Area properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Travel Direction",
props.travelDirection))
arcpy.AddMessage(" %*s: %s" % (justify, "Default breaks",
props.defaultBreaks))
# Polygon info
arcpy.AddMessage(" ")
arcpy.AddMessage(" %*s: %s" % (justify, "Polygon Type?",
props.serviceAreaPolygons))
arcpy.AddMessage(" %*s: %s" % (justify, "Overlap Type",
props.serviceAreaPolygonType))
arcpy.AddMessage(" %*s: %s" % (justify, "Multiple Facilities Options?",
props.mergeSimilarRanges))
arcpy.AddMessage(" %*s: %s" % (justify, "Excluded sources",
props.exclusionSources))
arcpy.AddMessage(" %*s: %s" % (justify, "Trim Polygons?",
props.trimPolygons))
arcpy.AddMessage(" %*s: %s" % (justify, "Trim Distance?",
props.trimDistance))
# Line info
arcpy.AddMessage(" ")
arcpy.AddMessage(" %*s: %s" % (justify, "Line overlap type",
props.serviceAreaLinesType))
arcpy.AddMessage(" %*s: %s" % (justify, "Split lines at breaks?",
props.splitLinesAtBreaks))
arcpy.AddMessage(" %*s: %s" % (justify, "Output line shape",
props.serviceAreaLines))
arcpy.AddMessage(" %*s: %s" % (justify, "Output line shape",
props.includeNetworkSourceFields))
def printODMatrix(justify=40):
'''Displays information about an OD Cost Matrix layer.'''
arcpy.AddMessage("---- OD Cost Matrix properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Target Destination Count",
props.defaultTargetDestinationCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Cutoff",
props.defaultCutoff))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.odLinesShape))
def printVRP(justify=35):
'''Displays information about a Vehicle routing problem layer'''
arcpy.AddMessage("---- Vehicle Routing Problem properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Date",
props.defaultDate))
arcpy.AddMessage(" %*s: %s" % (justify, "Capacity Count",
props.capacityCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Time Field Units",
props.timeFieldUnits))
arcpy.AddMessage(" %*s: %s" % (justify, "Distance Field Units",
props.distanceFieldUnits))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.vrpRoutesShape))
arcpy.AddMessage(" %*s: %s"%(justify,"Time window violation penalty factor",
props.timeWindowViolationPenaltyFactor))
arcpy.AddMessage(" %*s: %s"%(justify,"Penalty factor value",
props.timeWindowViolationPenaltyFactorValue))
arcpy.AddMessage(" %*s: %s" % (justify,"Excess transit time penalty factor",
props.excessTransitTimePenaltyFactor))
arcpy.AddMessage(" %*s: %s" % (justify,"Penalty factor value",
props.excessTransitTimePenaltyFactorValue))
def printLocationAllocation(justify=35):
'''Displays information about a Location-Allocation layer'''
arcpy.AddMessage("---- Location-Allocation properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Travel from" ,
props.travelDirection))
arcpy.AddMessage(" %*s: %s" % (justify, "Location-allocation problem type",
props.problemType))
arcpy.AddMessage(" %*s: %s" % (justify, "Number of facilities to find",
props.defaultTargetFacilityCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Impedance cutoff",
props.defaultCutoff))
arcpy.AddMessage(" %*s: %s" % (justify, "Impedance transformation",
props.impedanceTransformation))
arcpy.AddMessage(" %*s: %s" % (justify, "Impedance parameter",
props.impedanceParameter))
arcpy.AddMessage(" %*s: %s" % (justify, "Target market share",
props.targetMarketShare))
arcpy.AddMessage(" %*s: %s" % (justify, "Output path shape",
props.laLinesShape))
# ============
# main module
# ============
# Get the arguments..
in_layer = "C:/Data/Route.lyr"
justify = 35
#Describe the layer file and get the solver name
desc = arcpy.Describe(in_layer)
solvername = desc.solvername
# Branch on type of solver (Route, Closest Facility, etc)
if solvername.lower() == "route solver":
printRoute(justify)
elif solvername.lower() == "closest facility solver":
printClosestFac(justify)
elif solvername.lower() == "service area solver":
printServiceArea(justify)
elif solvername.lower() == "od cost matrix solver":
printODMatrix(justify)
elif solvername.lower() == "vehicle routing problem solver":
printVRP(justify)
elif solvername.lower() == "location-allocation solver":
printLocationAllocation(justify)
else:
arcpy.AddError("Unknown solver: %s" % solvername)
arcpy.AddMessage(" ")
arcpy.AddMessage("==== End description ====")
arcpy.AddMessage(" ")