Topic: Ships optimization - project
einstein13 Topic Opener |
Posted at: 2015-08-14, 22:48
Last update 08-31-15Hi! After reading this thread, especially this post and next posts, I've decided to make special project where any ideas can be tested and compared in a proper way. Few words about projectMy project is written in python 2.7, for newer versions I have to test it first. How to run your own experiment? Very simple:
The goal for now is to make efficient and math-like algorithm for work of ships and ports in Widelands before build 20. What is included now?
Do you want to suggest something?Feel free to write it down here, on this thread. Now I am developing the code. It needs lots of work. Then you will be able to add any algorithm you want to test. I will edit this post to keep it up-to-date Edited: 2015-08-31, 19:58
einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 Topic Opener |
Posted at: 2015-08-14, 22:54
My current state of the project is more like simple test, plus some statistics. All are available in "full description mode":
First row is the command, second part is explanation of every statistic written in the bottom part. Middle part (PORTS & SHIPS) is explanation what ship and port algorithm is used for the test. If something is not understandable enough, please report it. Also If you want some other statistics, please write it down too. I will see if it is possible to implement in current model. einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-08-17, 19:09
I think this is what we are after - these should correspond to seafaring delivery time - I mean time from delivery a ware to starting port till delivery to destination port.... Have you implemented also another algorithms for ship movements? Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 Topic Opener |
Posted at: 2015-08-17, 23:10
Yes and no. For me better should be another statistics: "difference between existence time and traveling time => waiting time (ware at first port)" (can be done, because we know the ship speed). But all these times are test-dependent. For close ports everything is smaller. We can compare different methods with one test case, but not different results from different test cases. For me slightly better is travel efficiency. It is dependent on port placement (max value), but for more complex problems it is great factor. For example factor equal to 10 means that the ware was traveling 10 times longer than it was needed. I will improve the statistics in the future, but I hope current version is enough for the first sight
Not yet. Working currently. I've fixed few bugs to do that correctly. Now it is very, very easy Create new file in ships folder, create there a Ship class and override methods you want to change. After all in settings register your model (give the name of file) in correct list. Creating new file can be just copying the file ship_copy.py and rename it as you want I will start with your method for ships. Hope in one or two hours time I will have first results And to answer your old question: this project was easy-tested with python 3.x and it was working fine. Only different results were given. Don't know why. Maybe because random class has different implementation for python 3.x? (different test case -> different results). When I will finish unit tests, I will have the answer RESULTS FOR TIBOR's ALGORITHMGeneral results for test cases 1-3 are the same as for older algorithm. For test 4 (>>Rectangular test (4 ports: 2 pairs with long distance between, 2 ships, 300 wares)<<) are better! Congratulations Tibor! Mean journey efficiency is much better, mean journey distance is sligtly better. Utilization is lower - for me it is better efficiency (less wares need to transport). And no "ERRORS". It means that all your ships were going to the ports for reason. In older algorithm that happened twice.
EDIT one more timeI've added my patch for port (https://wl.widelands.org/forum/topic/1762/?page=5#post-14225) and run tests. There are slightly different results for last test case. The best are when mixing port patch and Tibor's algorithm. I can't answer one question: why the results are different? Probably there is at least one hidden bug... Edited: 2015-08-18, 01:19
einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-08-18, 20:52
You know, also small differences in algorithm can matter. Also number and layout of ports, number of ships and so on.. Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 Topic Opener |
Posted at: 2015-08-22, 00:40
Today I was adding my algorithm to the project. Also I've added more complicated test case (not symmetrical one) and I've noticed that there are some bugs inside. The project is not stable. I will try to fix it, but not today. I don't know when Sorry einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 Topic Opener |
Posted at: 2015-08-24, 00:08
Finally I've found the problem: Tibor's algorithm for finding new path. The problem was with finding best solution for next destination. When the distances were very long (you can think as a very big and complicated map), sometimes carrying the wares to distant ports is very inefficient. That produce "count" value beneath the zero and no maximum is found (Tibor assumed that the minimum is above zero). When I run the tests again, another issue was found. Here is an output (slightly modified):
First two outputs are about Tibor's ship algorithm with two algorithms for ports. In both cases simulation was interruped by time limits. My idea is that: full ship (30 wares) is going to the port where are many wares, AND all the wares are to other ports. Then the ship can go to other port where are many wares too and the situation is the same as before. The ship is going around two ports and nothing happens. I am not sure if it happens now, but I will try to fix it in some time in the future. So my conclusion is that Tibor's algorithm for ships needs some revision. I don't know if it is only python version, but C++ needs to be checked too. Another conclusion is that my simpliest patch to port algorithm (here is the link) is making some mess. For example mixing it with algorithm for ships is not a good idea (worse results!), but mixing it with basic ships algorithm is making very good results! In this test even better than my algorithm for ships! Mixing this algorithm with new algorithm for ships is not a good idea- it makes lots of problems and efficiency is lower. Maybe in the future I will find another, better algorithm, more suited for ships? EDIT:I've provided simple patch: if there is more than 80% of capacity for a ship, it doesn't go to other ports than those that are in ship's wares list. And to be more specific: plain Tibor's algorithm (without any other patch) is not the best approach for extreme cases (lots of wares at once + large distances). As I can imagine, most of cases where people are not happy with ships are those ones. Simple tests modifications shows that for most of cases current approach (very simple port & ship algorithms) are good enough. For more complicated and extreme cases modifications can be helpful. Edited: 2015-08-24, 22:30
einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 Topic Opener |
Posted at: 2015-08-26, 16:07
I've added few fixes, plus some statistic display possibility: markdown tables for statistics (when executing all experiments!). First row, first column is "P\S" what stands for "Port \ Ship": rows are for port algorithms, columns- ship algorithms. If someone has better idea for this abbreviation, I am open to it . The names for algorithms are supposed to be short:
I think that the results are quite clear. If not- please tell me. Results for last test case in the project:Game time when last ware reach destination
Mean ship utilization (how many wares are onboard)
Mean number of wares waiting in ports
Maximum number of wares waiting in ports
Mean length of journey for any ware
Mean value of efficiency (length_journey/minimum_possible_length) for any ware
Minimum value of efficiency (length_journey/minimum_possible_length) for any ware
Maximum time waiting for ware in port to take by a ship
Mean time waiting for ware in port to take by a ship
Minimum time waiting for ware in port to take by a ship
einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-08-28, 20:36
Hey, I was away for couple of days, I could read (on a mobile) but had no comfort way to respond :)
Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-08-28, 20:50
And yes, I got approval to merge my branch, but due to this discussion I will wait a bit with merging..... Top Quote |