Network Analyst Solver

Resumen

Provides the analysis properties specific to a network analyst solver.

Debate

The properties common to all the network analyst solvers such as impedance can be determined by directly describing the network analysis layer. However some properties such as UseTimeWindows are supported only by a particular solver, in this case the route solver. So the properties available on the network analyst solver object depends on the solver being referenced by the network analysis layer. Use the solverName property to determine the solver being referenced by the network analysis layer and use the links below to determine the properties available on the object.

Ejemplo de código

Network Analyst Solver Properties example

Displays the properties from the network analyst solver object.

# 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(" ") 

7/10/2012