Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Cele to parametry, które wstępnie definiują typowe cele optymalizacji, takie jak najkrótsza odległość lub czas podróży, dostawy na czas czy równoważenie obciążenia między kierowcami. Ma to ułatwić deweloperom rozpoczęcie korzystania z interfejsu Route Optimization API przed poznaniem zaawansowanych funkcji i pełnej możliwości dostosowywania parametrów kosztów. (Więcej informacji o pełnym dostosowywaniu różnych celów znajdziesz w sekcji „cost model”).
Gdy są ustawione, ShipmentModel.objectives całkowicie zastępują model kosztów, dlatego są niezgodne z wcześniej ustalonymi kosztami. Każda z nich
Objective odnosi się do liczby wstępnie zdefiniowanych kosztów pojazdów, przesyłek lub atrybutów przejścia.
Jeśli określisz tryb rozwiązywania TRANSFORM_AND_RETURN_REQUEST, żądanie nie zostanie rozwiązane, a jedynie zweryfikowane i wypełnione kosztami
odpowiadającymi podanym celom. Zmodyfikowane żądanie jest zwracane jako OptimizeToursResponse.processed_request. W przypadku wszystkich pozostałych trybów rozwiązywania zwracana jest rozwiązana prośba.
Tryb rozwiązywania TRANSFORM_AND_RETURN_REQUEST jest prawidłowy tylko w przypadku żądań OptimizeTours i nie jest dostępny w przypadku innych żądań interfejsu Route Optimization API.
Ustaw PROJECT_NUMBER_OR_ID na numer lub identyfikator projektu Cloud.
To polecenie wysyła żądanie OptimizeToursRequest do interfejsu Route Optimization API, który zwraca odpowiedź OptimizeToursResponse z ustawionym polem ProcessedRequest.
[null,null,["Ostatnia aktualizacja: 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."]]