एक बार में कई विकल्पों को ऑप्टिमाइज़ करने वाले एपीआई के तरीके
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस गाइड में, OptimizeToursLongRunning और OptimizeToursUri एपीआई के तरीकों को एक्सपेरिमेंट के तौर पर लॉन्च करने के बारे में बताया गया है. इनकी मदद से उपयोगकर्ता, एक बार में ऑप्टिमाइज़ेशन के ऐसे अनुरोध कर सकते हैं जिनमें कोई रुकावट न आए. नॉन-ब्लॉकिंग ऑप्टिमाइज़ेशन में, उपयोगकर्ता को उस तरीके से तुरंत एक Operation proto मिलता है जिसका इस्तेमाल GetOperation को कॉल करके, ऑप्टिमाइज़ेशन की स्थिति को रेफ़रंस करने के लिए किया जा सकता है.
ज़्यादा जानकारी के लिए, लंबे समय तक चलने वाले ऑपरेशन देखें.
ये नॉन-ब्लॉकिंग तरीके, ब्लॉकिंग OptimizeTours तरीके की तुलना में ज़्यादा भरोसेमंद होते हैं. ऐसा इसलिए, क्योंकि ऑप्टिमाइज़ेशन के दौरान क्लाइंट को सर्वर से कनेक्शन बनाए रखने की ज़रूरत नहीं होती. साथ ही, इन नए तरीकों से BatchOptimizeTours की तुलना में, गड़बड़ियों को डीबग करना आसान हो जाता है. ऐसा इसलिए, क्योंकि हर ऑप्टिमाइज़ेशन एक ही लंबे समय तक चलने वाली कार्रवाई (एलआरओ) से जुड़ा होता है.
जिन उपयोगकर्ताओं को ऑप्टिमाइज़ेशन के अनुरोध को इनलाइन करना है वे OptimizeToursLongRunning तरीके का इस्तेमाल कर सकते हैं. वहीं, जिन उपयोगकर्ताओं को Google Cloud Storage का इस्तेमाल करके अनुरोधों को अपलोड करना है और जवाब पढ़ना है वे OptimizeToursUri तरीके का इस्तेमाल कर सकते हैं.
OptimizeToursLongRunning
उदाहरण: OptimizeToursLongRunning का अनुरोध करना
अनुरोध करने से पहले, यहां दिए गए पैरामीटर को अपने एनवायरमेंट के हिसाब से सही वैल्यू से बदलें:
PROJECT_NUMBER_OR_ID को अपने Cloud प्रोजेक्ट नंबर या आईडी पर सेट करें.
नीचे दी गई कमांड, Route Optimization API को OptimizeToursLongRunning अनुरोध भेजती है. साथ ही, इससे जुड़ा ऑपरेशन आईडी मिलता है. GetOperation तरीके का इस्तेमाल, ऑपरेशन के स्टेटस के बारे में क्वेरी करने के लिए किया जा सकता है.
ऑपरेशन पूरा होने के बाद, मेटाडेटा में फ़ाइनल OptimizeToursResponse भी शामिल होता है.
BatchOptimizeTours की तरह, OptimizeToursUri का इस्तेमाल करके, Google Cloud Storage पर ऑप्टिमाइज़ेशन के अनुरोध और जवाब को सेव किया जा सकता है.
Cloud Storage यूआरआई को OptimizeToursUri अनुरोध मैसेज में शामिल करना ज़रूरी है.
Operation के तौर पर दिखाया गया स्टेटस, सिर्फ़ सबमिट किए गए एक OptimizeToursRequest से जुड़ा होता है.
उदाहरण: OptimizeToursUri का अनुरोध करना
अनुरोध करने से पहले, यहां दिए गए पैरामीटर को अपने एनवायरमेंट के हिसाब से सही वैल्यू से बदलें:
PROJECT_NUMBER_OR_ID को अपने Cloud प्रोजेक्ट नंबर या आईडी पर सेट करें.
नीचे दी गई कमांड, Route Optimization API को OptimizeToursUri अनुरोध भेजती है. साथ ही, इससे जुड़ा ऑपरेशन आईडी मिलता है. कार्रवाई की स्थिति के बारे में क्वेरी करने के लिए, GetOperation तरीके का इस्तेमाल करें.
ऑपरेशन पूरा होने के बाद, OptimizeToursResponse को अनुरोध में दिए गए आउटपुट यूआरआई पाथ पर रिमोटली सेव किया जाता है.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-09-04 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThis guide introduces \u003ccode\u003eOptimizeToursLongRunning\u003c/code\u003e and \u003ccode\u003eOptimizeToursUri\u003c/code\u003e, new methods that enhance reliability and optionally remove the dependency on Google Cloud Storage compared to \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeToursLongRunning\u003c/code\u003e allows for inline optimization requests without requiring Google Cloud Storage and each request is tracked by its own individual LRO.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeToursUri\u003c/code\u003e offers the option to continue using Google Cloud Storage for request and response storage, with the benefit of each request having its own LRO.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e method, while still supported, requires all requests and responses to be stored on Google Cloud Storage and only provides one LRO for all the requests.\u003c/p\u003e\n"]]],[],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\nThis guide introduces the experimental launch of the [`OptimizeToursLongRunning`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.OptimizeToursLongRunning)\nand [`OptimizeToursUri`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.OptimizeToursUri) API methods that allow users to make single\nnon-blocking optimization requests. In a non-blocking optimization, the user\nquickly receives a Operation proto from the method that can be used\nto reference the status of the optimization by calling [`GetOperation`](/maps/documentation/route-optimization/reference/rpc/google.longrunning#google.longrunning.Operations.GetOperation).\nSee [Long Running Operations](https://developers.google.com/maps/documentation/route-optimization/sync-vs-async#long_running_operations)\nfor more details.\n\nThese non-blocking methods provide the\nreliability benefits over the blocking [`OptimizeTours`](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.OptimizeTours) method since the\nclient does not need to maintain connection to the server while the optimization\nis being executed. Also, these new methods make it easier to debug\nfailures compared to [`BatchOptimizeTours`](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.BatchOptimizeTours) since each optimization is\nassociated with a single Long-Running Operation (LRO).\n\nUsers who prefer to inline the optimization request can use the\n[`OptimizeToursLongRunning`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.OptimizeToursLongRunning) method while users who prefer to upload the\nrequests and the read response using Google Cloud Storage can use the\n[`OptimizeToursUri`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.OptimizeToursUri) method.\n\nOptimizeToursLongRunning\n\nExample: Make an `OptimizeToursLongRunning` request\n\nBefore making a request, replace the following parameters with values\nappropriate for your environment:\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 `OptimizeToursLongRunning` request to the\n Route Optimization API and receives an operation ID associated with it. The\n [`GetOperation`](/maps/documentation/route-optimization/reference/rpc/google.longrunning#google.longrunning.Operations.GetOperation) method can be used to query the status of the operation.\n Once the operation completes, the metadata also contains the final\n [`OptimizeToursResponse`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#optimizetoursresponse). \n\n ```scdoc\n curl -X POST 'https://routeoptimization.googleapis.com/v1/projects/PROJECT_NUMBER_OR_ID:optimizeToursLongRunning' \\\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 \"costPerKilometer\": 1.0\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\nOptimizeToursUri\n\nLike `BatchOptimizeTours`, you can use [`OptimizeToursUri`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.RouteOptimization.OptimizeToursUri) to continue\nstoring your optimization request and response on Google Cloud Storage.\nCloud Storage URIs must be specified in the `OptimizeToursUri` request message.\nThe `Operation` status returned is associated only with the single submitted\n`OptimizeToursRequest`.\n\nExample: Make an `OptimizeToursUri` request\n\nBefore making a request, replace the following parameters with values\nappropriate for your environment:\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 `OptimizeToursUri` request to the\n Route Optimization API and receives an operation ID associated with it. Use\n the [`GetOperation`](/maps/documentation/route-optimization/reference/rpc/google.longrunning#google.longrunning.Operations.GetOperation) method to query the status of the operation.\n Once the operation completes, the [`OptimizeToursResponse`](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.maps.routeoptimization.v1#optimizetoursresponse) is stored\n remotely on the output URI path provided in the request. \n\n ```scdoc\n curl -X POST 'https://routeoptimization.googleapis.com/v1/projects/PROJECT_NUMBER_OR_ID:optimizeToursUri' \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n --data @- \u003c\u003cEOM\n {\n \"input\": {\n \"uri\": \"gs://bucket/path/input/object.json\"\n },\n \"output\": {\n \"uri\": \"gs://bucket/path/output/object.json\"\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."]]