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
kamnet
Moderator
Moderator
Posts: 8548
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Cargo Distribution

Post by kamnet »

That "some reason" is because most people prefer to get from A->B directly without any stopovers, and thus is a premium that they will pay for. Airlines give a discount on A->B->C because it helps them fill capacity and operate more efficiently and it appeals to individuals who value money over time.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Cargo Distribution

Post by Wahazar »

Alberth wrote:How would you detect such a cargo? Note that cargo itself has no "this is primary" property. You only know industries, and what it accepts and produces.
Bulk class can be such (roughly approximated) criterium, however even in case of primary cargo, cargodist itself sometimes is useful, sometimes not.

For example, consider following chain:

Code: Select all

S1 ---> R1 <--- S2 ---> R2 <--- S3 
Cargodist will send some freight from S1 trough R1 and S2 to R2, and the same with S3 to R1.
It is not bad, because your vehicles have no empty runs. And load time at S2 is low.
OK, I want to enable cargodist even for bulk/primary cargos.

But consider same topology located not linear:

Code: Select all

R1  <-- S2 
^         |
|         |
|        R2 <-- S3
S1
and now S1-R1 link is used for wastage S1-R2 cargo instead of profitable S1-R1 and S2-R2 ones.
It is a reason, why players on my server requested to switch freight cargodist off.
Rubidium wrote:I fairly regularly see odd routes for airplane trips that are way longer than necessary.
But those discounts are intentionally provided by airlines operators - as Kamnet mentioned, it is to avoid empty links.
You cannot buy cheap A1-B-A2 ticket if A1-B link is already saturated.
In case of openttd, fares are fixed, and cargodist make totally opposite thing -
it assign unprofitable A1-B-A2 instead of profitable A1-B.
The real company would bankrupt within a days with such fares policy.

I understand, that cargodist authors are willing to force players to make optimal transport grid,
but such feature described above seems to be to much harassment, especially for on-line players -
there is no opportunity to pull-down, and analyse every cargo at each station.

My compromise proposition is as follows:
lets keep demands calculation as it was before, but give load priority for links which direct distance to hop distance ratio is higher.
(it can be soft priority - just decrease amount of "unwanted" cargo loaded proportional to distance ratio).
If you have spare place in your vehicles, those "unwanted" cargos would be transporter either.
If all loading space is filled up by cargo travelling straightforward, roundabout cargo would pile up at station.
I think it is clear information for player, that his network is suboptimal, without stealthy abusing his resources.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Cargo Distribution

Post by Alberth »

McZapkie wrote:But consider same topology located not linear:

Code: Select all

R1  <-- S2 
^         |
|         |
|        R2 <-- S3
S1
and now S1-R1 link is used for wastage S1-R2 cargo instead of profitable S1-R1 and S2-R2 ones.
It is a reason, why players on my server requested to switch freight cargodist off.
Just set the order of S2->R1 to "no loading" at R1. Problem solved?
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Cargo Distribution

Post by Wahazar »

Alberth wrote:Just set the order of S2->R1 to "no loading" at R1. Problem solved?
If player is aware about such problem, it can help to solve.
But I am talking about general improvement of cargo distribution algorithm - which is faulty by now - if manual intervention is needed to avoid absurd routes.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

I don't really think this discussion is going anywhere like this. I'm not implementing any heuristic to "automatically" determine which routes should be considered "sane" or which cargoes should be considered "safe" for cargodist. If anyone wants to do that, go ahead, but make a new thread for that.

One thing I can imagine is more options to set distribution types for cargoes. I think we have successfully determined that having newGRFs set distribution types isn't going anywhere either, which significantly simplifies the debate. So, if you look at cargotype.h you'll find this:

Code: Select all

enum CargoClass {
	CC_NOAVAILABLE  = 0,       ///< No cargo class has been specified
	CC_PASSENGERS   = 1 <<  0, ///< Passengers
	CC_MAIL         = 1 <<  1, ///< Mail
	CC_EXPRESS      = 1 <<  2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers)
	CC_ARMOURED     = 1 <<  3, ///< Armoured cargo (Valuables, Gold, Diamonds)
	CC_BULK         = 1 <<  4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit)
	CC_PIECE_GOODS  = 1 <<  5, ///< Piece goods (Livestock, Wood, Steel, Paper)
	CC_LIQUID       = 1 <<  6, ///< Liquids (Oil, Water, Rubber)
	CC_REFRIGERATED = 1 <<  7, ///< Refrigerated cargo (Food, Fruit)
	CC_HAZARDOUS    = 1 <<  8, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.)
	CC_COVERED      = 1 <<  9, ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.)
	CC_SPECIAL      = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes.
};
Right now we have special distribution types for CC_PASSENGERS, CC_MAIL and CC_ARMOURED. Everything else is handled by "default distribution type". Now, depending if we want to handle CC_NOAVAILABLE, those are 10 or 11 cargo classes with actual meaning. I can very well imagine having 11 instead of 4 options for defining distribution types and then just be done with it. However, I'll be gone for 4 weeks from saturday. Don't expect any code from me in the near future and feel free to implement that yourself. It should be pretty straight forward.
The guy on the picture is not me, it's Alonso.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: Cargo Distribution

Post by keoz »

fonso wrote:However, I'll be gone for 4 weeks from saturday.
I wish you nice travel/holidays. :D

And thank you, once more, for this great piece of code you added to OTTD.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

there are a number of problems with using cargo classes.
  • first: a cargo class is no guarantee for a uniform group of cargos. like i probably need a different type of distribution (e.g. weight allocation, or handling of unconnected destinations) for fertilizer (more like goods or supplies) than for coal or ore, yet all of those are in "bulk"
  • second: a cargo can have more than one class, how is the behaviour defined if the settings for the classes differ? majority rule? on overrides off? off overrides on? the lower class takes precedence?
  • third: even though the values 10 to 14 are unused in the code, there is no guarantee that NewGRFs won't use them.
all in all, i think overloading cargo classes (which are meant for determining which vehicle can load something, nothing else) with cargodist stuff is questionable...
User avatar
te_lanus
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 19 Jul 2012 18:04
Location: The Elizabeth Arkham Asylum for the Criminally Insane

Re: Cargo Distribution

Post by te_lanus »

Two easy questions. Only recently started with cargodist.

1) I set up a road network servicing a few stops included is a stop that's linked to the airport, on theis line I've noticed that every now and then, that certain busses will get a "tranfer=R12000/cost=R5600" (an example) . Read a bit, but not sure whyme is paying for a delivery.

2) Playing without cargodist I get about 3-4 subsidy offers yearsly, yet with cargodist After 20 game years still hven't had one , any idea why?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

ad 1) you get paid, but the final payment is more than what was 'given' to the other vehicles which helped get the cargo to its destination. Thus the income for the last vehicle is negative. See also https://wiki.openttd.org/Negative_incom ... er_service

ad 2) Subsidies don't work with cargodist. You won't get any.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Cargo Distribution

Post by Wahazar »

fonso wrote:One thing I can imagine is more options to set distribution types for cargoes. I think we have successfully determined that having newGRFs set distribution types isn't going anywhere either, which significantly simplifies the debate.
I agree with Eddi, that using these cargo classes to determine cargodist action can be questionable,
for example FIRS petrol and refined products are bulk, as crude oil, but since there is usually no reasons to use cargodist for oil (and other "primary" resources), secondary (refined products) and especially final (petrol) needs to be distributed to many places.

Instead of cargo classes, is it possible to use life_type flag of cargo origin to choose cargodist distribution type?

Code: Select all

enum IndustryLifeType {
	INDUSTRYLIFE_BLACK_HOLE =      0, ///< Like power plants and banks
	INDUSTRYLIFE_EXTRACTIVE = 1 << 0, ///< Like mines
	INDUSTRYLIFE_ORGANIC    = 1 << 1, ///< Like forests, farms
	INDUSTRYLIFE_PROCESSING = 1 << 2, ///< Like factories
};
 
fonso wrote: I'm not implementing any heuristic to "automatically" determine which routes should be considered "sane" or which cargoes should be considered "safe" for cargodist.
There is no need for any AI, but currently there is demand_distance parameter, which define how amount of allocated cargo depend on distance between origin and recipient.
The bad feature, in my opinion, is to use direct distance,
instead of sum of all hops between origin and source.
Is it possible to fix, or huge workload for code rewriting is needed?
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

McZapkie wrote: Instead of cargo classes, is it possible to use life_type flag of cargo origin to choose cargodist distribution type?

Code: Select all

enum IndustryLifeType {
	INDUSTRYLIFE_BLACK_HOLE =      0, ///< Like power plants and banks
	INDUSTRYLIFE_EXTRACTIVE = 1 << 0, ///< Like mines
	INDUSTRYLIFE_ORGANIC    = 1 << 1, ///< Like forests, farms
	INDUSTRYLIFE_PROCESSING = 1 << 2, ///< Like factories
};
[/quote]

No. For one, the type of industry a cargo originates from is not stored with cargo, thus not available. But worse, and that kills the suggestion: same cargo can be produced by different industries, e.g. from black hole, extractive, organic and processing industries (e.g. think of 'waste' cargo). What type would you attach to it? This is an at least equally bad abuse of an existing game concept than abusing cargo classes for that purpose.
kujichagulia
Engineer
Engineer
Posts: 31
Joined: 05 Jul 2011 00:57
Location: Sakai, Japan

Re: Cargo Distribution

Post by kujichagulia »

Forgive me if I missed this - I've been away from OpenTTD for a year or so, and I couldn't find the right information when searching - but has CargoDist been included in the standard OpenTTD now? And if so, how do you activate it? I downloaded the latest version of OpenTTD, but after starting a test game with a train line and a few buses, the passengers don't seem to be distributed to certain destinations. I remember there used to be a feature in the station window that shows you exactly where passengers are going, and even passengers that don't have a specific destination.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: Cargo Distribution

Post by aantono »

You need to enable it in Advanced Settings -> Cargo Distribution menu. Switch the Passengers and/or Mail to either symmetric or asymmetric, and you will get CargoDist to work. If all cargo groups are set to manual, CargoDist is off.
kujichagulia
Engineer
Engineer
Posts: 31
Joined: 05 Jul 2011 00:57
Location: Sakai, Japan

Re: Cargo Distribution

Post by kujichagulia »

@aantono - Excellent. Thank you very much!
CSL
Engineer
Engineer
Posts: 41
Joined: 18 Aug 2004 15:02

Re: Cargo Distribution

Post by CSL »

@aantono thanks a lot to you too, I am also away from OpenTTD for 2-3yrs because of lacking of cargodist and instead go for Simutrans.

Now actually its patched into the game...I can now go back to OpenTTD

THANKS :)
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: Cargo Distribution

Post by aantono »

You are most welcome, though the real THANKS should go to @fonso, who dedicated a lot of time to get it polished to the point of perfection and being accepted into the trunk!
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Cargo Distribution

Post by Wahazar »

andythenorth wrote: (Those cargos are liquid, nowhere near bulk class) ;)
Indeed. Note to myself: don't drink and write.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

And if you drink, don't drink bulk but rather liquid.
The guy on the picture is not me, it's Alonso.
User avatar
le_harv
Engineer
Engineer
Posts: 83
Joined: 27 Sep 2014 05:16

Re: Cargodist/YACD/ChillPP playing strategies

Post by le_harv »

JGR wrote:I recently ran into an interesting problem (for reference using Chill's Patchpack (hca7f5804)).
Rather than using direct point to point links for all freight, I decided to try using a bus type topology, using a single train line, onto which feeder services shuttle cargo in either direction from various nodes along the line. In particular, some cargoes fed onto the train line are not directly accepted at any rail stations. As I'm currently near the start of an ECS game, the number of cargoes and the distances between (some) industries is relatively high, but the quantity of cargo to transport is relatively small. So I'm using (at present) a single freight train (with wagons of the various cargoes) to service the line (the line is also used for passengers).
This works quite well with routed cargo, the snag arises when any unrouted freight is generated.
Whilst it is easy to move such cargo onto the rail line (using transfer & leave empty orders), getting it off the line at the correct station is more difficult, as there is not a mechanism for cargo-specific transfer orders. The cargo then just sits on the train indefinitely and effective blocks the line.
I realise that I could just use one train per cargo or one train per exit node, but this is not really ideal, and soon becomes overly expensive (given how many cargoes ECS has). That however would not work well either in the event that a cargo becomes transferable via more than one node along the line.

I've not been able to come up with a genuinely elegant solution, with the possible exception of just disabling unrouted cargo entirely, however this would have other fairly nasty implications.

Any bright ideas? Have others had any luck with this sort of layout?

Code: Select all

       Λ                         Λ                         Λ
       |                         |                         |
       V                         V                         V
<=================================================================================>
                 Λ                         Λ                         Λ
                 |                         |                         |
                 V                         V                         V
(As an additional disclaimer, I've not previously used ECS before, or really attempted to implement the associated type of distributed freight network using cargodist/cargodest/etc.)
Apologies if I am resurrecting an old thread but I am having the same issue as this poster and I didn't see any reply so I am curious as to how to solve this problem. I have two factories a distance apart. Trucks collect goods produced and drop them off at exchange sidings for each factory. A train will collect the goods from exchange sidings A transport them to exchange sidings B, unload and then load the goods destined back to exchange sidings A. The trucks mentioned above also make run back to a city with goods on board before returning to the factory.

It is a similar system as mentioned in the quote and it worked great until the cargo stopped having a destination all of a sudden and was available to any station. The trains then load but are not unloading cargo, as suggested above, effectively blocking the rail line and cargodist can't recalculate the route because the train is full. I did read on another thread that this also happens because the service is too infrequent. I believe this was the answer... http://www.tt-forums.net/viewtopic.php? ... start=2840 (about halfway down)
fonso wrote:I don't think this has anything to do with the dates. It's probably just the normal effect of creating and dropping links. If a link between two stations is visited too infrequently it's dropped, sending all people waiting for it "to any station". Those people are then picked up by other vehicles and slowly get transported away. I have another patch that prevents dropping of links for which there still are orders, even if the vehicles are visiting those links very infrequently. I haven't gotten around to committing it, yet.
This also sounds like my issue but its a bit of a catch 22 as the 'any station' goods don't go anywhere so there is no recalculation. You mention a patch that stops the links from ever being dropped. Has any progress been made on this?

I don't use any patches, and use the latest stable release of 1.4.3. I have a handful of newgrfs that I use too and can provide a list if needs be.

I just wanted to say that cargodist is an outstanding development and truly takes the game to a whole new level. It's the best thing since path based signals. Thank you for the effort of bringing forward such a professional and complex implementation :bow:
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 3 guests