Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About the performance #4

Closed
AlgorithmFan opened this issue Jan 21, 2018 · 2 comments
Closed

About the performance #4

AlgorithmFan opened this issue Jan 21, 2018 · 2 comments
Assignees
Labels

Comments

@AlgorithmFan
Copy link

AlgorithmFan commented Jan 21, 2018

Very thanks for your code. I'm very interested in applying genetic algorithm in vehicle route problem (VRP).

In the code, I turned this code for VRPTW into a general VRP problem by doing the following modifications:

  1. Calculate the distance matrix with Euclidean distance between any two coordinates.
    image

  2. Set the waitCost to zero, and the delayCost to zero.

  3. Remove the code related with dueTime as follows:
    line 28: updatedElapsedTime = elapsedTime + instance['distance_matrix'][lastCustomerID][customerID]
    line 30: if (updatedVehicleLoad <= vehicleCapacity):
    line 34: elapsedTime = updatedElapsedTime
    line 41: elapsedTime = instance['distance_matrix'][0][customerID]

At last, I get the results of routes:
Vehicle 1's route: 0 - 48 - 44 - 34 - 9 - 19 - 41 - 40 - 2 - 33 - 35 - 70 - 76 - 64 - 59 - 96 - 88 - 3 - 5 - 69 - 82 - 29 - 26 - 92 - 75 - 71 - 16 - 52 - 45 - 21 - 23 - 27 - 58 - 60 - 6 - 7 - 31 - 67 - 25 - 13 - 77 - 10 - 0
Vehicle 2's route: 0 - 54 - 24 - 94 - 18 - 50 - 53 - 56 - 38 - 14 - 81 - 79 - 63 - 61 - 73 - 66 - 86 - 55 - 20 - 100 - 8 - 95 - 89 - 22 - 74 - 4 - 90 - 91 - 12 - 85 - 93 - 65 - 87 - 49 - 72 - 84 - 39 - 47 - 0
Vehicle 3's route: 0 - 15 - 68 - 46 - 37 - 83 - 97 - 32 - 43 - 57 - 42 - 80 - 51 - 1 - 98 - 30 - 11 - 36 - 17 - 28 - 99 - 62 - 78 - 0

And I plot the route as follow. From the figure, we can observe the cost of generated routes is very expensive. I don't know what problems exist in the code. Can you provide some explanations for these problems.

figure_1

@AlgorithmFan
Copy link
Author

In my view, the cross over function might have some errors. Please reference the method of the deap libariry. https://github.com/DEAP/deap/blob/master/deap/tools/crossover.py

@iROCKBUNNY
Copy link
Contributor

@AlgorithmFan Thank you and your nice work. It looks like your results were not yet converged. The parameters of the GA have to be tuned to get the best results.

I implemented my own cross over function which in a certain case was suitable for my solution. You can try other cross over functions (either from the DEAP library or written by yourself) as well.

@iROCKBUNNY iROCKBUNNY self-assigned this Jan 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants