LTN sometimes sends deliveries to stations that don't request them

Adds new train stops forming a highly configurable logistic network.

Moderator: Optera

Post Reply
DeadMG
Burner Inserter
Burner Inserter
Posts: 16
Joined: Thu Oct 22, 2020 7:56 am
Contact:

LTN sometimes sends deliveries to stations that don't request them

Post by DeadMG »

**Error message or bug description**
LTN sometimes sends more trains than a station needs. This causes cargo to be left over.

**To Reproduce**
Observed with the following sequence (note that this stop has a maximum trains of 1).

1. A train supplies 8000 iron plates.
2. The requester asks for slightly more than this, say, 10000 iron plates.
3. The train arrives.
4. LTN calculates a new request value, say, 2000 iron plates.
5. LTN queues a request for this value.
6. The existing 8000 iron plates are unloaded, and in response, the circuit network attached changes the request value to zero.
7. LTN queues a delivery of 2000 iron plates after the train is emptied, and left, even though the requested value is zero.
8. This causes the station to not unload all the cargo, creating a Mess.

**LTN version**
1.16.7

**Log file**
[factorio-previous.log](https://github.com/Yousei9/Logistic-Tra ... evious.log)
I performed some testing with the Carrick Greenmere station. There's a log entry about resetting train signals, but this doesn't seem to reconsider requests.

The broader context is that the "request threshold" signal did not work for me in practice because to avoid leftover cargo in the train, each wagon must be considered individually. If you need more than 8000 iron plates but each wagon is connected to separate belts and only one can unload, the other wagon has cargo left over. Therefore I created a circuit network to apply my own request threshold which considers each wagon individually and only requests when all wagons can be unloaded. This works completely fine except in the above case where recalculating the request value does not work as expected. It's not clear how to fix this in the circuit network either as although you can read out the train contents from the stop, the logic must be applied per wagon, rather than per train, and the circuit network can't read out the contents of each wagon, so you don't know whether all wagons can unload or not.

The expected behaviour is that regardless of what circuit-network shenanigannery I might implement to decide the requested value, this may depend on having finished unloading the previous train first, so LTN should not decide future deliveries until after the train is unloaded and the new circuit signals received. I guess that there is some problem with arbitrary circuit networks taking arbitrary time to update, but some small threshold like 10-20 ticks should cover virtually all networks in practice? Alternatively, you could simply determine that stations which can't unload all wagons evenly are simply not supported, which would certainly make quite a few things simpler, but this is not something I found documented or mentioned in tutorials.

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: LTN sometimes sends deliveries to stations that don't request them

Post by robot256 »

The "update frequency" and "updates per tick" mod settings control how frequently LTN reads the signals provided to a stop. Your can try reducing this time for faster response to your dynamic request threshold and slower game performance.

I have actually done the same thing (dynamically change LTN signals when one wagon would not be able to unload). Instead of changing the request threshold, I set the item request to -128k ore (1.5 trains) when there was space, and 0 when one wagon would be blocked. The request threshold was fixed at 72k (one train), and train limit set to 2. The station has buffers for 4 trains with of material.

Unbalanced unloading (and loading) causes problems for vanilla train systems, not just LTN, so it's pretty much taken for granted that some effort to balance will be made. That is the number one issue you need to fix. There are lots of solutions, including ones using circuit networks.

Trains will wait in the LTN depot as long as needed to empty items that were not fully unloaded, so they are empty for the next run. Just add an inserter and active provider to every wagon on every track. This is my backup system, and it does get used now and then. LTN Manager is a good way to keep track of it.

If you still need a way to read the contents of individual wagons, Inventory Sensor can do it.

Post Reply

Return to “Logistic Train Network”