旅行推销员(TSP)跳过城市

时间:2012-08-08 14:42:43

标签: mathematical-optimization

我想解决类似于旅行销售人员问题的问题但是在这种情况下,如果访问城市的成本太高,销售人员可以跳过城市。

请指点我如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

一种方法是复制/粘贴this vehicle routing exampleDrools Planner并将其破解为:

有2辆车:1辆真实车辆(=巡回赛)和1辆未使用的车辆(=非使用过的城市)。 客户==城市。删除容量规则。

然后,更改分数规则,使其仅计算二手车(而非未使用车辆)的城市(=客户)的距离:

rule "distanceToPreviousAppearance"
    when
        $customer : VrpCustomer(previousAppearance != null, $distanceToPreviousAppearance : distanceToPreviousAppearance, vehicleIsUsed == true)
    then
        insertLogical(new IntConstraintOccurrence("distanceToPreviousAppearance", ConstraintType.NEGATIVE_SOFT,
                $distanceToPreviousAppearance,
                $customer));
end

rule "distanceFromLastCustomerToDepot"
    when
        $customer : VrpCustomer(previousAppearance != null, vehicleIsUsed == true)
        not VrpCustomer(previousAppearance == $customer)
    then
        VrpVehicle vehicle = $customer.getVehicle();
        insertLogical(new IntConstraintOccurrence("distanceFromLastCustomerToDepot", ConstraintType.NEGATIVE_SOFT,
                $customer.getDistanceTo(vehicle),
                $customer));
end

同样,您可以添加一个规则,该规则将使用过的车辆访问过的每个城市的访问奖金相加,并尝试使用ConstraintType.POSITIVE_SOFT(加权与行驶距离)进行最大化。

当然,你不应该像这样破解它:这只是要点。而是根据您的要求重命名和重新设计它。