Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Tujuan adalah parameter yang telah menentukan target pengoptimalan umum, seperti
jarak atau durasi perjalanan terpendek, pengiriman tepat waktu, penyeimbangan beban
antar-pengemudi. Tujuannya adalah untuk mempermudah developer mengaktifkan Route Optimization API sebelum mempelajari kecanggihan dan penyesuaian penuh parameter biaya. (Lihat "cost model" untuk mengetahui cara menyesuaikan sepenuhnya berbagai tujuan Anda)
Jika ditetapkan, ShipmentModel.objectives akan menggantikan model biaya
sepenuhnya, sehingga tidak kompatibel dengan biaya yang sudah ada. Setiap
Objective dipetakan ke sejumlah biaya yang telah ditentukan sebelumnya untuk kendaraan, pengiriman, atau
atribut transisi.
Saat menentukan mode penyelesaian TRANSFORM_AND_RETURN_REQUEST,
permintaan tidak diselesaikan, tetapi hanya divalidasi dan diisi dengan biaya
yang sesuai dengan tujuan yang diberikan. Permintaan yang diubah ditampilkan sebagai
OptimizeToursResponse.processed_request. Semua mode penyelesaian lainnya akan
menampilkan permintaan yang telah diselesaikan.
Mode penyelesaian TRANSFORM_AND_RETURN_REQUEST hanya valid untuk permintaan
OptimizeTours dan tidak tersedia untuk permintaan Route Optimization API
lainnya.
Contoh: Membuat permintaan ShipmentModel.objectives
Sebelum membuat permintaan, selesaikan langkah-langkah berikut:
Tetapkan PROJECT_NUMBER_OR_ID ke nomor atau ID project Cloud Anda.
Perintah berikut mengirimkan OptimizeToursRequest ke
Route Optimization API yang menampilkan OptimizeToursResponse dengan
setelan kolom ProcessedRequest.
[null,null,["Terakhir diperbarui pada 2025-08-29 UTC."],[],[],null,["\u003cbr /\u003e\n\n| This product or feature is Experimental (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](/maps/launch-stages).\n\n\u003cbr /\u003e\n\nObjectives are parameters that pre-define common optimization targets, such as\nshortest travel distance or duration, on time deliveries, balancing loads\nbetween drivers. It's meant to make it easier for developers to onboard to Route\nOptimization API before learning the sophications and full customization of cost\nparameters. (See \"[`cost model`](/maps/documentation/route-optimization/concepts/costs)\" for how to fully customize your wide variety of objectives)\n\nWhen set, the [`ShipmentModel.objectives`](/maps/tt/route-optimization/experimental/objectives/reference/rpc/google.maps.routeoptimization.v1#shipmentmodel) overwrite the cost model\ncompletely, therefore they are incompatible with pre-existing costs. Each\n[`Objective`](/maps/tt/route-optimization/experimental/objectives/reference/rpc/google.maps.routeoptimization.v1#objective) maps to a number of predefined costs for vehicles, shipments or\ntransition attributes.\n| **Note:** `OptimizeToursRequests` that have both costs and objectives set are invalid and will be rejected with a validation error.\n\nWhen specifying the [`TRANSFORM_AND_RETURN_REQUEST`](/maps/tt/route-optimization/experimental/objectives/reference/rpc/google.maps.routeoptimization.v1#solvingmode) solving mode,\nthe request is not solved and it is only validated and filled with costs\ncorresponding to the given objectives. The modified request is returned as\n[`OptimizeToursResponse.processed_request`](/maps/tt/route-optimization/experimental/objectives/reference/rpc/google.maps.routeoptimization.v1#optimizetoursresponse). All other solve modes will\nreturn the solved request.\n| **Note:** `TRANSFORM_AND_RETURN_REQUEST` requests are not billed.\n\nThe `TRANSFORM_AND_RETURN_REQUEST` solving mode is only valid for\n`OptimizeTours` requests and is not available for other Route Optimization API\nrequests.\n\nExample: Make a `ShipmentModel.objectives` request\n\nBefore making a request, complete the following steps:\n\n- Ensure you have [Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc) configured as described in [Use OAuth](/maps/documentation/route-optimization/oauth-token).\n- Set \u003cvar label=\"project_number\" translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e to your Cloud\n project number or ID.\n\n The following command sends an `OptimizeToursRequest` to the\n Route Optimization API which returns an `OptimizeToursResponse`. \n\n ```carbon\n curl -X POST 'https://routeoptimization.googleapis.com/v1/projects/\u003cvar label=\"project_number\" translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e:optimizeTours' \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n --data @- \u003c\u003cEOM\n {\n \"model\": {\n \"shipments\": [\n {\n \"pickups\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.42506261000996,\n \"longitude\": -122.09535511930135\n }\n }\n ],\n \"deliveries\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.42421503206021,\n \"longitude\": -122.09526063135228\n }\n }\n ]\n }\n ],\n \"vehicles\": [\n {\n \"travelMode\": \"DRIVING\",\n }\n ],\n \"objectives\": [\n {\n \"type\": \"MIN_TRAVEL_TIME\"\n }\n ],\n }\n }\n EOM\n ```\n | **Note:** This example uses the `--data @-` to read a request from standard input. Use `--data @`\u003cvar label=\"curl_filename\" translate=\"no\"\u003eFilename\u003c/var\u003e to read from a file.\n\nExample: Make a `TRANSFORM_AND_RETURN_REQUEST` request\n\nBefore making a request, complete the following steps:\n\n- Ensure you have [Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc) configured as described in [Use OAuth](/maps/documentation/route-optimization/oauth-token).\n- Set \u003cvar label=\"project_number\" translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e to your Cloud\n project number or ID.\n\n The following command sends an `OptimizeToursRequest` to the\n Route Optimization API which returns an `OptimizeToursResponse` with the\n [`ProcessedRequest`](/maps/tt/route-optimization/experimental/objectives/reference/rpc/google.maps.routeoptimization.v1#optimizetoursresponse) field set. \n\n ```carbon\n curl -X POST 'https://routeoptimization.googleapis.com/v1/projects/\u003cvar label=\"project_number\" translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e:optimizeTours' \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n --data @- \u003c\u003cEOM\n {\n \"model\": {\n \"shipments\": [\n {\n \"pickups\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.42506261000996,\n \"longitude\": -122.09535511930135\n }\n }\n ],\n \"deliveries\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.42421503206021,\n \"longitude\": -122.09526063135228\n }\n }\n ]\n }\n ],\n \"vehicles\": [\n {\n \"travelMode\": \"DRIVING\",\n }\n ],\n \"objectives\": [\n {\n \"type\": \"MIN_TRAVEL_TIME\"\n }\n ]\n },\n \"solvingMode\": \"TRANSFORM_AND_RETURN_REQUEST\"\n }\n EOM\n ```\n The previous command will produce a similar response to the following. \n\n ```\n {\n \"processedRequest\": {\n \"model\": {\n \"shipments\": [\n {\n \"pickups\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.425062610009959,\n \"longitude\": -122.09535511930135\n }\n }\n ],\n \"deliveries\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.424215032060211,\n \"longitude\": -122.09526063135228\n }\n }\n ]\n }\n ],\n \"vehicles\": [\n {\n \"travelMode\": \"DRIVING\",\n \"costPerHour\": 30,\n \"costPerTraveledHour\": 330,\n \"costPerKilometer\": 0.2\n }\n ],\n \"objectives\": [\n {\n \"type\": \"MIN_TRAVEL_TIME\"\n }\n ]\n },\n \"solvingMode\": \"TRANSFORM_AND_RETURN_REQUEST\"\n }\n }\n ```\n | **Note:** This example uses the `--data @-` to read a request from standard input. Use `--data @`\u003cvar label=\"curl_filename\" translate=\"no\"\u003eFilename\u003c/var\u003e to read from a file."]]