<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ODCM &amp;quot;solve did not find a solution&amp;quot; error with arcpy.nax.solve on valid origins/destinations in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227294#M8062</link>
    <description>&lt;P&gt;I am trying to run an ODCM using arcpy.nax and I'm seeing this "Solve did not find a solution" error when running the example code below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Solving OD Cost Matrix...
# OD Cost Matrix solve failed.
# [[-2147200956, 'No "Destinations" found for "Location 1" in "Origins".'], [30212, 'Solve did not find a solution.'], [-2147200971, 'No solution found.']]&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

# Check out the NA license or alert error
class LicenseError(Exception):
  pass
  
if arcpy.CheckExtension("Network") == "Available":
  arcpy.CheckOutExtension("Network")
else:
  raise LicenseError("You need the ArcGIS Network Analyst extension license. Please contact your KP administrator.")

try:
  arcpy.env.overwriteOutput = True

  # Set environment variables
  nds = r"path/to/StreetMapPremium/FGDB/StreetMap_Data/NorthAmerica.gdb/Routing/Routing_ND" # &amp;lt;path to your network dataset&amp;gt;
  gdb = r"path/to/scratch.gdb" # &amp;lt;path to your working geodatabase&amp;gt;
  in_origins = os.path.join(gdb, "in_org") #   nw block group weighted centroids
  in_destinations = os.path.join(gdb,"in_dest") # nw pc mob locations
  out_lines = os.path.join(gdb,"od_cost_matrix_lines")
  

  nd_travel_modes = arcpy.nax.GetTravelModes(nds)
  travel_mode = nd_travel_modes["Driving Time"]

  # Instantiate a solver object
  odcm = arcpy.nax.OriginDestinationCostMatrix(nds)
  
  # Set object properties
  odcm.travelMode = travel_mode
  odcm.timeUnits = arcpy.nax.TimeUnits.Minutes
  # odcm.defaultImpedanceCutoff = 20
  # odcm.defaultDestinationCount = 2
  odcm.lineShapeType = arcpy.nax.LineShapeType.StraightLine

  
  # Load inputs
  odcm.load(
    arcpy.nax.OriginDestinationCostMatrixInputDataType.Origins, in_origins)
  odcm.load(
    arcpy.nax.OriginDestinationCostMatrixInputDataType.Destinations, in_destinations)
  
  # Solve the analysis
  print("Solving OD Cost Matrix...")
  result = odcm.solve()
  
  # Export the results to a feature class
  if result.solveSucceeded:
    print("OD Cost Matrix solve succeeded.")
  else:
    print("OD Cost Matrix solve failed.")
    print(result.solverMessages(arcpy.nax.MessageSeverity.All))

except Exception as e:
  import sys
  tb = sys.exc_info()[2]
  print(f"An error occured on line {tb.tb_lineno}")
  print(str(e))
  
# Solving OD Cost Matrix...
# OD Cost Matrix solve failed.
# [[-2147200956, 'No "Destinations" found for "Location 1" in "Origins".'], [30212, 'Solve did not find a solution.'], [-2147200971, 'No solution found.']]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The origin in question has the following coordinates:&amp;nbsp;&lt;STRONG&gt;33.492278, -117.247194&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The destination in question has the following coordinates:&amp;nbsp;&lt;STRONG&gt;33.90478,&amp;nbsp;-117.4693&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The ODCM solve succeeds when running by hand within ArcGIS Pro, however, this approach is calling arcpy.na methods behind the scenes, instead of arcpy.nax.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.na.MakeODCostMatrixAnalysisLayer(r"/path/to/StreetMapPremium/FGDB/StreetMap_Data/NorthAmerica.gdb/Routing/Routing_ND", "OD Cost Matrix", "Driving Time", None, None, None, "LOCAL_TIME_AT_LOCATIONS", "STRAIGHT_LINES", None)

arcpy.na.AddLocations("OD Cost Matrix", "Origins", "in_org", "Name # #;TargetDestinationCount # #;CurbApproach # 0;Cutoff_Minutes # #;Cutoff_TravelTime # #;Cutoff_Miles # #;Cutoff_Kilometers # #;Cutoff_TimeAt1KPH # #;Cutoff_WalkTime # #;Cutoff_TruckMinutes # #;Cutoff_TruckTravelTime # #", "5000 Meters", None, "Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE", "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "EXCLUDE", None)

arcpy.na.AddLocations("OD Cost Matrix", "Destinations", "in_dest", "Name # #;CurbApproach # 0", "5000 Meters", None, "Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "EXCLUDE", None)

arcpy.na.Solve("OD Cost Matrix", "SKIP", "TERMINATE", None, '')
# Start Time: Monday, October 31, 2022 9:54:53 AM
# Succeeded at Monday, October 31, 2022 9:54:54 AM (Elapsed Time: 0.81 seconds)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Can someone from Esri help me understand why the same origins/destinations are returning different results depending on whether arcpy.na or arcpy.nax methods are used? Any insight is appreciated!&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2022 22:44:43 GMT</pubDate>
    <dc:creator>PhilipOrlando</dc:creator>
    <dc:date>2022-10-31T22:44:43Z</dc:date>
    <item>
      <title>ODCM "solve did not find a solution" error with arcpy.nax.solve on valid origins/destinations</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227294#M8062</link>
      <description>&lt;P&gt;I am trying to run an ODCM using arcpy.nax and I'm seeing this "Solve did not find a solution" error when running the example code below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Solving OD Cost Matrix...
# OD Cost Matrix solve failed.
# [[-2147200956, 'No "Destinations" found for "Location 1" in "Origins".'], [30212, 'Solve did not find a solution.'], [-2147200971, 'No solution found.']]&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

# Check out the NA license or alert error
class LicenseError(Exception):
  pass
  
if arcpy.CheckExtension("Network") == "Available":
  arcpy.CheckOutExtension("Network")
else:
  raise LicenseError("You need the ArcGIS Network Analyst extension license. Please contact your KP administrator.")

try:
  arcpy.env.overwriteOutput = True

  # Set environment variables
  nds = r"path/to/StreetMapPremium/FGDB/StreetMap_Data/NorthAmerica.gdb/Routing/Routing_ND" # &amp;lt;path to your network dataset&amp;gt;
  gdb = r"path/to/scratch.gdb" # &amp;lt;path to your working geodatabase&amp;gt;
  in_origins = os.path.join(gdb, "in_org") #   nw block group weighted centroids
  in_destinations = os.path.join(gdb,"in_dest") # nw pc mob locations
  out_lines = os.path.join(gdb,"od_cost_matrix_lines")
  

  nd_travel_modes = arcpy.nax.GetTravelModes(nds)
  travel_mode = nd_travel_modes["Driving Time"]

  # Instantiate a solver object
  odcm = arcpy.nax.OriginDestinationCostMatrix(nds)
  
  # Set object properties
  odcm.travelMode = travel_mode
  odcm.timeUnits = arcpy.nax.TimeUnits.Minutes
  # odcm.defaultImpedanceCutoff = 20
  # odcm.defaultDestinationCount = 2
  odcm.lineShapeType = arcpy.nax.LineShapeType.StraightLine

  
  # Load inputs
  odcm.load(
    arcpy.nax.OriginDestinationCostMatrixInputDataType.Origins, in_origins)
  odcm.load(
    arcpy.nax.OriginDestinationCostMatrixInputDataType.Destinations, in_destinations)
  
  # Solve the analysis
  print("Solving OD Cost Matrix...")
  result = odcm.solve()
  
  # Export the results to a feature class
  if result.solveSucceeded:
    print("OD Cost Matrix solve succeeded.")
  else:
    print("OD Cost Matrix solve failed.")
    print(result.solverMessages(arcpy.nax.MessageSeverity.All))

except Exception as e:
  import sys
  tb = sys.exc_info()[2]
  print(f"An error occured on line {tb.tb_lineno}")
  print(str(e))
  
# Solving OD Cost Matrix...
# OD Cost Matrix solve failed.
# [[-2147200956, 'No "Destinations" found for "Location 1" in "Origins".'], [30212, 'Solve did not find a solution.'], [-2147200971, 'No solution found.']]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The origin in question has the following coordinates:&amp;nbsp;&lt;STRONG&gt;33.492278, -117.247194&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The destination in question has the following coordinates:&amp;nbsp;&lt;STRONG&gt;33.90478,&amp;nbsp;-117.4693&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The ODCM solve succeeds when running by hand within ArcGIS Pro, however, this approach is calling arcpy.na methods behind the scenes, instead of arcpy.nax.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.na.MakeODCostMatrixAnalysisLayer(r"/path/to/StreetMapPremium/FGDB/StreetMap_Data/NorthAmerica.gdb/Routing/Routing_ND", "OD Cost Matrix", "Driving Time", None, None, None, "LOCAL_TIME_AT_LOCATIONS", "STRAIGHT_LINES", None)

arcpy.na.AddLocations("OD Cost Matrix", "Origins", "in_org", "Name # #;TargetDestinationCount # #;CurbApproach # 0;Cutoff_Minutes # #;Cutoff_TravelTime # #;Cutoff_Miles # #;Cutoff_Kilometers # #;Cutoff_TimeAt1KPH # #;Cutoff_WalkTime # #;Cutoff_TruckMinutes # #;Cutoff_TruckTravelTime # #", "5000 Meters", None, "Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE", "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "EXCLUDE", None)

arcpy.na.AddLocations("OD Cost Matrix", "Destinations", "in_dest", "Name # #;CurbApproach # 0", "5000 Meters", None, "Routing_Streets SHAPE;Routing_Streets_Override NONE;Routing_ND_Junctions NONE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "EXCLUDE", None)

arcpy.na.Solve("OD Cost Matrix", "SKIP", "TERMINATE", None, '')
# Start Time: Monday, October 31, 2022 9:54:53 AM
# Succeeded at Monday, October 31, 2022 9:54:54 AM (Elapsed Time: 0.81 seconds)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Can someone from Esri help me understand why the same origins/destinations are returning different results depending on whether arcpy.na or arcpy.nax methods are used? Any insight is appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 22:44:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227294#M8062</guid>
      <dc:creator>PhilipOrlando</dc:creator>
      <dc:date>2022-10-31T22:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: ODCM "solve did not find a solution" error with arcpy.nax.solve on valid origins/destinations</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227318#M8063</link>
      <description>&lt;P&gt;Hi Philip!&lt;BR /&gt;&lt;BR /&gt;Could you provide me with a little more detail on what version of Pro you are using and the SMP data?&lt;BR /&gt;&lt;BR /&gt;I did try it an in-house version of Pro 3.1 and it failed within Pro as well. Upon further inspection, I found that the street on which the origin is located does not allow automobile. Unchecking 'Driving an automobile' in the travel settings resolved the issue.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would still like to reproduce the issue in-house by replicating your settings and software version.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 23:50:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227318#M8063</guid>
      <dc:creator>AmlanR</dc:creator>
      <dc:date>2022-10-31T23:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: ODCM "solve did not find a solution" error with arcpy.nax.solve on valid origins/destinations</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227518#M8067</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/452160"&gt;@AmlanR&lt;/a&gt;, thanks for the info! I'm using ArcGIS Pro 2.7.3 and SMP 2021.3.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I did some more digging yesterday and discovered that the Rounting_ND data that comes with Business Analyst was being selected from within the GUI (instead of SMP). Pointing my ArcPy script to this Routing_ND resulted in a successful ODCM solve.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there any other way to handle these points besides unchecking the "Driving an automobile" setting? Ideally, I would like this point to snap to the nearest edge where this is allowed instead of having to alter the travel mode.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 17:56:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/odcm-quot-solve-did-not-find-a-solution-quot-error/m-p/1227518#M8067</guid>
      <dc:creator>PhilipOrlando</dc:creator>
      <dc:date>2022-11-03T17:56:40Z</dc:date>
    </item>
  </channel>
</rss>

