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

resurrection
Engineer
Engineer
Posts: 28
Joined: 24 May 2009 16:58

Re: Cargo Distribution

Post by resurrection »

Hi, in recent versions I am having this strange bug. It's somewhat hard to explain so please see the savegame. Basically in more complex delivery the final trains actually delivering the cargo gives the company correct profit BUT in their records it shows as loss (and it shows as loss on delivery in floating number representing the revenue). So the profit is given correctly but it shows wrongly and causes tons of "vehicles in reds" every year while they actually are not.

It happens in last 3 bundles (win32 and win64) freshly installed. Maybe I have something wong in my settings? Thx for help!
Attachments
Res Transport, 18. led 1960.sav
(603.98 KiB) Downloaded 30 times
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

this is an old problem, that also appears in "normal" openttd, see http://wiki.openttd.org/Negative_income ... er_service
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: Cargo Distribution

Post by aantono »

I was looking at the codebase, and I don't see a latest bug, which was fixed in the commit "ff4a46603b465188333b807d86d0bcc964402cd6" appearing in the master "cd" branch. Has that fix been integrated in the latest build?
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

The fix is included in eeaaead1 - "implementation of SharesMap and FlowStatMap". There's no need to keep fix commits around when rebasing all the time.
The guy on the picture is not me, it's Alonso.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

I'm about to start a new CD game, any ideas for specific things to try? I usually play only industrial (FIRS) transportation with NuTracks and 2CC, a passenger game however is a possibility to. Let me know if you prefer any specific testing Fonso.
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: Cargo Distribution

Post by bokkie »

a huge network for testing performance I believe. Fonso said something about the network design as well... you might search this thread and the cd merge thread.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Yes, big complicated networks that drive the MCF solver to its limits are interesting. Also interesting: uncovering problems with order modifications, conditional, unload, transfer and so on.
The guy on the picture is not me, it's Alonso.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

As an idea of something which would be nice if it somewhat continues to work (using heavily conditional orders) and what I'd like see a game with CD made with: http://blog.openttdcoop.org/2009/07/19/ ... rders-sro/ (I was only slightly excessive there :D )
Robbedem
Engineer
Engineer
Posts: 111
Joined: 14 Jan 2013 18:08

Re: Cargo Distribution

Post by Robbedem »

Is there an intention that passengers/mail/goods... can remain on a vehicle when they need to go to a further destination of that vehicle?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

Robbedem wrote:Is there an intention that passengers/mail/goods... can remain on a vehicle when they need to go to a further destination of that vehicle?
Uhm... did you play cargodist? That's what happens already. Even in a fashion that happens in trunk...
Robbedem
Engineer
Engineer
Posts: 111
Joined: 14 Jan 2013 18:08

Re: Cargo Distribution

Post by Robbedem »

planetmaker wrote:Uhm... did you play cargodist? That's what happens already. Even in a fashion that happens in trunk...
Yes, I played it yesterday for the first time and I thougth passengers would remain on the train, but they didn't. Perhaps a bug? Or do you need larger networks? (I have only one line yet with 3 stations)
I will continue playing for a bit and see if anyhthing changes. ;-)

EDIT: Ok, my fault, I guess the network wasn't updated yet.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

yes, there are some strange effects when you open new lines...
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Cargo Distribution

Post by Zuu »

I played a game using gcbd15085-cd. In this game it happened more than once that I got stale cargo at a station when I inserted a new station into the shared orders of an existing route/connection. This cargo never age or disappear. It just sit there with "to any station".

Here is one such station with stale cargo:
Österberg Transport, 2nd Sep 1982.png
Österberg Transport, 2nd Sep 1982.png (137.16 KiB) Viewed 406 times
The via-station for the stale cargo is the only target station for livestock and wheat ever in this game:
Österberg Transport, 2nd Sep 1982#1.png
Österberg Transport, 2nd Sep 1982#1.png (172.64 KiB) Viewed 406 times
Earlier livestock and wheat from another farm was sent via ship here. Later I gave that farm a direct rail connection instead of transporting with ship here and then rail to the food processing plant. The stale cargo can have ended up here due to that. But it can also have ended up stale here because I have inserted a stop between Gnädhammar Docks (where the stale cargo is) and the food processing plant where trains can pick up additional goods from two farms on the way to the final destination.


Another problem I first though was that I had stale connections and new connections that didn't was detected. I later realized that this was not a bug. It was just that I couldn't see dark green on green background on my screen. So more contrast between the degree of saturation colour and the background would be useful.

One question, does "saturated" in the scale means that [planned flow]/[capacity] = 1?
Attachments
Cargodist.sav
My cargodist game. Uses NewGRFs from bananas and #openttdcoop GRF pack
(175.26 KiB) Downloaded 29 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

For reference, my last game, though far from finished. I'm annoyed with it and stopping the play on that one, I started servicing too many iron ore and coal industries and pumping up their output. I can't reasonably increase capacity on the main lines anymore.

Code: Select all

Cargo Distribution version: gd4255b61
Newgrfs:
- AV8 2.11
- Basecosts 3.2.1
- Chips 1.0.0
- FIRS 0.7.5
- eGRVTS v1.0
- FISH 0.9.2
- ISR v0.8.1
- NuTracks 1.1.2
- 2CC V2.0.0 Beta 5
- Rock Replacement for Transmitter
- TTRS 3.13
- TBRS 1.12
Wow, there are some old newgrfs, I definitely have to update some of them for my next game.

For the new game I'm thinking about starting a passenger only game then, starting with only small villages to make it possible to build manageable networks. Important are the 2cc metro's, trams and buses with enough capacity. I however also think about using the new and improved Dutch trainset, maybe that set has capable metro's as well.
Attachments
Flondbourne Transport, 1953-08-19.sav
(279.44 KiB) Downloaded 28 times
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

It seems I've broken the rerouting on link drop. I'll check that.
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Indeed the rerouting is broken. This patch fixes it:

Code: Select all

diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 3001c12..6c027f8 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3385,14 +3385,14 @@ void DeleteStaleLinks(Station *from)
                        Station *to = Station::GetIfValid(it->first);
                        if (to == NULL) continue;
                        if (to->goods[c].link_graph != ge.link_graph) {
-                               ge.cargo.Reroute(UINT_MAX, &ge.cargo, from->index, to->index, &ge);
+                               ge.cargo.Reroute(UINT_MAX, &ge.cargo, to->index, from->index, &ge);
                        } else {
                                Edge edge = (*lg)[ge.node][to->goods[c].node];
                                if (edge.LastUpdate() == INVALID_DATE ||
                                                (uint)(_date - edge.LastUpdate()) > LinkGraph::MIN_TIMEOUT_DISTANCE +
                                                (DistanceManhattan(from->xy, to->xy) >> 2)) {
                                        (*lg)[ge.node].RemoveEdge(to->goods[c].node);
-                                       ge.cargo.Reroute(UINT_MAX, &ge.cargo, from->index, to->index, &ge);
+                                       ge.cargo.Reroute(UINT_MAX, &ge.cargo, to->index, from->index, &ge);
                                }
                        }
                }
However, the current version does the rerouting different. If you load the game with a version newer than gcbd15085-cd it won't work with your current game because the cargo is directly rerouted when the link disappears and the links are iterated instead of the cargo destinations. There is no checking for stale cargo anymore. If you apply the patch to gcbd15085-cd the cargo in your current game will correctly be rerouted the next time you load it.
The guy on the picture is not me, it's Alonso.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

I'll grab tonight's binary and start a new game tomorrow.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: Cargo Distribution

Post by aantono »

I know that what I'm about to ask is a stretch (at least on this topic), but how hard would it be to add the support (integrate an advanced orders patch) into CargoDist? With the amazing new functionality that CargoDist provides, it would merry up nicely with the ability to be able to control how much cargo is to load on vehicles (if your industry only needs 5 tons of industrial supply [playing with FIRS or ECS] and it is year 2000, you just don't have a truck that small).

I'm attaching a patch that I've found elsewhere on this forum, which could be used/applied. (http://www.tt-forums.net/viewtopic.php?f=33&t=12193) I wish I was familiar with C/C++ to be able to contribute myself, but unfortunately it is not my forte. :(
Attachments
additionalorders.r2235.patch
(54.43 KiB) Downloaded 28 times
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Having additional orders would further complicate the hairy issues with order modifications not being properly reflected in the link graph and cargodist planning an impossible distribution for cargo. I certainly won't add more order modifications to cargodist.
The guy on the picture is not me, it's Alonso.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: Cargo Distribution

Post by aantono »

Thanks for the prompt reply and an explanation. I definitely understand the desire to keep things as simple as possible (computing so much dynamic data, as you already do, is by no means an easy/simple task)! I am not sure exactly how the link loads/capacities are derived, so I could be completely wrong in my assumptions here - what I was thinking is if we allow to specify in order how much of cargo to load onto a vehicle (say vehicle capacity is 50t and we say load 20t of industrial supplies), then you will see the link capacity be not 50t as the capacity of the vehicle dictates, but rather 20t as defined per the loadable order condition.

Also, many use manual control for non passenger/mail cargoes, so the CargoDist algorithms don't have to work so hard for those cargo types.

But those are just my thoughts, and I totally understand if the reality of implementation is a lot more difficult than it seems from my naive point of understanding, and falls out of scope of the effort. :)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 12 guests