Solve (Network Analyst)


Solves the network analysis layer problem based on its network locations and properties.



Solve_na (in_network_analysis_layer, {ignore_invalids}, {terminate_on_solve_error})
ParameterExplanationData Type

The network analysis layer on which the analysis will be computed.

Network Analyst Layer
  • SKIPThe solver will skip over network locations that are unlocated and solve the analysis layer from valid network locations only. It will also continue solving if locations are on nontraversable elements or have other errors. This is useful if you know your network locations are not all correct, but you want to solve with the network locations that are valid.
  • HALTDo not solve if there are invalid locations. You can then correct these and re-run the analysis.

For vehicle routing problem network analysis layer, use HALT as the parameter value since the vehicle routing problem solver requires all the network locations to be valid.

  • TERMINATEThe tool will fail to execute when the solver encounters an error. This is the default. When you use this option, the result object is not created when the tool fails to execute due to a solver error. You should obtain the geoprocessing messages from the ArcPy object.
  • CONTINUEThe tool will not fail and continue execution even when the solver encounters an error. All of the error messages returned by the solver will be converted to warning messages. When you use this option, the result object is always created and the maxSeverity property of the result object is set to 1 even when the solver encounters an error. Use the getOutput method of the result object with an index value of 1 to determine if the solve was successful.

Code Sample

Solve example 1 (Python window)

Execute the tool using all the parameters.

import arcpy
Solve example 2 (workflow)

The following stand-alone Python script demonstrates how the Solve tool can be used to perform a closest facility analysis and save results to a layer file.

# Name:
# Description: Solve a closest facility analysis to find the closest warehouse 
#              from the store locations and save the results to a layer file on 
#              disk.
# Requirements: Network Analyst Extension 
# Author: ESRI

#Import system modules
import arcpy
from arcpy import env

    #Check out the Network Analyst extension license

    #Set environment settings
    env.workspace = "C:/data/Paris.gdb"
    env.overwriteOutput = True
    #Set local variables
    inNetworkDataset = "Transportation/ParisMultimodal_ND"
    outNALayer = "ClosestWarehouse"
    impedanceAttribute = "Drivetime"
    accumulateAttributeName = ["Meters"]
    inFacilities = "Analysis/Warehouses"
    inIncidents = "Analysis/Stores"
    fieldMappings = "Name NOM #"
    outLayerFile = "C:/data/output" + "/" + outNALayer + ".lyr"
    #Create a new closest facility analysis layer. Apart from finding the drive 
    #time to the closest warehouse, we also want to find the total distance. So
    #we will accumulate the "Meters" impedance attribute.
    #Load the warehouses as Facilities using the default field mappings and 
    #search tolerance
    #Load the Stores as Incidents. Map the Name property from the NOM field
    #Solve the closest facility layer
    #Save the solved closest facility layer as a layer file on disk using
    #relative paths
    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)


Related Topics

Licensing Information

ArcView: Requires Network Analyst
ArcEditor: Requires Network Analyst
ArcInfo: Requires Network Analyst

Published 6/7/2010