概要
配車ルート (VRP) ネットワーク解析レイヤーを作成し、解析プロパティを設定します。VPR 解析レイヤーは、複数の車両による配送を最適化するときに役立ちます。このレイヤーを作成するには、ローカル ネットワーク データセットを使用するか、オンラインでホストされたサービスまたはポータル内のサービスを使用します。
[配車ルート (VRP) 解析レイヤーの作成 (Make Vehicle Routing Problem Analysis Layer)] ツールと [配車ルート (VRP) の解析 (Solve Vehicle Routing Problem)] ツールは類似していますが、それぞれ異なる目的で設計されています。ジオプロセシング サービスをセットアップする場合、[配車ルート (VRP) の解析 (Solve Vehicle Routing Problem)] ツールを使用すると、セットアップ プロセスが簡単になります。それ以外の場合は、[配車ルート (VRP) 解析レイヤーの作成 (Make Vehicle Routing Problem Analysis Layer)] ツールを使用します。
使用法
- このツールで解析レイヤーを作成した後は、[ロケーションの追加 (Add Locations)] ツールを使用して解析レイヤーにネットワーク解析オブジェクトを追加し、[解析の実行 (Solve)] ツールを使用して解析を実行し、[レイヤー ファイルの保存 (Save To Layer File)] ツールを使用して結果をディスクに保存することができます。 
- このツールをジオプロセシング モデルに使用するときは、モデルをツールとして動作させる場合、出力ネットワーク解析レイヤーにモデル パラメーターを作成する必要があります。そうしないと、出力レイヤーはマップのコンテンツに追加されません。 
構文
MakeVehicleRoutingProblemAnalysisLayer(network_data_source, {layer_name}, {travel_mode}, {time_units}, {distance_units}, {default_date}, {time_zone_for_time_fields}, {line_shape}, {time_window_factor}, {excess_transit_factor}, {generate_directions_on_solve}, {spatial_clustering})| パラメーター | 説明 | データ タイプ | 
| network_data_source | ネットワーク解析が実行されるネットワーク データセットまたはサービス。サービスのポータル URL を使用します。 | Network Dataset Layer; String | 
| layer_name (オプション) | 作成する配車ルート ネットワーク解析レイヤーの名前。 | String | 
| travel_mode (オプション) | 解析で使用する移動モードの名前。移動モードは、移動規制や U ターン ポリシーなど、歩行者、車、トラック、その他の交通手段がネットワークをどのように移動するかを決定するネットワーク設定のコレクションを表します。移動モードは、ネットワーク データ ソースに対して定義されます。arcpy.na.TravelMode オブジェクトおよび移動モードの有効な JSON 表現を含む文字列もパラメーターの入力として使用できます。 | String | 
| time_units (オプション) | 解析レイヤーのサブレイヤーおよびテーブル (ネットワーク解析のクラス) の時間的なフィールドで使用される時間の単位を指定します。この値は、時間コスト属性の単位と一致する必要はありません。 
 | String | 
| distance_units (オプション) | 解析レイヤーのサブレイヤーおよびテーブル (ネットワーク解析のクラス) の距離的なフィールドで使用される距離の単位を指定します。この値は、オプションである距離コスト属性の単位と一致する必要はありません。 
 | String | 
| default_date (オプション) | 時間フィールド値として日付が指定されない場合の日付。訪問先オブジェクトに対する時間フィールド (TimeWindowStart1 など) が時刻のみを示す値である場合、日付はデフォルトの日付となります。時間フィールド値として特定の日付がすでに指定されている場合、デフォルトの日付は無効になります。 | Date | 
| time_zone_for_time_fields (オプション) | このツールでサポートされている入力日時フィールドのタイム ゾーンを指定します。 
 UTC 形式での日時の値の指定は、訪問先や拠点があるタイム ゾーンが不明な場合や、訪問先と拠点が複数のタイムゾーンに分散しているときに、すべての日時の値を同時に開始する必要がある場合に役立ちます。[UTC] オプションは、ネットワーク データセットでタイム ゾーン属性が定義されている場合のみ適用されます。定義されていない場合、すべての日時の値は常にその場所に対応するタイム ゾーンと見なされます。 | String | 
| line_shape (オプション) | 解析で出力されるルート フィーチャの形状タイプを指定します。 
 どの出力形状のタイプを選択するかに関係なく、常に最適なルートはユークリッド距離ではなくネットワーク インピーダンスによって決定されます。これは、ルート形状のみが異なり、ネットワークの基となっているトラバースは同じであることを意味します。 | String | 
| time_window_factor (オプション) | 違反が発生しないタイム ウィンドウの重要度を指定します。タイム ウィンドウ違反は、タイム ウィンドウが閉じてから訪問先、拠点、または休憩にルートが到着した場合に発生します。この超過時間は、タイム ウィンドウの終了からルートの到着時間までの時間です。 
 | String | 
| excess_transit_factor (オプション) | 超過移動時間を減らすことの重要度を指定します。超過移動時間とは、訪問先ペア間を直接移動するのに必要な時間に対する超過時間です。この超過時間は、訪問先ペアへの立ち寄りの途中で、休憩を取ったり他の訪問先や拠点に移動することで発生します。このパラメーターは、訪問先ペアを使用する場合のみ関連します。 
 | String | 
| generate_directions_on_solve (オプション) | ルート案内を生成するかどうかを指定します。 
 | Boolean | 
| spatial_clustering (オプション) | 空間クラスタリングを使用するかどうかを指定します。 
 | Boolean | 
派生した出力
| 名前 | 説明 | データ タイプ | 
| out_network_analysis_layer | 新しいネットワーク解析レイヤー。 | Network Analyst レイヤー | 
コードのサンプル
必須パラメーターのみを使用してツールを実行します。
import arcpy 
arcpy.env.workspace = "C:/Data/SanFrancisco.gdb" 
arcpy.na.MakeVehicleRoutingProblemLayer("Transportation/Streets_ND")すべてのパラメーターを使用してツールを実行します。
import arcpy
arcpy.env.workspace = "C:/Data/SanFrancisco.gdb"
arcpy.na.MakeVehicleRoutingProblemAnalysisLayer('Streets_ND', 'FridayRoutes', 
                                                'Driving Time', 'Minutes', 
                                                'Miles', '1/2/2020', 
                                                'LOCAL_TIME_AT_LOCATIONS', 
                                                'TRUE_LINES_WITHOUT_MEASURES', 
                                                'High', 'Medium', 'DIRECTIONS')次のスタンドアロン Python スクリプトは、MakeVehicleRoutingProblemAnalysisLayer (配車ルート解析レイヤーの作成) ツールを使用して複数の車両で訪問先にサービスを提供する方法を示しています。
# Name: MakeVehicleRoutingProblemLayer_Workflow.py
# Description: Find the best routes for a fleet of vehicles, which is operated
#              by a distribution company, to deliver goods from a main
#              distribution center to a set of grocery stores.
# Requirements: Network Analyst Extension
# Import system modules
import arcpy
from arcpy import env
import os
try:
    # Check out the Network Analyst license if available. 
    # Fail if the Network Analyst
    # license is not available.
    if arcpy.CheckExtension("network") == "Available":
        arcpy.CheckOutExtension("network")
    else:
        raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
    # Set environment settings
    output_dir = "C:\Data"
    # The NA layer's data will be saved to the workspace specified here
    env.workspace = os.path.join(output_dir, "Output.gdb")
    env.overwriteOutput = True
    # Set local variables
    input_gdb = "C:/Data/SanFrancisco.gdb"
    network = os.path.join(input_gdb, "Transportation", "Streets_ND")
    layer_name = "StoreDeliveryRoute"
    travel_mode = "Driving Time"
    time_units = "Minutes"
    distance_units = "Miles"
    in_orders = os.path.join(input_gdb, "Analysis/Stores")
    in_depots = os.path.join(input_gdb, "Analysis/DistributionCenter")
    in_routes = os.path.join(input_gdb, "Analysis/Routes")
    output_layer_file = os.path.join(output_dir, layer_name + ".lyrx")
    # Create a new Vehicle Routing Problem (VRP) layer. Since the time-based
    # attributes such as ServiceTime on orders and CostPerUnitTime on routes is
    # recorded in minutes, we use minutes for time_units parameter. As we are
    # using cost per unit distance in routes, we have to specify a distance 
    # attribute. The values for CosterPerUnitDistance are in miles, so we
    # specify miles for distance units parameter
    result_object = arcpy.na.MakeVehicleRoutingProblemAnalysisLayer(network, 
                                            layer_name, travel_mode, 
                                            time_units, distance_units,
                                            line_shape="STRAIGHT_LINES")
    
    # Get the layer object form the result object. The route layer can now be
    # referenced using the layer object.
    layer_object = result_object.getOutput(0)
    # Get the names of all the sublayers within the VRP layer.
    sub_layer_names = arcpy.na.GetNAClassNames(layer_object)
    # Store the layer names that we will use later
    orders_layer_name = sub_layer_names["Orders"]
    depots_layer_name = sub_layer_names["Depots"]
    routes_layer_name = sub_layer_names["Routes"]
    # Load the store locations as orders. Using field mappings we map the
    # TimeWindowStart1, TimeWindowEnd1, and DeliveryQuantities properties
    # for Orders from the fields of store features and assign a value of
    # 0 to MaxViolationTime1 property. The Name and ServiceTime properties
    # have the correct mapped field names when using the candidate fields
    # from store locations feature class.
    candidate_fields = arcpy.ListFields(in_orders)
    order_field_mappings = arcpy.na.NAClassFieldMappings(layer_object, 
                                                         orders_layer_name,
                                                         False, candidate_fields)
    order_field_mappings["TimeWindowStart1"].mappedFieldName = "TimeStart1"
    order_field_mappings["TimeWindowEnd1"].mappedFieldName = "TimeEnd1"
    order_field_mappings["DeliveryQuantities"].mappedFieldName = "Demand"
    order_field_mappings["MaxViolationTime1"].defaultValue = 0
    arcpy.na.AddLocations(layer_object, orders_layer_name, in_orders, 
                          order_field_mappings, "")
    # Load the depots from the distribution center features. Using field mappings
    # we map the Name properties for Depots from the fields of distribution 
    # center features and assign a value of 8 AM for TimeWindowStart1 and a
    # value of 5 PM for TimeWindowEnd1 properties
    depot_field_mappings = arcpy.na.NAClassFieldMappings(layer_object, 
                                                         depots_layer_name)
    depot_field_mappings["Name"].mappedFieldName = "Name"
    depot_field_mappings["TimeWindowStart1"].defaultValue = "8 AM"
    depot_field_mappings["TimeWindowEnd1"].defaultValue = "5 PM"
    arcpy.na.AddLocations(layer_object, depots_layer_name, in_depots, 
                          depot_field_mappings, "")
    
    # Load the routes from a table containing information about routes. In this
    # case, since the fields on the routes table and property names for Routes
    # are the same, we will just use the default field mappings
    arcpy.na.AddLocations(layer_object, routes_layer_name, in_routes, "", "")
    # Solve the VRP layer
    arcpy.na.Solve(layer_object)
    # Save the solved VRP layer as a layer file on disk with relative paths
    arcpy.management.SaveToLayerFile(layer_object, output_layer_file, "RELATIVE")
    print ("Script Completed Successfully")
except Exception as e:
    # If an error occurred, print line number and error message
    import traceback
    import sys
    tb = sys.exc_info()[2]
    print ("An error occurred on line %i" % tb.tb_lineno)
    print (str(e))ライセンス情報
- Basic: はい
- Standard: はい
- Advanced: はい