How to group nearby stops to be visited sequentially using Google Route Optimization API? - Stack Overflow

I’m using the Google Route Optimization API to optimize 50 stops with one vehicle. I have around 10 poi

I’m using the Google Route Optimization API to optimize 50 stops with one vehicle. I have around 10 points within a 100m radius, but after optimization, they are not visited sequentially (refer to the image).

This is what my model looks like,

{
    "shipments": [
        {
            "pickups": [
                {
                    "arrival_location": {"latitude": 22.63253, "longitude": 88.21828},
                    "label": "A26731",
                    "tags": ["grp_tag"],
                }
            ]
        },
        # More stops here
    ],
    "vehicles": [
        {
            "label": "cluster2",
            "cost_per_kilometer": 10.0,
            "cost_per_hour": 10.0,
            "start_location": {"latitude": 22.62791, "longitude": 88.231},
        }
    ],
    "global_duration_cost_per_hour": 100,
    "global_start_time": datetime.datetime(2025, 1, 7, 7, 0),
    "global_end_time": datetime.datetime(2025, 1, 7, 23, 0),
    "transition_attributes": [
        {
            "excluded_dst_tag": "grp_tag",
            "excluded_src_tag": "grp_tag",
            "distance_limit": {
                "soft_max_meters": 200,
                "cost_per_kilometer_below_soft_max": 1,
                "cost_per_kilometer_above_soft_max": 5000,
            },
        }
    ],
}

I’ve tried using the transition attributes feature of Google RO but it doesn’t seem to work. What I want is the nearby stops to be visited sequentially, regardless of which side of the road the points are on.

I’m using the Google Route Optimization API to optimize 50 stops with one vehicle. I have around 10 points within a 100m radius, but after optimization, they are not visited sequentially (refer to the image).

This is what my model looks like,

{
    "shipments": [
        {
            "pickups": [
                {
                    "arrival_location": {"latitude": 22.63253, "longitude": 88.21828},
                    "label": "A26731",
                    "tags": ["grp_tag"],
                }
            ]
        },
        # More stops here
    ],
    "vehicles": [
        {
            "label": "cluster2",
            "cost_per_kilometer": 10.0,
            "cost_per_hour": 10.0,
            "start_location": {"latitude": 22.62791, "longitude": 88.231},
        }
    ],
    "global_duration_cost_per_hour": 100,
    "global_start_time": datetime.datetime(2025, 1, 7, 7, 0),
    "global_end_time": datetime.datetime(2025, 1, 7, 23, 0),
    "transition_attributes": [
        {
            "excluded_dst_tag": "grp_tag",
            "excluded_src_tag": "grp_tag",
            "distance_limit": {
                "soft_max_meters": 200,
                "cost_per_kilometer_below_soft_max": 1,
                "cost_per_kilometer_above_soft_max": 5000,
            },
        }
    ],
}

I’ve tried using the transition attributes feature of Google RO but it doesn’t seem to work. What I want is the nearby stops to be visited sequentially, regardless of which side of the road the points are on.

Share Improve this question edited Mar 24 at 9:34 Anonymous 1841 gold badge1 silver badge5 bronze badges asked Mar 20 at 11:46 Darsh PatelDarsh Patel 431 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4

You need to flip the transition_attributes costs; ideally setting the "above soft max" to 0 and "below soft max" to a non-negligible value (100 is plenty enough). That should cluster nearby visits together.

"transition_attributes": [
        {
            "excluded_dst_tag": "%$@#",
            "excluded_src_tag": "%$@#",
            "distance_limit": {
                "soft_max_meters": 200,
                "cost_per_kilometer_below_soft_max": 100,
            },
        }
    ],

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744412377a4572945.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信