Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Цели — это параметры, которые заранее определяют общие цели оптимизации, такие как кратчайшее расстояние или продолжительность поездки, своевременная доставка, распределение нагрузки между водителями. Это упрощает разработчикам освоение API оптимизации маршрутов до изучения тонкостей и полной настройки параметров стоимости. (См. раздел « cost model », чтобы узнать, как полностью настроить широкий спектр целей).
При установке ShipmentModel.objectives полностью перезаписывают модель стоимости, поэтому они несовместимы с уже существующими затратами. Каждая Objective соответствует ряду предопределенных затрат на транспортные средства, поставки или атрибуты перехода.
При указании режима решения TRANSFORM_AND_RETURN_REQUEST запрос не решается, а только проверяется и заполняется стоимостью, соответствующей заданным целям. Изменённый запрос возвращается как OptimizeToursResponse.processed_request . Все остальные режимы решения возвращают решённый запрос.
Режим решения TRANSFORM_AND_RETURN_REQUEST действителен только для запросов OptimizeTours и недоступен для других запросов API оптимизации маршрутов.
Пример: сделайте запрос ShipmentModel.objectives
Перед подачей запроса выполните следующие действия:
Задайте PROJECT_NUMBER_OR_ID в качестве номера или идентификатора вашего облачного проекта.
Следующая команда отправляет OptimizeToursRequest в API оптимизации маршрута, который возвращает OptimizeToursResponse с установленным полем ProcessedRequest .
[null,null,["Последнее обновление: 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."]]