یک پیام درخواست بسازید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
توسعه دهندگان منطقه اقتصادی اروپا (EEA). همانطور که به طور خلاصه در بررسی اجمالی بهینه سازی مسیر توضیح داده شد، یک درخواست اساسی شامل مدل ، محموله ها و وسایل نقلیه به عنوان موجودیت های مورد نیاز است:
- مدل تنظیمات و محدودیتها را برای کل درخواست، شامل
Shipments
و Vehicles
، ثبت میکند. - محموله ها وظایف یا محموله های واقعی را نشان می دهند که شامل تحویل و تحویل
VisitRequest
می شود. محموله ها دارای تنظیمات و محدودیت های محلی هستند. - وسایل نقلیه نشان دهنده وسایل نقلیه، رانندگان یا پرسنل هستند. وسایل نقلیه همچنین دارای تنظیمات و محدودیت های محلی هستند.
ویژگی های هر موجودیت بخشی از یک مسئله بهینه سازی را در سطح خاصی از دانه بندی توصیف می کند. محدودیتهای گسترده مدل برای همه محمولهها و وسایل نقلیه اعمال میشود، در حالی که محدودیتها و ویژگیهای مشخص شده در محمولهها یا وسایل نقلیه مختص یک محموله یا وسیله نقلیه است.
برای مستندات کامل در مورد هر نوع پیام، به مستندات مرجع برای پیامهای ShipmentModel
( REST ، gRPC )، Shipment
( REST ، gRPC ) و Vehicle
( REST ، gRPC ) مراجعه کنید.
ویژگی OptimizeToursRequest
برخی از ویژگیهای رایج مورد استفاده پیام سطح بالای OptimizeToursRequest
( REST ، gRPC ) شامل موارد زیر است:
-
searchMode
نشان میدهد که آیا باید اولین راهحلی را که محدودیتهای مشخص شده را برآورده میکند بازگردانید یا بهترین راهحل ممکن را در یک مهلت تعیینشده پیدا کنید. -
considerRoadTraffic
تعیین می کند که آیا از ترافیک زنده برای مسیریابی و تخمین ETA استفاده می شود یا خیر. -
populateTransitionPolylines
تعیین می کند که آیا چند خطوط مسیر و نشانه های مسیر در پاسخ برگردانده می شوند یا خیر.
خواص مدل
برخی از ویژگی های رایج پیام ShipmentModel
( REST ، gRPC ) عبارتند از:
-
globalStartTime
نشان دهنده اولین زمان شروع مسیرها در همه وسایل نقلیه و محموله ها است. هیچ وسیله نقلیه ای نمی تواند اولین انتقال و حمل و نقل خود را قبل از این زمان آغاز کند. -
globalEndTime
آخرین زمان پایان مسیرها در همه وسایل نقلیه و محموله ها را نشان می دهد. همه محمولهها و انتقالها باید قبل از این زمان کامل شوند.
خواص حمل و نقل
برخی از ویژگی های رایج پیام Shipment
( REST ، gRPC ) عبارتند از:
-
pickups[]
و deliveries[]
نشاندهنده محل تحویل یا تحویل محموله است. ویژگیهای pickups[]
و deliveries[]
هر دو از پیام VisitRequest
( REST ، gRPC ) استفاده میکنند. -
loadDemands
نشان دهنده بار مورد نیاز برای یک وسیله نقلیه برای تکمیل یک محموله است. ویژگی load_limits
مربوط به وسایل نقلیه ( REST ، gRPC ) نشان دهنده مقدار باری است که یک وسیله نقلیه می تواند در یک زمان تحمل کند. درباره بار در تقاضاها و محدودیتهای بار بیشتر بخوانید. -
penalty_cost
هزینه ای را نشان می دهد که در صورت نادیده گرفتن محموله انجام می شود. در مورد هزینه ها در پارامترهای مدل هزینه بیشتر بخوانید.
خواص خودرو
برخی از ویژگی های رایج پیام Vehicle
( REST ، gRPC ) عبارتند از:
-
startLocation
نشان دهنده جایی است که یک وسیله نقلیه باید مسیر خود را شروع کند. این ویژگی اختیاری است. اگر مشخص نشده باشد، مسیر وسیله نقلیه از محل اولین محموله تعیین شده شروع می شود. -
endLocation
نشان دهنده جایی است که یک وسیله نقلیه باید مسیر خود را پایان دهد. این ویژگی اختیاری است. اگر مشخص نشده باشد، مسیر وسیله نقلیه به محل آخرین محموله تعیین شده خاتمه می یابد. -
startTimeWindows[]
نشان دهنده زمانی است که وسیله نقلیه می تواند مسیر خود را شروع کند. این ویژگی اختیاری است. -
endTimeWindows[]
نشان دهنده زمانی است که یک وسیله نقلیه می تواند مسیر خود را شروع و پایان دهد. هر دو ویژگی اختیاری هستند. -
loadLimits
نشان دهنده ظرفیت وسیله نقلیه در دسترس برای پاسخگویی به نیازهای بار محموله ها است. در مورد تقاضاها و محدودیت های بار در مطالب و محدودیت های بار بیشتر بخوانید.
یک نمونه درخواست کامل در قالب JSON به نظر می رسد:
{
"model": {
"shipments": [
{
"pickups": [
{
"arrivalLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
}
}
],
"deliveries": [
{
"arrivalLocation": {
"latitude": 37.79581,
"longitude": -122.4218856
}
}
]
}
],
"vehicles": [
{
"startLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
},
"endLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
},
"costPerKilometer": 1.0
}
],
"globalStartTime": "2024-02-13T00:00:00.000Z",
"globalEndTime": "2024-02-14T06:00:00.000Z"
}
}
OptimizeTours
و BatchOptimizeTours
هر دو پیام های درخواست را مانند مثال بالا مصرف می کنند، اما به روش های مختلف. قبل از درخواست بهینه سازی مسیر، مهم است که تفاوت بین این دو روش را درک کنید:
مقایسه OptimizeTours و BatchOptimizeTours
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eRoute Optimization requests require defining a \u003ccode\u003eModel\u003c/code\u003e with \u003ccode\u003eShipments\u003c/code\u003e and \u003ccode\u003eVehicles\u003c/code\u003e to represent the optimization problem.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eModel\u003c/code\u003e sets global parameters, while \u003ccode\u003eShipments\u003c/code\u003e and \u003ccode\u003eVehicles\u003c/code\u003e have individual properties and constraints for pickups, deliveries, loads, and time windows.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeToursRequest\u003c/code\u003e allows controlling the search mode, traffic considerations, and response details.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeTours\u003c/code\u003e and \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e offer synchronous and asynchronous request processing, respectively, with key differences in handling large or complex scenarios.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify global start and end times for all vehicles and shipments within the \u003ccode\u003eShipmentModel\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Construct a request message\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nAs briefly described in [Route Optimization Overview](/maps/documentation/route-optimization/overview), a basic request\nconsists of **Model** , **Shipments** , and **Vehicles** as required entities:\n\n- **Model** captures settings and constraints for the entire request, inclusive of both `Shipments` and `Vehicles`.\n- **Shipments** represent tasks or actual shipments that include pickup and delivery `VisitRequest`s. Shipments have local settings and constraints.\n- **Vehicles** represent vehicles, drivers, or personnel. Vehicles also have local settings and constraints.\n\nEach entity's properties describe part of an optimization problem at a\nparticular level of granularity. Model-wide constraints are applied to all\nshipments and vehicles, while constraints and properties specified on shipments\nor vehicles are specific to a single shipment or vehicle.\n\nFor complete documentation on each message type, see the reference documentation\nfor `ShipmentModel` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.ShipmentModel)), `Shipment` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Shipment), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Shipment)),\nand `Vehicle` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Vehicle), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Vehicle)) messages.\n\n`OptimizeToursRequest` properties\n---------------------------------\n\nSome commonly used properties of the top-level `OptimizeToursRequest` message\n([REST](/maps/documentation/route-optimization/reference/rest/v1/projects/optimizeTours), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.OptimizeToursRequest)) include the following:\n\n- `searchMode` indicates whether to return the first solution that satisfies specified constraints or find the best possible solution within a set deadline.\n- `considerRoadTraffic` determines whether or not live traffic is used for routing and ETA estimation.\n- `populateTransitionPolylines` determines whether or not route polylines and route tokens are returned in the response.\n\nModel properties\n----------------\n\nSome commonly used properties of the `ShipmentModel` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel),\n[gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.ShipmentModel)) include:\n\n- `globalStartTime` represents the earliest start time of routes across all vehicles and shipments. No vehicle may start its first transitions and shipments before this time.\n- `globalEndTime` represents the latest end time of routes across all vehicles and shipments. All assigned shipments and transitions must be complete before this time.\n\nShipment properties\n-------------------\n\nSome commonly used properties of the `Shipment` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Shipment), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Shipment))\ninclude:\n\n- `pickups[]` and `deliveries[]` represent where a shipment can be picked up or dropped off. `pickups[]` and `deliveries[]` properties both use the `VisitRequest` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#VisitRequest), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Shipment.VisitRequest)).\n- `loadDemands` represent the load required for a vehicle to complete a shipment. Vehicles' corresponding `load_limits` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Vehicle.FIELDS.load_limits), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Vehicle.FIELDS.repeated.google.maps.routeoptimization.v1.Vehicle.LoadLimitsEntry.google.maps.routeoptimization.v1.Vehicle.load_limits)) property represents how much load a vehicle can accommodate at one time. Read more about load in [Load Demands and Limits](/maps/documentation/route-optimization/load-demands-limits).\n- `penalty_cost` represents the cost incurred if a shipment is skipped. Read more on costs in [Cost Model Parameters](/maps/documentation/route-optimization/cost-model).\n\nVehicle properties\n------------------\n\nSome commonly used properties of the `Vehicle` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Vehicle), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Vehicle))\ninclude:\n\n- `startLocation` represents where a vehicle must start its route. This property is optional. If not specified, the vehicle's route starts at the location of its first assigned shipment.\n- `endLocation` represents where a vehicle must end its route. This property is optional. If not specified, the vehicle's route ends at the location of its last assigned shipment.\n- `startTimeWindows[]` represents when a vehicle can start its route. This property is optional.\n- `endTimeWindows[]` represents when a vehicle can start and end its route. Both properties are optional.\n- `loadLimits` represent the vehicle's capacity available to meet shipments' load demands. Read more about load demands and limits in [Load Demands and\n Limits](/maps/documentation/route-optimization/load-demands-limits).\n\nA complete example request in JSON format looks like: \n\n {\n \"model\": {\n \"shipments\": [\n {\n \"pickups\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.73881799999999,\n \"longitude\": -122.4161\n }\n }\n ],\n \"deliveries\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.79581,\n \"longitude\": -122.4218856\n }\n }\n ]\n }\n ],\n \"vehicles\": [\n {\n \"startLocation\": {\n \"latitude\": 37.73881799999999,\n \"longitude\": -122.4161\n },\n \"endLocation\": {\n \"latitude\": 37.73881799999999,\n \"longitude\": -122.4161\n },\n \"costPerKilometer\": 1.0\n }\n ],\n \"globalStartTime\": \"2024-02-13T00:00:00.000Z\",\n \"globalEndTime\": \"2024-02-14T06:00:00.000Z\"\n }\n }\n\n`OptimizeTours` and `BatchOptimizeTours` both consume request messages like the\nexample above, but in different ways. Before making a Route Optimization\nrequest, it's important to understand the difference between the two methods:\n\n[Comparing OptimizeTours and BatchOptimizeTours](/maps/documentation/route-optimization/sync-vs-async)"]]