gpt4 book ai didi

or-tools - SetGlobalSpanCoefficient 方法谷歌或工具

转载 作者:行者123 更新时间:2023-12-04 13:59:28 25 4
gpt4 key购买 nike

我正在尝试使用谷歌或工具解决车辆路线问题。
这是链接https://developers.google.com/optimization/routing/vrp .
我正在尝试使用 google 的代码,但是当我遇到这段代码时:

def add_distance_dimension(routing, distance_callback):
"""Add Global Span constraint"""
distance = 'Distance'
maximum_distance = 3000 # Maximum distance per vehicle.
routing.AddDimension(
distance_callback,
0, # null slack
maximum_distance,
True, # start cumul to zero
distance)
distance_dimension = routing.GetDimensionOrDie(distance)
# Try to minimize the max distance among vehicles.
distance_dimension.SetGlobalSpanCostCoefficient(100)

我不明白最后一个结构的含义
distance_dimension.SetGlobalSpanCostCoefficient(100)

这个函数的目的是什么,参数的含义是什么?为什么那里有一个“100”?

最佳答案

documentation ,自发布此问题以来很可能已经更新,阐明了 100 的含义:

The method SetGlobalSpanCostCoefficient sets a large coefficient (100) for the global span of the routes, which in this example is the maximum of the distances of the routes. This makes the global span the predominant factor in the objective function, so the program minimizes the length of the longest route.



一般来说(来自 API reference ),该方法

[sets] a cost proportional to the global dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).

关于or-tools - SetGlobalSpanCoefficient 方法谷歌或工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53487153/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com