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 »

JacobD88 wrote:Crash for you Fonso with CD version g6def25ed-cd
Thanks for the report. It was a regression due to changes in trunk affecting the way settings are specified. I've fixed it.
The guy on the picture is not me, it's Alonso.
Nat AS
Engineer
Engineer
Posts: 6
Joined: 24 May 2012 07:01

Re: Cargo Distribution

Post by Nat AS »

fonso wrote:Well, Net AS, you must have made some mistake with your orders there. Order 11 of train 5 can never be reached so it cannot actually take the "shortcut" back to order 3. Thus the train will always refit to food, no matter if it has loaded any goods at order 9. You might as well drop orders 10 and 11. If trunk behaves differently here then that's a bug in trunk.
Yeah, I realised that as I was transcribing the orders, but even after I fixed it, I still get the problem.
And yes, the newgrf but is unrelated, ignore it.

Here's the save after I fixed the order list.
http://dl.dropbox.com/u/24299180/OTTD/H ... 202086.sav

The order list looks like this now,

Code: Select all

1>Go non stop to factory/port
2>Go non stop to city 1
3>Go non stop to city 2
4>Go non stop to city 3
5>Go non stop to city 4
6>Go non stop to nearest depot and refit to goods
7>Go non stop to factory/port
8>Jump to order 2 if load is more than zero
9>Else go non stop to nearest depot and refit back to food
The train is refitting and picking up goods properly, but no matter what it is carrying, it dumps all of it in city 1 and wastes money dragging an empty train the rest of the route,
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

That's a different problem: The ship is very slow and so the goods show up in the port very infrequently. This is why cargodist has a hard time making a plan about goods there. In the absence of any planned distribution the train just delivers the goods on the first occasion it gets. If the train was only carrying goods without the refitting it would behave the same. You should use several smaller ships or some other mode of transport in order to get a proper distribution for goods.

Also, the single train is too little to maintain a stable route for both goods and food. It is barely able to keep the food route up. With such small capacities cargodist doesn't work very well. You can see the problem when you open the smallmap and disable all cargos except food and goods. The links keep breaking down all the time. A proper plan can only be created if the links are stable for some time.
The guy on the picture is not me, it's Alonso.
Nat AS
Engineer
Engineer
Posts: 6
Joined: 24 May 2012 07:01

Re: Cargo Distribution

Post by Nat AS »

The infrequent ship visits were the whole reason I made this contrived plan :c
If they came more often I would have had a dedicated train for them, and then I'd have to increase the amount of platforms at each station to prevent jams, ect ect

Is there any chance of this being improved in the future?
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Actually that's pretty hard to fix within the current architecture. There is a length-dependent timeout for unvisited links. After the timeout the link is removed if it hasn't been visited. This is important in order to remove obsolete links and avoid sending cargo along them. Cargodist doesn't track the orders for that as there are lots of traps to avoid when tracking orders (stopped vehicles, vehicles loading indefinitely, lost vehicles, unreachable conditional orders, conditional refits that will change a vehicles cargo based on the current phase of the moon, you name it). In order to avoid that snake pit I just said "if a link is visited frequently it is active; if not, it can be dropped". The only way to determine "not visited frequently" is by using some kind of timeout. There are still a few things I could do to adaptively adjust that timeout based on recorded past visits, though. Once the algorithm learns that a link is visited only once a year it could give it a longer timeout. I have different priorities at the moment, though. If you want me (or someone else) to remember that problem it would be nice if you could post an issue at github
The guy on the picture is not me, it's Alonso.
Nat AS
Engineer
Engineer
Posts: 6
Joined: 24 May 2012 07:01

Re: Cargo Distribution

Post by Nat AS »

fonso wrote:If you want me (or someone else) to remember that problem it would be nice if you could post an issue at github
And how would i do that?
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

There, I did that for you: http://github.com/fonsinchen/openttd-cargodist/issues/7

It is easy. Go to http://github.com and create an account if you don't have one. Go to http://github.com/fonsinchen/openttd-cargodist, log in if necessary, click on "Issues", click on "New Issue" and write a title and a description in the form. Click on "Submit new issue". Done.
The guy on the picture is not me, it's Alonso.
Nat AS
Engineer
Engineer
Posts: 6
Joined: 24 May 2012 07:01

Re: Cargo Distribution

Post by Nat AS »

Thank you! Although this really is spoon feeding, I'm spoiled. Oh well, At least I wont have to make another account for something I might only ever use once.
sph
Engineer
Engineer
Posts: 20
Joined: 14 Oct 2010 16:09

Re: Cargo Distribution

Post by sph »

I'm getting the following error here (gcc 4.7.0):
src/core/multimap.hpp:375:37: error: ‘lower_bound’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
src/core/multimap.hpp:375:37: note: declarations in dependent base ‘std::map<short unsigned int, std::list<CargoPacket*>, std::less<short unsigned int>, std::allocator<std::pair<const short unsigned int, std::list<CargoPacket*> > > >’ are not found by unqualified lookup
src/core/multimap.hpp:375:37: note: use ‘this->lower_bound’ instead
make[1]: *** [cargopacket.o] Error 1
I attached a patch but basically it's replacing "lower_bound" by "this->lower_bound" twice.
Attachments
multimap-fix.diff
(806 Bytes) Downloaded 159 times
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

sph wrote:I attached a patch but basically it's replacing "lower_bound" by "this->lower_bound" twice.
Thanks. I've included the patch.
The guy on the picture is not me, it's Alonso.
User avatar
siu238X
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 13 Sep 2004 18:54
Location: Hong Kong, China

Re: Cargo Distribution

Post by siu238X »

Sorry if the following question had been asked, but please forgive me for my laziness because I am not very fond of reading 125 pages of discussion...


I got this patch on one of my old saved games and I found it fascinating that it did the distributions on old, un-patched games as well.

My problem is as follows:

Code: Select all

B       B       B       B
|       |       |       |
B   B   B   B   B   B   B
|   |   |   |   |   |   |
T===T===T===T===T===T===T
|   |   |   |   |   |   |
B   B   B   B   B   B   B
|       |       |       |
B       B       B       B
As depicted above, I have a trunk train line running between several towns, and each town have their own feeder systems (Metro-land is my all-time favourite). Thus, all train stations are essentially transfer stations, but they are by no means "parkway stations" (in the middle of nowhere). Therefore, there had to be some passengers destined to these transfer stations.

Which kind of order should I assign vehicles to call these transfer stations?
  1. It seems that, if I don't use "Transfer", the routing algorithm doesn't feel like distributing passengers from feeder onto the mainline (as well as from the mainline to another town's feeder).
  2. However, if I do use "Transfer", then passengers going to the transfer station themselves might get lost upon their arrival.
I am not sure whether my observations are correct, so if Mr. Fonso could explain it (again?) or even include it in the wiki, it'd be most helpful.


P.S. I now know why my buses often get the red bomb when they're back to the the remote terminals, but as long as the little people commute like how I want them to I don't care :lol:
Image
Image
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

don't use any modifiers. the system will do transfers automatically if necessary. but it may need a few rounds of travelling before it has built up the network so the routing can kick in.

check the source stations, initially you will have a lot of people going "to any station", which means they behave like without this patch, so no routing at all, they enter any train and hop off on the next station. after a while, people will appear that do have a specific destination, and they will use the train connections that get them there (not always the shortest. links tend to get overcrowded very fast)

also check that you have the routing enabled (usually "symmetric" for passengers/mail/valuables, "asymmetric" for other cargos)
GhostRybinsk
Engineer
Engineer
Posts: 1
Joined: 24 Apr 2012 18:26

Re: Cargo Distribution

Post by GhostRybinsk »

Hello

How can I get diff or patch file for last version of CD source to apply it myself for a patchpack? There are full source and binary packs only there http://bundles.openttdcoop.org/cargodist/releases/
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

you can get diffs and stuff from the git repository, which is linked in the first post.
User avatar
Ildefonse
Traffic Manager
Traffic Manager
Posts: 134
Joined: 22 Apr 2002 16:32
Location: New Zealand
Contact:

Re: Cargo Distribution

Post by Ildefonse »

Hello,

I recently started playing with CargoDist and have a few questions. I browsed a bit through this thread and the wiki, but it's hard to find the specific info I need.
To make answering simple, I'll number the questions. Save game is included for clarity as well (I use the latest version gd4255b61).

1) I have a simple train line between several cities like this:

C1-------C2-------C3-------C4-------C5

Each city also has a few buses transporting passengers to the train stations, but all in all it's pretty linear.
I have several trains running this route and stopping at every station along the way, and, as an experiment I also introduced two trains with non-stop orders from the first city to the last, and back.

What I find after a while, is that passengers start to build up at C1 heading to C5 non-stop. This amount grows and grows, but then, right before the IC train arrives at the station, they suddenly vanish and/or decide to board the trains that stop at all stations instead.

Is there a reason for this behaviour? How long does it take until these passengers "timeout"? It used to happen when I had one train servicing this route, so I added another, halving the waiting time, but it still happens. The result is empty IC trains that make no profit at all.

2) What I also found in the above situation, is that no passengers would use the IC to travel onwards, e.g. via buses. They would only do this via the non-direct links.

3) Is it possible to add explanations to the settings of CargoDist in the advanced settings tab? It is really, really unclear what everything does now. For example, "Effect of distance on demand: 100%". What effect? Is it a positive effect, or a negative effect?? What do I set it to if I want to prioritize longer routes, >100% or <100%?

The same holds pretty much for all the rest of the settings. I would really like to play around with them, but I'd rather first actually know clearly what they do and how they will affect the algorithms.

Thanks! And all in all, great effort, makes TTD much more interesting this way.
Is there an ETA for when this will appear in the trunk of OpenTTD?
Attachments
Totepiritirima Transport, 4th Dec 1955.sav
Save game to illustrate question 1
(916.37 KiB) Downloaded 144 times
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: Cargo Distribution

Post by YNM »

To answer those question (being a player of cargodist too)

1)It is possible to have a bunch of passenger from C1 to C5 taking via C2 ; Its the more part for cargodist.
And another question : Have you let your intercity train run quite long enough ? It takes some ticks for people to change the destinations, likely. (And the rule in normal OTTD still apply : Trains have to reach both destinations before cargo/pax piling up).

2)See above. (Well, but I still use older builts, so I don't know if this is happens in newer builts only)

3) EDIT : Fonso, where are you ?
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Ildefonse wrote: What I find after a while, is that passengers start to build up at C1 heading to C5 non-stop. This amount grows and grows, but then, right before the IC train arrives at the station, they suddenly vanish and/or decide to board the trains that stop at all stations instead.

Is there a reason for this behaviour? How long does it take until these passengers "timeout"? It used to happen when I had one train servicing this route, so I added another, halving the waiting time, but it still happens. The result is empty IC trains that make no profit at all.
The service is still not frequent enough. The link breaks down before the train arrives and the passengers get assigned to other links. You can see that when watching the link graph visualization simultaniously. See also https://github.com/fonsinchen/openttd-c ... t/issues/7
Ildefonse wrote: What I also found in the above situation, is that no passengers would use the IC to travel onwards, e.g. via buses. They would only do this via the non-direct links.
The few passengers the non-stop trains pick up are probably "to any station". They just behave as if there wasn't any cargodist.
Ildefonse wrote: Is it possible to add explanations to the settings of CargoDist in the advanced settings tab? It is really, really unclear what everything does now. For example, "Effect of distance on demand: 100%". What effect? Is it a positive effect, or a negative effect?? What do I set it to if I want to prioritize longer routes, >100% or <100%?

The same holds pretty much for all the rest of the settings. I would really like to play around with them, but I'd rather first actually know clearly what they do and how they will affect the algorithms.
Yes, sorry. I should write some descriptions for them. The direction of effect of distance is negative. I though that would be self-explanatory. So, 0% means all destinations are treated the same, no matter how far away they are and 100% means destinations are treated in a way that I think should be good for the usual player. >100% means local destinations are preferred very much over remote ones. The description field has been added to the settings window only recently. When I wrote the code there was no space for those details.

There is no ETA for anything. Someone should sit down and do the big refactoring I have pointed out in #3 to #6 at https://github.com/fonsinchen/openttd-cargodist/issues . The code is in pretty good shape so it can be refactored without rewriting everything. However, it's a lot of work.
The guy on the picture is not me, it's Alonso.
User avatar
Ildefonse
Traffic Manager
Traffic Manager
Posts: 134
Joined: 22 Apr 2002 16:32
Location: New Zealand
Contact:

Re: Cargo Distribution

Post by Ildefonse »

Ok, thanks for the answers! So I'd have to make the service even more frequent. Won't that risk the possibility of every train still being only half full at best in that case?
It didn't seem like there were enough passengers being generated even for this amount of trains. If I put more, will cargodist generate more pax for that route?

If not, then the IC might simply not be viable at this stage of town size, correct?

Later in the game I set up another route, connecting MAW with the towns to the north/west, and cargodist generated a huge interest for travel between the big cities there. That was cool, but then the interest kind of exploded ;) Now there's 8 trains running the route non-stop, which already causes them to arrive in the station pretty much one after the other, yet there's still 1000's of pax waiting for that route. Does that happen commonly for cities of 3000+ ppl? I don't want to begin to imagine the size of stations I'd have to make for cities of 30.000 ppl.

Thanks for the description of the setting, I actually thought it'd be the opposite, e.g. higher % would favour long distance routes.

Cheers!
Attachments
Totepiritirima Transport, 20th Aug 1962.sav
New busy IC link
(959.57 KiB) Downloaded 117 times
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Cargodist increases the overall amount of passengers at your stations as more people transfer than in a normal game and those guys show up at multiple stations during their journey. People have written patches to reduce the amount of passengers. So, yes, you should carefully plan your network for high capacities. On the other hand Cargodist will prefer big and near destinations. So your IC might in fact be useless. But do some experiments and find out. Then discuss those gameplay strategies at http://www.tt-forums.net/viewtopic.php?f=29&t=58091 , please.
The guy on the picture is not me, it's Alonso.
User avatar
Ildefonse
Traffic Manager
Traffic Manager
Posts: 134
Joined: 22 Apr 2002 16:32
Location: New Zealand
Contact:

Re: Cargo Distribution

Post by Ildefonse »

Ok, thanks!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 10 guests