English 中文(简体)
共同财产法
原标题:JSprit penalize extra shipment minutes in vehicle

我正在安排客运/游离路线。

Multiple passengers in a vehicle is good!

乘客在车上的额外时间是坏的。

如果博博博爱的生活接近尾声,艾丽斯的生活远未消失,理想的情况是,我们将拿到艾丽斯,然后将博博拉带走。 共同财产似乎对此有内在限制。

Essentially, I want a soft constraint for passenger extra minutes in vehicle, above the straight-shot drive time from pickup to dropoff. I think a simple penalty for overall time in vehicle would work all right instead of calculating the extra. Any thoughts about how to structure this constraint in JSprit? Is it a soft version of MaxTimeInVehicleConstraint?

问题回答

我通过使用<代码>J Sprit.setObjectiveFunction()而不是习惯限制来解决这一问题。 执行起来要简单得多。

public double getCosts( VehicleRoutingProblemSolution solution ) {
    double costPerPassengerSecond = 0.001;
    double costs = 0.0;
    int passengersInVehicle = 0;
    for ( VehicleRoute route : solution.getRoutes() ) {
        costs += route.getVehicle().getType().getVehicleCostParams().fix;
        TourActivity prevAct = route.getStart();

        for ( TourActivity act : route.getActivities() ) {
            costs += vrp.getTransportCosts().getTransportCost(prevAct.getLocation(), act.getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
            //costs += vrp.getActivityCosts().getActivityCost(act, act.getArrTime(), route.getDriver(), route.getVehicle()); // there are no activity costs, because CostPerServiceTime is zero
            costs += costPerPassengerSecond * passengersInVehicle * vrp.getTransportCosts().getTransportTime(prevAct.getLocation(), act.getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
            passengersInVehicle += act.getSize().get(0);
        }


        costs += vrp.getTransportCosts().getTransportCost(prevAct.getLocation(), route.getEnd().getLocation(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
        //if ( route.getVehicle().getBreak() != null && !hasBreak && route.getEnd().getArrTime() > route.getVehicle().getBreak().getTimeWindow().getEnd() ) {
        //  costs += 4.0 * (maxCosts * 2.0 + route.getVehicle().getBreak().getServiceDuration() * route.getVehicle().getType().getVehicleCostParams().perServiceTimeUnit);
        //}

    }
    return costs;
}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签