Cargo Distribution

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

el koeno wrote:This might seem silly; but I have to admit that after playing this patch since the first (working) binary got posted here, I still do not fully understand how cargo/passengers are routed. :oops: Suppose there's ship between two stations, and a metro/rail connection (requiring transfering from the metro to the train). This is an actual situation in my game. But I have no clue how the passengers choose which option to take...

I do get that capacity matters, but what if capacity is equal? Or the slowest, most inconvenient option has the highest capacity?
First, why do I have to repeat myself again? Post a savegame. Always. Come on, it can't be that hard!

In the first pass the shortest routes are saturated up to the percentage given in the option "saturation of short paths". The length of a path is the sum of the manhattan distances between the stations it visits plus one for each hop. The absolutely shortest path is saturated up to that percentage first, then the second shortest one and so on until all paths are saturated (up to the given percentage) or no demand is left. The very shortest path in your game is probably the ship as I guess it has no other stops in between.

In the second pass the paths with most capacity left are saturated in turn. I guess after the first pass more capacity is left on the train route than on the ship route. So first the train route is saturated until less capacity is left there than on the ship route. Then the ship route gets more flow assigned, then the train route again and so on until all demand is used up. The result is what you see in the "planned" view. Cargo is always sent along the most undersupplied link, which is the one where (planned - sent) is greatest. After sending cargo "sent" is increased accordingly. "sent" is also subject to the moving average calculation so it won't grow infinitely.
The guy on the picture is not me, it's Alonso.
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: Cargo Distribution

Post by el koeno »

fonso wrote:
el koeno wrote:This might seem silly; but I have to admit that after playing this patch since the first (working) binary got posted here, I still do not fully understand how cargo/passengers are routed. :oops: Suppose there's ship between two stations, and a metro/rail connection (requiring transfering from the metro to the train). This is an actual situation in my game. But I have no clue how the passengers choose which option to take...

I do get that capacity matters, but what if capacity is equal? Or the slowest, most inconvenient option has the highest capacity?
First, why do I have to repeat myself again? Post a savegame. Always. Come on, it can't be that hard!
Judging from the progress you're making I'm pretty sure you're working hard, but please; take it easy! You basically answered my question without having to look up which binary I used, starting it, loading the savegame, and looking for city I meant (actually, the public transit in the city is pretty awesome, so the time might actually be well spent :)). This was just a general question, so I thought no savegame was needed, at all. I still think so, and a response in large red letters was uncalled for if you ask me. But if you still really want to see a savegame, I could find out which binary I downloaded, and report back to you.

Anyway, let's not dwell on this, as you're answer interests me:
In the first pass the shortest routes are saturated up to the percentage given in the option "saturation of short paths". The length of a path is the sum of the manhattan distances between the stations it visits plus one for each hop. The absolutely shortest path is saturated up to that percentage first, then the second shortest one and so on until all paths are saturated (up to the given percentage) or no demand is left. The very shortest path in your game is probably the ship as I guess it has no other stops in between.

In the second pass the paths with most capacity left are saturated in turn. I guess after the first pass more capacity is left on the train route than on the ship route. So first the train route is saturated until less capacity is left there than on the ship route. Then the ship route gets more flow assigned, then the train route again and so on until all demand is used up. The result is what you see in the "planned" view. Cargo is always sent along the most undersupplied link, which is the one where (planned - sent) is greatest. After sending cargo "sent" is increased accordingly. "sent" is also subject to the moving average calculation so it won't grow infinitely.
From your answer I understand that there currently is no preferred routes; all cargo is distributed across the available options. Is this correct? It would seem sort of weird that passengers would let empty seats in the most efficient option.

In reality, there are often more than two routes, unless you've got a pure hub-and-spokes style network. Trams can be taken around town, before boarding the boat, you can catch a plane halfway across the map, take local trains back, and then catch the metro and train. Obviously, these options should not be counted, so there must be a way to discriminate between routes; which ones are acceptably efficient, and which ones are not. I'm just curious how this works.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Cargo Distribution

Post by Rubidium »

fonso wrote:First, why do I have to repeat myself again? Post a savegame. Always. Come on, it can't be that hard!
It is very hard. It even is very hard when such big red letters tell you to attach certain files on bug reports and still most of the time people do not attach the requested files. Even though you repeat yourself every time, it won't help those who simply cannot act upon what is written.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

el koeno wrote:... I still think so, and a response in large red letters was uncalled for if you ask me. But if you still really want to see a savegame, I could find out which binary I downloaded, and report back to you.
OK, that might have been a bit harsh. However, those comments very often highlight a problem in cargodist and I always like to have the opportunity to actually look at it. So, yes, posting a savegame is always good. Additionally posting version information is even better. In newer versions you can just post the version string you see in the menu window and I'll know enough. Anyway, if I want to open a savegame and I don't know which version it was created with I'll be less annoyed than if I want to see the problem and don't have a save game.
el koeno wrote: From your answer I understand that there currently is no preferred routes; all cargo is distributed across the available options. Is this correct? It would seem sort of weird that passengers would let empty seats in the most efficient option.

In reality, there are often more than two routes, unless you've got a pure hub-and-spokes style network. Trams can be taken around town, before boarding the boat, you can catch a plane halfway across the map, take local trains back, and then catch the metro and train. Obviously, these options should not be counted, so there must be a way to discriminate between routes; which ones are acceptably efficient, and which ones are not. I'm just curious how this works.
I think you are misunderstanding what "capacity" and "length" are for cargodist. And you seem to think it only works for up to two parallel routes, but I don't know how you get that idea.

"capacity" is the total amount of cargo that can be transported along a given link per month. Of course that not only measures the size and number of the vehicles serving it but also their speed. The faster the vehicles are the more often they visit the stations and the more cargo can be transported.

"length" is the added manhattan distance between the stations involved plus one for each hop. If a route contains a long detour across numerous hops it will be very long. If a route is a straight line from source to destination, but with some stops in between it will be shorter, but still long. If a vehicle goes directly from the source to the destination station without stopping the length of the resulting route is minimal.

The current implementation does prefer routes that either have a high capacity or are short. Of course there might be routes with a high capacity which send cargo all across the map as you describe above. This is why the short routes are saturated first. The second pass is mainly for assigning demand that exceeds the available capacity. In the second pass only routes can be used that have already been established in the first pass, so you won't get overly long routes if that hadn't been necessary before. If it had been necessary then you have either set the short path saturation very low (which defeats the purpose of the second pass) or you simply have too much cargo to be transported on the shorter routes.
The guy on the picture is not me, it's Alonso.
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: Cargo Distribution

Post by el koeno »

Ah, I think I understand. I think I kind of forgot to mention that it seems to be working quite well. I've got way too many passengers to really judge what's going on (1,600 people to go to an oilfield :)), so it's very hard to see what's going on behind all those numbers. Thanks for the clarification. :)
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

there's a passenger reduction patch around, maybe that'll help you.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Cargo Distribution

Post by DaleStan »

fonso wrote:First, why do I have to repeat myself again? Post a savegame. Always. Come on, it can't be that hard!
If you want people to do that, you need to end your posts right there.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

el koeno wrote:... (1,600 people to go to an oilfield :)) ...
Now, where is the savegame? This is not normal.
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Windows binary of latest version:

http://fickzoo.com/fonsinchen/openttd-c ... -win32.zip

Actually Cargodist is built by the compile farm now. You can download lots of different binaries from this place:

http://mz.openttdcoop.org/bundles/cargodist/

Thanks TrueBrain for compiling, Ammler for hosting, Yexo for saying OK.
The guy on the picture is not me, it's Alonso.
Aqua77
Engineer
Engineer
Posts: 27
Joined: 26 May 2009 09:31

Re: Cargo Distribution

Post by Aqua77 »

Sometimes, my full loaded train is not leaving the station immediately, even when its way is free.
I think that happens when another train is waiting for its full load at the same station too.
Attachments
Nestheim 100percent.sav
(95.19 KiB) Downloaded 59 times
Aqua77
Engineer
Engineer
Posts: 27
Joined: 26 May 2009 09:31

Re: Cargo Distribution

Post by Aqua77 »

Cargodist.jpg
Cargodist.jpg (20.25 KiB) Viewed 2824 times
Is it possible to keep also the destinations with 0 passengers or mail in this list? I would like that.
Why is there "to any station" and "via any station" and not the name of the station?
Can u suppress the via-line when the via-station is the same as the to-station?
User avatar
Toni Babelony
Tycoon
Tycoon
Posts: 1389
Joined: 07 Jul 2006 09:34
Skype: toni_babelony
Location: Sagamihara-shi, Japan
Contact:

Re: Cargo Distribution

Post by Toni Babelony »

fonso wrote:Actually Cargodist is built by the compile farm now. You can download lots of different binaries from this place:

http://mz.openttdcoop.org/bundles/cargodist/
EPIC WIN!

This saves so much time with compiling and now everybody can play with cargodist! Excellent job! :)
Retired JapanSet developer and creator of TIAS.
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Cargo Distribution

Post by Gathers »

Aqua77 wrote:Sometimes, my full loaded train is not leaving the station immediately, even when its way is free.
I think that happens when another train is waiting for its full load at the same station too.
I have also noticed tendencies for similar dilatory behaviour amongst the otherwise diligent drivers of my trains. :? After learning and playing around with git bisect it seems to me like on commit 2d782f full load handling was good, on c1d1fe it broke and did not work at all and on 6709a9 it was fixed, but not fully.

Unfortunately, I'm not at all familiar with openttd code and I don't really understand what's going on in the code that changed.. Yet I still hope this otherwise pointless post might somehow be helpful as a start for fonso or anyone else who feels like having a go at it.
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: Cargo Distribution

Post by el koeno »

fonso wrote:
el koeno wrote:... (1,600 people to go to an oilfield :)) ...
Now, where is the savegame? This is not normal.
Hmmm... This was just one example of how swamped I got with passengers, and its seems I overstated the issue a bit. There were ~1400 people waiting at a heliport. Only ~1000 of them were actually going to the oilfieds: the helicopter served three platforms, so that's about 300 per platform. Compared to the 10,000 people I get at other stations it's a joke - as it should be. Oilfied passenger transportation should be a niche business.

When my current game runs too slow on this pc, I'll get a recent binary and do some proper testing. And trust me, if I think you should see something, I will post a savegame. ;)

Forget about that. It's going waaay to slow for me. Map is very busy, lots of boats, lots of cargo, but it might be cargodist creating the slowdown. R16284, binary here. The savegame is positioned at a spot where the problem described above happens; I created a train with exactly the same capacity as an oil tanker, it reaches 100%, and doesn't leave. I didn't think it was a cargodist problem, but you might be interested. The oilfied heliport is near Agincourt.

===Forgot to include a screenie of my NewGRF settings, but my housemates are already waiting with dinner for me, so I'll post it later, if needed.===
Attachments
Slow.sav
(1.82 MiB) Downloaded 255 times
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

I'll have a look at the loading problem as soon as possible. Thanks for all the feedback.

About the station GUI:

I'm not fully satisfied with the redundant "to" and "via" entries either. However, if I remove any of them you'll get an unexpected entry when clicking on the "+". For example you might might have grouped by source-via-destination and want to see the next hop for some entry, so you click on the "+". Then, if I follow Aqua77's proposal, either you only get a "to" entry (which usually doesn't tell you about the next stop, but in this case it would) or no further "+" for the destination station. Of course there'd only be one destination station, but that wouldn't be evident. Also it would break the alignment of the entries and make things harder to read. At the moment you can easily spot which entry belongs to which column. This wouldn't be possible if I moved entries to the left. I think all this would confuse a lot more people than the current situation annoys. If anyone has an idea concerning that, please post it.

About destinations with 0 passengers. Unfortunately I can't do that. It would mean adding every single station on the map to the list. This would be very confusing for most people. There is an exception. Some flows contain less than 1 but more then 0 units per month. This happens because the moving average is usually longer than 30 and I scale all flows to one month in the station GUI. At the moment those entries aren't shown, but I could show them as either 0 or 1.

The "any station" entries mean just that. The cargo shown there is not handled by cargodist and you can deliver it to any station you like. I can't give any more details about it and I have explained numerous times why there will always be some unrouted cargo.
The guy on the picture is not me, it's Alonso.
_Robbie_
Engineer
Engineer
Posts: 49
Joined: 23 Feb 2008 09:52
Location: Norway

Re: Cargo Distribution

Post by _Robbie_ »

I did a quick mockup (in paint :lol: ) of how I think station GUI should look like. I don't know how difficult it would be to make something like that, as I never played with the code responsible for drawing GUIs, but if it's doable, then I think it would be better (cleaner) than current interface. Then you could also get rid of "Destination-Via-Source" drop-down list. For cargos without destination only box on the left would be used. Though I realize that it would look rather bad if someone would play without destinations...
Attachments
...I have a dream...
...I have a dream...
GUI example.png (39.3 KiB) Viewed 2632 times
Robbie
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

_Robbie_ wrote:I did a quick mockup (in paint :lol: ) of how I think station GUI should look like. I don't know how difficult it would be to make something like that, as I never played with the code responsible for drawing GUIs, but if it's doable, then I think it would be better (cleaner) than current interface. Then you could also get rid of "Destination-Via-Source" drop-down list.
Thanks. It looks nice.
_Robbie_ wrote:For cargos without destination only box on the left would be used. Though I realize that it would look rather bad if someone would play without destinations...
I think you either mean the box on the right or the texts are wrong. And if I don't draw those vertical seperator lines no one will notice that anything is missing when playing without destinations :)

Unfortunately this layout doesn't associate entries between the columns, does it? So I if there was more than one destination station I wouldn't be able to find out which passengers were going via which next stop to which destination station. I'd only be able to see n passengers going to station X via some unspecified next stops or m passengers going via next stop Y to some unspecified destination. Or what would that look like? Perhaps this information isn't important after all. Generally, this looks better than the current layout. Perhaps I'll try to implement something similar.

Edit: It also takes about 3 times as much space as the current layout in the horizontal dimension. I'm reluctant to massively increase the size of the station window as that means decreasing the maximum number of station windows that can be visible at once.
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

New version:
  • Fix: When there was no cargo, but a fully loaded vehicle with a "full load" order at a station, the vehicle would not leave.
  • Fix some smaller glitches in the station GUI
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

el koeno wrote: Forget about that. It's going waaay to slow for me. Map is very busy, lots of boats, lots of cargo, but it might be cargodist creating the slowdown. R16284, binary here.
I guess you are right with blaming cargodist. It uses way too much memory on this map. If you have an older computer this may well be the reason for the slowdown. It probably has a memory leak somewhere. I'm investigating that.
el koeno wrote: The savegame is positioned at a spot where the problem described above happens; I created a train with exactly the same capacity as an oil tanker, it reaches 100%, and doesn't leave. I didn't think it was a cargodist problem, but you might be interested.
Of course it was a cargodist problem and it is fixed in the latest version.
The guy on the picture is not me, it's Alonso.
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: Cargo Distribution

Post by Wasila »

Is there any system of applying patches to versions before savegame bump? Patching for me still fails...

Thanks anyway!
Wasila
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 18 guests