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
How to implement a multiobjective TSP? #142
Comments
|
Hi David, thank for responding so quickly on my three questions! About Q1: How can I minimise the carbon objective by referring to the matrix given above?I still have trouble obtaining a result. Here is my code:
And I get this error message:
About Q3: How would you propose to implement a multiobjective TSP in Platypus?Thanks for the recommendation on the 2-opt operator, will try it out definitely. But I was more asking on how write the multiobjective TSP in Platypus. I am not a very experienced programmer as you can probably tell. Therefore, I would be very thankful if you could give me some inspiration by providing a rough outline on how to setup the code for a multiobjective TSP in Platypus. I have another matrix with the traveling times between the 6 exemplary cities. I suppose I need to write another function which calculates the total traveling time for a given tour. The
Am I thinking in the right direction here? In the documentation I didn't find much about implementing multiple objective functions unfortunately. |
and just set
|
Hi David, thanks for all the help so far! I managed to implement the multiobjective function. Now, I am trying to use local search operators like two_opt which you recommended. I guess having to rely only on random permutatations is not quite efficient. I have implemented the two_opt function in the normal TSP first. It works for me but it's taking quite some time to complete the function evaluations. Could you please take a look and tell me what could be improved?
Also, I was wondering: Did you ever achieve to get the optimal route for PR76 with Platypus? Thanks again |
This is the version of 2-opt that I wrote in Java - https://github.com/MOEAFramework/MOEAFramework/blob/master/examples/org/moeaframework/examples/ga/tsplib/TSP2OptHeuristic.java. It's been a few years since I wrote that so I forget the details, but one difference I see is that you don't need to compute the full route each time, you can just compute the distance between the four cities (i, i+1, j, j+1). I don't think I've ever seen the optimal result for PR76 without 2-opt, but that's not surprising. There are 76! = 1.88 x 10^111 different permutations. Without some local search, it's really, really hard to find the optimum. With 2-opt, you can find the optimum in 10-20 iterations. The MOEAFramework, the Java library I wrote that Platypus is based on, has all this implemented. |
Adding to ☝️ , it also can plot the search, showing the best route found so far (red), and the current population (gray lines) - http://moeaframework.org/images/screenshot-5.png |
Hi David, I implemented your version of two_opt which really seems to work better. Now, I have some problem with the distance matrix which is needed for the two_opt operator. The
Error:
The code runs fine when I feed the function a predefined route tough. Where is this error coming from? Thanks again for the help! |
Have it return |
It works, thanks! The two_opt is quite fast and is getting me good results. But the
I get a result like this: When I plug this route into the |
This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR. |
Hi everyone,
This question is a rather long one. It is referring to this example code: https://github.com/Project-Platypus/Platypus/blob/master/examples/tsp.py
I am working on a multiobjective TSP model where the salesman can choose between bus or flight to go from city i to j. The two conflicting objectives are to minimise travelling time and carbon emissions. This would be applicable to a tourist doing a citytrip, the tourist has the choice whether to go by plane (fast but carbon intensive) or by bus (slow but green).
I created my own "distance matrices" for carbon emissions and traveling time for 6 cities. This dataset I would like to feed the NSGA-II algorithm to find out the non-dominated solutions. Below is just the carbon emission matrix:
I tried writing my emissions function based on the tsp()-function from the example code (https://github.com/Project-Platypus/Platypus/blob/master/examples/tsp.py):
I tried to feed this function into the solver but failed to get a reasonable solution:
Questions:
tour=x[0]
which I have taken from the tsp()-function. Is this referring to the decision variable x_ij?Thanks in advance
Kevin
For more information on my model you can refer to my question in OR-Stackexchange: https://or.stackexchange.com/q/3933/3385
The text was updated successfully, but these errors were encountered: