google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
11.27k stars 2.13k forks source link

Vehicle Routing Problem Issue #1552

Closed sanke-t closed 5 years ago

sanke-t commented 5 years ago

I am running Vehicle Routing Problem in Java for a 4*4 distance matrix using https://developers.google.com/optimization/routing/vrp#entire_program1 and getting solution as null. Please help.

Distance Matrix

{{0,1754,2834,3301}, {1690,0,1588,1555}, {2314,1987,0,1366}, {3206,1940,1922,0}}

Below is the DataModel class I have changed from the one in the URL

static class DataModel { public final long[][] distanceMatrix = { {0,1754,2834,3301}, {1690,0,1588,1555}, {2314,1987,0,1366}, {3206,1940,1922,0} }; public final int vehicleNumber = 4; public final int depot = 0; }

paultrow commented 5 years ago

I typed your distance matrix into the original example (not copy and paste) and I get

Route for vehicle 0: 0 -> 3 -> 1 -> 0 Distance of the route: 1552m

Route for vehicle 1: 0 -> 0 Distance of the route: 0m

Route for vehicle 2: 0 -> 0 Distance of the route: 0m

Route for vehicle 3: 0 -> 2 -> 0 Distance of the route: 1552m

Could there be a hidden character in your file?

On Fri, Sep 6, 2019 at 9:53 AM sanke-t notifications@github.com wrote:

I am running Vehicle Routing Problem in Java for a 4*4 distance matrix using https://developers.google.com/optimization/routing/vrp#entire_program1 and getting solution as null. Please help.

Distance Matrix

{{0,1754,2834,3301}, {1690,0,1588,1555}, {2314,1987,0,1366}, {3206,1940,1922,0}}

Below is the DataModel class I have changed from the one in the URL

static class DataModel { public final long[][] distanceMatrix = { {0,1754,2834,3301}, {1690,0,1588,1555}, {2314,1987,0,1366}, {3206,1940,1922,0} }; public final int vehicleNumber = 4; public final int depot = 0; }

— 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/1552?email_source=notifications&email_token=AEC63UO43HWH2K54Z3PSW6LQIJOEXA5CNFSM4IUJIQWKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJZ77WA, or mute the thread https://github.com/notifications/unsubscribe-auth/AEC63UJAEFZZZJS3DJJ67RTQIJOEXANCNFSM4IUJIQWA .

sanke-t commented 5 years ago

I typed your distance matrix into the original example (not copy and paste) and I get Route for vehicle 0: 0 -> 3 -> 1 -> 0 Distance of the route: 1552m Route for vehicle 1: 0 -> 0 Distance of the route: 0m Route for vehicle 2: 0 -> 0 Distance of the route: 0m Route for vehicle 3: 0 -> 2 -> 0 Distance of the route: 1552m Could there be a hidden character in your file? On Fri, Sep 6, 2019 at 9:53 AM sanke-t @.**> wrote: I am running Vehicle Routing Problem in Java for a 44 distance matrix using https://developers.google.com/optimization/routing/vrp#entire_program1 and getting solution as null. Please help. Distance Matrix {{0,1754,2834,3301}, {1690,0,1588,1555}, {2314,1987,0,1366}, {3206,1940,1922,0}} Below is the DataModel class I have changed from the one in the URL static class DataModel { public final long[][] distanceMatrix = { {0,1754,2834,3301}, {1690,0,1588,1555}, {2314,1987,0,1366}, {3206,1940,1922,0} }; public final int vehicleNumber = 4; public final int depot = 0; } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1552?email_source=notifications&email_token=AEC63UO43HWH2K54Z3PSW6LQIJOEXA5CNFSM4IUJIQWKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJZ77WA>, or mute the thread https://github.com/notifications/unsubscribe-auth/AEC63UJAEFZZZJS3DJJ67RTQIJOEXANCNFSM4IUJIQWA .

I had kept capacity same as the one in the example. When I changed it to sum of entries in the matrix, it worked fine. Suppose that was the issue.

Link to documentation for anyone else who might face this issue- https://developers.google.com/optimization/routing/dimensions