News: Portal
Our Simutrans site. You can find everything about Simutrans from here.

Some small producers fail to deliver goods to the stations

Started by Octavius, June 12, 2022, 12:55:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


This happens on a the version I updated and compiled today, but it has been present for longer and I took some time to investigate this.

The issue is that some producers (arable farms and cattle farms on my map, playing around the year 1810) may fail to deliver goods (vegetables and livestock in this case), even when consumers of those goods run out of stock. It's not that max_transit has been reached, as some arable farms and sheep farms (sheep farms have a higher production of livestock than cattle farms, which may be relevant) continue delivery of the same goods and indeed max_transit as reported in the consumer's infobox (but there is an inconsistency between the max_transit reported there and the one reported under connections for the producer) hasn't been reached and the max_transit as reported by the consumer matches the consumption multiplied by the reported lead time.

But there definitely is a dependency on max_transit. Initially this issue appeared on both livestock and vegetable deliveries on my map. Some arable farms never delivered anything and neither did the cattle farms, so that the first market connected always ran out of vegetables and the slaughterhouse ran out of livestock (and consequently the market out of meat). But after I connected a second market for delivery of vegetables, the issue disappeared for the arable farms. They all started regular deliveries. I can't say for sure they all started deliveries to both markets. The markets still occasionally ran out of vegetables, because the production of all arable farms combined was less than consumption of the markets combined.

After a while however I noticed that my line of wagons moving vegetables from some of the farms to the market (and from there by narrowboat to the other market) didn't have enough capacity. Boxes of vegetables remained at one of the pickup stations for a long time, until capacity of the pickup station was reached, inflating lead time. Lead time increased to over 100 hours, although actual travel time after pickup was only about 25 hours. The max_transit appears based on the lead time of the slowest delivering supplier (that's what I get from the source code), so this inflated lead time leads to an inflated max_transit, which could never be fulfilled as storage capacity at stations was too small and at most stations pickup was pretty fast.

When I increased capacity of the line of wagons, the lead time dropped a lot, so did the max_transit and some arable farms again stopped delivery. So it appears that the issue disappears when max_transit is much larger than in_transit (or max_transit+max-(transit+stored) is much larger than 0). Also, I've only seen it happen for small producers, producing less than 1 unit per month.

I've been wondering whether this might be some rounding issue. Looking into the source code, it appears there's a lot of scaling going on between the numbers shown to the user and those used internally, I assume to prevent such rounding errors, but maybe something goes wrong there.

Another interesting observation is that the issue disappeared the moment I set just_in_time to 0. When I changed just_in_time back to 1 (or 2, 3, 4), the issue reappeared for the cattle farms, although not for the arable farms. But they haven't fully stabilised yet.

In the screenshot you can see a slaughterhouse with in_transit showing as 6/48, so it should order new livestock. One of the sheep farms, which reports the slaughterhouse's in_transit as 6/6, makes regular deliveries, but the cattle farm, also showing 6/6, has full stock and never delivers anything. I can't see anything regular in the inconsistent max_transits. An arable farm reports its consumers at in_transits of 4/13 and 31/31, whilst those markets themselves report 4/18 and 31/63. Maybe this inconsistency is related.

Edit: One of the cattle farms, the one at (473,65), makes occasional deliveries, but it still delivers less than it should. And for some reason, delivered, produced and the changes in stock don't add up at this farm.


Thank you for the report. I am struggling to understand the problem precisely enough to reproduce it. You refer to there being occasions when the consumer industries run out of raw materials - but the slaughter-house at 394,51 in the uploaded saved game never runs out of materials. Is the saved game after you made changes that fixed the problem? If so, I will need a saved game where the problem can in fact reliably be reproduced at a specific industry in order to try to fix this. Ultimately, I will need precise instructions on how to reproduce a very specific issue at a very specific location in a specific saved game.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.


This is exactly the game where the slaughterhouse doesn't get the livestock it needs. I let it run for a bit longer now (no changes) and attached a new screenshot and save. The slaughterhouse gets about 7 units of livestock per month, only from the sheep farms, which is insufficient. The cattle farms don't send any livestock there,1 although they are fully stocked and connected. And you can see the in_transit at 3/78, which should trigger sending some more units of livestock to my stations. With just_in_time set to 1 and stock at 0/4, the farms should submit livestock until I have 82 in transit.

The higher deliveries about a year ago were during an experiment when I had set just_in_time to 0. During that experiment cattle farms were behaving as expected. The experiment was inspired by line 2602 in, which tells that the distribution of goods is different when just_in_time!=0. I suspect the error is caused in that part of code or in some function called from there, but I have some difficulty understanding what exactly is going on. Maybe there's a problem with needed or needed_base_units as calculated a few line above there.

The arable farms, which showed the same problem, appear fixed for the moment. I thought a description of their behaviour may provide a lead to where the problem is located. When needed is large enough, it all works, but when it gets close to zero, deliveries stop. This suggests this is a rounding-to-zero error.

In case it matters, I downloaded and compiled the program and pakset today around 11:20 UTC and run it on Ubuntu 21.10.

So, none of the cattle farms connected to the slaughterhouse at (394,51) deliver livestock, although at the slaughterhouse stock is 0/4 and in_transit is 3/78.

1: The cattle farm at (473,65) is behaving a bit strange. In the past 12 months it produced 1 unit of livestock and it actually delivered 2 units, the only cattle farm delivering, yet its stock increased from 1 to 4. I don't know if this is a related issue. If unrelated, it's less important.