News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[patch] optimizations in cargo routing

Started by Dwachs, February 01, 2013, 02:45:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

This patch calculates connected components of the cargo-network. If two halts belong to two different connected components, then they are disconnected and no route search is necessary.

Any thoughts?
Parsley, sage, rosemary, and maggikraut.

prissi

Aparently I am not good at patch reading. Before the connections were sorted, but now those are just appended? (May have misinterpreted this, it is already 2am here.)

The idea is good. Did you profile it? (Yoshi87 has a lot off goods running, but most are crossconnected.) But then, those optimisation only affect factories with stops by no connection. It would be interesting to see the additional effort of bookekping when adding stop etc. versus the time save for routing from unconnected factories with good stops.

One could also think that a factory does not update their distribution target, if it isd not overflown or schedule counter changed. That would avoid the calls to route altogether.

PS: By looking at simhalt.cc I found out that I again forgot half of the changes. connections_t is not commented, esp. weight. Maybe you could add this too.

Dwachs

The patch reduces time spent in search_route(...) by roughly 20% (for the yoshi game). I think most of the gain is for distributing factory output. If start and end halts are not connected then the search cancels much earlier.

It also allows to check for existing connection for scripts.

Another motivation was to rework the schedule-counter stuff. Now the calls to set_schedule_counter are done very conservatively. It could later be refined. For instance, if a new line is established that connects two formerly disconnected components of the route graph, then these two components are united and rerouting only need to happen on the new component.
Parsley, sage, rosemary, and maggikraut.

prissi

Aparently you reached the submit stage. 20% is much more than I expected (as the yoshi game is quite nicely crossconnected already.)

Dwachs

Parsley, sage, rosemary, and maggikraut.