【问题标题】:How to set minimum locations per route in Google OR-Tools?如何在 Google OR-Tools 中设置每条路线的最小位置?
【发布时间】:2021-04-29 00:32:00
【问题描述】:

我正在尝试限制每辆车访问的最小位置,我已成功实施最大位置约束,但在确定最小位置时遇到问题。我的最大位置代码:

def counter_callback(from_index):
    """Returns 1 for any locations except depot."""
    # Convert from routing variable Index to user NodeIndex.
    from_node = manager.IndexToNode(from_index)
    return 1 if (from_node != 0) else 0;

counter_callback_index = routing.RegisterUnaryTransitCallback(counter_callback)

routing.AddDimensionWithVehicleCapacity(
    counter_callback_index,
    0,  # null slack
    [16,16,16],  # maximum locations per vehicle
    True,  # start cumul to zero
    'Counter')

【问题讨论】:

    标签: python constraint-programming or-tools vehicle-routing


    【解决方案1】:

    您不应该对节点数量进行硬性限制,因为这很容易使模型不可行。

    推荐的方法是创建一个只计算访问次数的新维度(评估器总是返回 1),然后在每辆车的末尾对该维度的累积量推一个软下限。

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      • 1970-01-01
      • 2020-04-13
      • 2020-09-09
      • 2020-12-31
      • 1970-01-01
      相关资源
      最近更新 更多