Closed EvilDonkey closed 4 years ago
In the time matrix, just set all the entries in the columns corresponding to end nodes to 0.
On Sat, Apr 4, 2020 at 10:50 AM EvilDonkey notifications@github.com wrote:
Hey,
I have made a VRPTW that does from start to ends, within a timeframe. That part works just fine. However, I want to exclude ends from overall cost, yet still have routes that goes towards them.
My problem: Total time availabe 6000 START -> A -> B-> C -> END 0 -> 2000 -> 2000 -> 2000
C is dropped due to END taking up 2000. Any help would be much appriciated :)
` RoutingIndexManager routingIndexManager = new RoutingIndexManager( dataModel.TimeMatrix.GetLength(0), dataModel.VehicleNumber, dataModel.Starts, dataModel.Ends);
RoutingModel routingModel = new RoutingModel(routingIndexManager); int transitCallbackIndex = routingModel.RegisterTransitCallback( (long fromIndex, long toIndex) => { // Convert from routing variable Index to distance matrix NodeIndex. var fromNode = routingIndexManager.IndexToNode(fromIndex); var toNode = routingIndexManager.IndexToNode(toIndex); return dataModel.TimeMatrix[fromNode, toNode]; } ); routingModel.SetArcCostEvaluatorOfAllVehicles(transitCallbackIndex); routingModel.AddDimension( transitCallbackIndex, // transit callback 0, // allow waiting time dataModel.MaxWorkingTimeInSeconds,//6000, // vehicle maximum time capacities - Total worktime in seconds true, // start cumul to zero "Time");`
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/1947, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEC63ULYMKCMMWZGPLZRZV3RK5CJRANCNFSM4L6NMB2A .
Hey @paultrow thanks, but wont that result in them ending far away from the depot?
Are your starts and ends not the start and end nodes defined in the problem, as in this example?
On Sat, Apr 4, 2020 at 11:20 AM EvilDonkey notifications@github.com wrote:
Hey @paultrow https://github.com/paultrow thanks, but wont that result in them ending far away from the depot?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/1947#issuecomment-609044057, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEC63UML34AQXFAZ7UG7EV3RK5F3TANCNFSM4L6NMB2A .
No, my starts are all zeros while my ends have actual time in seconds. So you can say they are in reverse.
They all start at the depot, but end at their homes. I do not want the cost of driving from last parcel location to home to factor into the max working time in seconds, but still want the routes to go towards their home.
Actually your solution gave me an idea so I can control how long they have to their end location. Thanks :D
OK. I was just going to say that if you set starts = [0, 0, 0, 0] and ends = [1, 2, 15, 16], there will be four routes, each going from 0 to one of the four nodes in ends. So if you change your time matrix to have all entries in the columns for 1,2, 15, and 16 to be 0, the routes will still end at those four nodes, but the last step in each route will have 0 cost, so won't contribute to the total cost.
But I'm not sure exactly what you're trying to accomplish.
On Sat, Apr 4, 2020 at 12:13 PM EvilDonkey notifications@github.com wrote:
No, my starts are all zeros while my ends have actual time in seconds. So you can say they are in reverse.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/1947#issuecomment-609051563, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEC63ULSBA7W3OMBA6KCXILRK5MDTANCNFSM4L6NMB2A .
Pretty much what you wrote Paul, thanks :)
Hey,
I have made a VRPTW that does from start to ends, within a timeframe. That part works just fine. However, I want to exclude ends from overall cost, yet still have routes that goes towards them.
My problem: Total time availabe 6000 START -> A -> B-> C -> END 0 -> 2000 -> 2000 -> 2000
C is dropped due to END taking up 2000. Any help would be much appriciated :)
` RoutingIndexManager routingIndexManager = new RoutingIndexManager( dataModel.TimeMatrix.GetLength(0), dataModel.VehicleNumber, dataModel.Starts, dataModel.Ends);