Solution to inserters getting stuck loading cargo wagons

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

TLDR: In the situation where a train cargo wagon has stack filters to allow a set amount of each resource to be loaded on to it, inserters can become stuck if more than one is loading the cargo wagon. I have seen other posts describing this problem as a bug, but it seems that this is intended behavior. I think a good solution to this problem would be to allow the inserters to place the resource back into the chest(if there is room), and then continue loading the train with other resources.

The easiest way I can think to explain this is using an example.

Example:
Actors:
1 cargo wagon
2 chests
2 inserters

Suppose the cargo wagon has stack filters set such that it can only be loaded with 200 iron and 50 copper. The two chests are filled with copper and iron and then loaded on to the cargo wagon using the two inserters. You would expect the two inserters to load both copper and iron until the cargo wagon is full. What happens however is that the two inserters start out loading copper, but on the last copper item both inserters pick up copper from their respective chests. Only one can load the copper onto the cargo wagon. While the inserter that got to load the last copper gets to move on to loading iron, the other inserter is stuck holding the copper and does not move on to loading iron.

Solution 1: Put all of the copper in one chest and all of the iron in the other chest.
Drawback: You need a chest and inserter per resource which limits you to 24 different resources. This isn't a show stopper, however it is inconvenient if you wanted multiple trains with their own set of stack filters to be able to stop at the same train stop. In addition, the more unique resources, the slower cargo wagons are loaded.


Proposed solution: Add a feature to allow the stalled inserter to place the copper back into the chest and then start loading iron.
Drawback: if the chests are being constantly filled by another inserter than there is a chance that between picking up an item and putting it back in the chest, the chest may become full. In this situation the inserter will be stuck again. The user must prevent the chests from ever becoming completely full if they want to load cargo wagons in this way.

User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by thereaverofdarkness »

I don't think this is a good idea.

If you're trying to load more than 24 item types into a train, you can put some of them in one chest and other types in another chest. You never have to put one item type in more than one chest. If you're trying to load a lot of one item type and small amounts of others, I would recommend putting the bulk items into a separate car from the assorted items. But you can link 12 chests to one car (24 with some extra belts) so there's always a way to sort things out and not have to have stuck inserters.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

Oh you're right you can have one box with multiple items in it. My statement would be more accurate if I said multiple chests cant share any resource types unless there is only one resource.

I should probably explain what I want to do to show why i think this is a good idea. I am trying to make a single train stop that is capable of loading/unloading any train that stops at it. I don't want to modify the loading station every time I add a new train that needs a new set of resources. I already have it working, but because of this constraint, many of the trains take longer to load than they would otherwise have to take. If resources could be evenly distributed across all of the chests than all of the inserters could be used at the same time in order to load every train. Instead however, only a small subset of the inserters are used for each cargo wagon.

Maybe a more technical solution to the problem would be better. One way I can think of is to make there two values associated with every resource in the cargo wagon, a pending value and a actual value. When an inserter starts to place a new resource into the cargo wagon, it increments the pending value in an atomic operation. When the inserter finishes placing the resource in the cargo wagon, the actual value is incremented. Before an inserter starts to place a resource into the cargo wagon, it checks the pending value to see if there is room for the particular resource. Then they will never get locked up.

User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by thereaverofdarkness »

What you can do to unload any train is to have the inserters unload into passive provider chests, and have requester chests already placed in the base requesting high numbers of all the items you plan to send over. Then you just make sure you have logistics robot coverage far enough to transfer items between the chests. It'll jam up when any item type's requests fill up, but until then it'll draw automatically without you being present.

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by SyncViews »

Yes for mixed goods unloading into provider chests is useful. I dont see the point of making the requester chest request more than it needs though, the bots can bring over as needed and Id sooner only buffer a given item in 1 place.
Maybe if I could have a "low priority" requester chest that construction bots etc. could use to build faster (than flying across the base to storage / passive), but never made that work well :(


Unloading you can do with circuits to have less chests / slightly easier config. attach a arithmetic combinator to the the chest on "EACH = EACH * -1", a constant combinator with the desired levels and a filter inserter (filter inserter takes the first N signals greater than 0).

But I do think its a shame you cant easily load cargo, with one chest/inserter, or unload with a filtered chest (especially since unmodded stack filter inserters only have 1 filter, and normal filter inserters are slow).

User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by thereaverofdarkness »

If you just want to unload whatever is on the train and not bother sorting it, you can unload it into active provider chests and just have storage chests in your logistic network.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

For unloading my approach was to use filter inserters combined with circuit network similar to what SyncViews said. Loading is the part I am running into issues with.

Say I have two trains, one has stack filters to allow only iron to be loaded, and one has stack filters to allow only copper to be loaded. At my loading station I would like to be able to have 12 requester chests that request 100 copper and 100 iron and then when either train arrives at the station the 12 inserters start loading copper or iron depending on which train has arrived. What I have to do because of this inserter dead-lock problem is make 6 requester chests for iron and 6 requester chests for copper. This makes it take twice as long to load each train. To make matters worse, I want it to work with more than just two resources which makes loading even slower.

I know fixing this deadlock situation would solve my problem, but I haven't thought of any work around just yet.

dragontamer5788
Fast Inserter
Fast Inserter
Posts: 154
Joined: Fri Jul 15, 2016 1:44 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by dragontamer5788 »

Or maybe you can just use circuits to solve the problem: viewtopic.php?f=194&t=46791

This technique works in vanilla for trains of size 1. I have come across issues for larger trains... but I'm using a different methodology and I'm confident I can solve the problem for 1-2 trains (A bit of pulse-mode counting + Deciders being used as memory cells, looking at Yellow-light off of signals to determine when to reset).

Its not UPS optimized, but those UPS-limited megabases have problems of their own. Lol. But yeah, I think this "problem" should remain, since it is solved by only ~6 combinators or so.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

Does this work if the cargo wagon has stack filters to allow for more than 1 resource?

Also in my situation my trains are 2 cargo wagons long. One cargo wagon is loaded while the other is unloaded. Will this still work?

dragontamer5788
Fast Inserter
Fast Inserter
Posts: 154
Joined: Fri Jul 15, 2016 1:44 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by dragontamer5788 »

astrojack00 wrote:Does this work if the cargo wagon has stack filters to allow for more than 1 resource?
I don't really know why you'd use stack filters to load a wagon, because cargo-wagons have filters if you just middle-click on the contents (just like your toolbelt). So... I'm not really sure how to answer your question aside from maybe... use the built-in filter mechanism in cargo wagons?

My solution above only uses standard stack-inserters. I don't need any filter inserters to get the job done.
Also in my situation my trains are 2 cargo wagons long. One cargo wagon is loaded while the other is unloaded. Will this still work?
My version 2.0 method, which is under development right now, would work in that case. I've got a few kinks to work out, but the pulse-mode counting while loading a cargo-wagon definitely works for mixed loading of cargo wagons.

In any case, the pulse-mode counting methodology simply counts the number of items loaded into each wagon, turns off eleven of the inserters at "132 remaining" and then sets the stack-override on the final 12th inserter to be the number of items remaining. There's a lot you can do with combinators... they're even Turing complete and provably can perform any function any computer can do (with enough combinators of course). There are a few timing issues and other stuff that prevents some very complicated stuff... but cargo-wagon counting should be feasible in 0.15 thanks to all of the features added.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

I don't really know why you'd use stack filters to load a wagon, because cargo-wagons have filters if you just middle-click on the contents (just like your toolbelt).
Thats what a stack filter is. https://wiki.factorio.com/Cargo_wagon

Im not sure if I am following the pulse counting method. How do you know how much of each resource needs to be loaded onto the cargo wagon? And what if the wagon already has some resources left over from the last time it was loaded?

dragontamer5788
Fast Inserter
Fast Inserter
Posts: 154
Joined: Fri Jul 15, 2016 1:44 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by dragontamer5788 »

astrojack00 wrote:
I don't really know why you'd use stack filters to load a wagon, because cargo-wagons have filters if you just middle-click on the contents (just like your toolbelt).
Thats what a stack filter is. https://wiki.factorio.com/Cargo_wagon
Lulz. I thought you were talking about this: https://wiki.factorio.com/index.php?tit ... r_inserter
Im not sure if I am following the pulse counting method. How do you know how much of each resource needs to be loaded onto the cargo wagon? And what if the wagon already has some resources left over from the last time it was loaded?
The answer to question #1 is simple: standardize the number of items you load onto a wagon at any given station. As long as all the various items served by a station have the same stack-sizes, my circuit-methodology works.

#2 is also simple: empty the wagon before pulling it into this station.

The vast majority of my trains run on "Wait until full" and "Wait until empty". Occasionally, I'd make a dedicated waiting bay where some trains wait for a specific circuit condition before leaving the "Train-stop waiting bay", but this is a relatively rare situation.

I dunno why you'd want to ever return a train back to pickup items before it was empty. Train networks get congested in larger bases, so you want to minimize traffic, and instead leave trains around waiting bays (off the main roads) or "parked" with inserters pulling from them.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

The answer to question #1 is simple: standardize the number of items you load onto a wagon at any given station. As long as all the various items served by a station have the same stack-sizes, my circuit-methodology works.
Ah thats what I am trying to avoid. I want a general solution that works for all trains with any set of stack filters.
I dunno why you'd want to ever return a train back to pickup items before it was empty.
I can think of a situation. Suppose you have a factory that transforms iron and copper plates into copper wires, and electric circuits. If you have a train delivering metal plates and copper to the factory than it is inevitable that the train will either run out of iron or copper first. If the train is set to wait until it is empty than it will never leave because in order to consume the rest of the iron, it will need additional copper(or vice versa). The train must go back home to fill up on more resources. You can add any number of chests to store the unloaded cargo at the factory, but eventually you would end up with a large surplus of one of the resources that would back up to the train.

dragontamer5788
Fast Inserter
Fast Inserter
Posts: 154
Joined: Fri Jul 15, 2016 1:44 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by dragontamer5788 »

astrojack00 wrote:
The answer to question #1 is simple: standardize the number of items you load onto a wagon at any given station. As long as all the various items served by a station have the same stack-sizes, my circuit-methodology works.
Ah thats what I am trying to avoid. I want a general solution that works for all trains with any set of stack filters.
It looks like a planned feature is to give all trains unique ID numbers to be output from the Train Station. So you'd know which trains were passing buy through the circuit network. You might have to wait till that version is released to get what you want.
I dunno why you'd want to ever return a train back to pickup items before it was empty.
I can think of a situation. Suppose you have a factory that transforms iron and copper plates into copper wires, and electric circuits. If you have a train delivering metal plates and copper to the factory than it is inevitable that the train will either run out of iron or copper first. If the train is set to wait until it is empty than it will never leave because in order to consume the rest of the iron, it will need additional copper(or vice versa). The train must go back home to fill up on more resources. You can add any number of chests to store the unloaded cargo at the factory, but eventually you would end up with a large surplus of one of the resources that would back up to the train.
Hmm, I'd just use two trains with two train-stations, because reducing train traffic is a huge priority in the endgame. Train stations take up space, but space is infinite. Any solution that incurs unnecessary traffic seems suboptimal to me...

Because if the train runs out of iron, then the iron train can go back (and the copper train can remain in the dedicated copper-waiting area or copper-station), thereby reducing traffic.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

Hmm, I'd just use two trains with two train-stations, because reducing train traffic is a huge priority in the endgame. Train stations take up space, but space is infinite. Any solution that incurs unnecessary traffic seems suboptimal to me...
I prefer to have one train that leaves when either resource is empty.

User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by thereaverofdarkness »

Perhaps we need a Requester Wagon--a train wagon that acts like a requester chest.

astrojack00
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat May 06, 2017 9:57 pm
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by astrojack00 »

If anyone is interested, I found a solution that is pretty simple. Just have one filter inserter connected to all the other inserters with circuit network and configure it to read the contents that the other inserters are holding. Then set the filters of the filter inserter to that signal. Force the filter inserter to only move 1 item at a time. Then the filter inserter will unload the items 1 by 1 until the cargo wagon is exactly filled and all of the inserters are no longer stuck holding an item. There is some additional circuitry you can add to make it so the filter inserter only starts unloading when the other inserters are stuck, but it isn't necessary.

I still thing they should make the inserters a little smarter in this regard but I guess a lot of people see it as a challenge so meh just my opinion.

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by Aeternus »

Reading all this, isn't the issue just how inserters work, and not related to trains at all? Inserters that have more then one item on their hand have to be able to drop off their entire batch before starting a new movement action. If the dropoff point cannot handle this (or in the case of trains moves away), the excess content is stuck on the arm until there is room, and the inserter will not be able to move anything else. In most cases this isn't an issue, but for inserters moving multiple cargo types in bulk, it becomes a problem. Since inserters can't figure out if the stack they grab will fit on the container it is being moved to, the player will have to use the circuit network to check for that - disable extra inserters and set the stack size appropriately to top off a wagon or chest.

User avatar
BLuehasia
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Tue Dec 30, 2014 2:13 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by BLuehasia »

what i dont get is why they cant unload the extra bit into the blocked off zone of the wagon, bots carrying extra items will over fill into the blocked off parts of a chest so why not inserters. it would solve alot.

see the image. so much space to dump that little bit of extra space

https://prnt.sc/fd6khq

User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: Solution to inserters getting stuck loading cargo wagons

Post by thereaverofdarkness »

It doesn't seem that difficult to use separate inserters for different item types. If you're really trying to squeeze tiny amounts of many kinds of items onto one train wagon and you simply can't be bothered to extend the train and use more cargo wagons, then you can use logistics bots to load the train, or you can combine inserters and logistic bots. You can also make inserters work with multiple item types if you have only one inserter per item type.

For instance, you could load a cargo wagon with 1 stack regular magazines, 1 stack piercing magazines, 1 stack uranium magazines, and 10 stacks iron plates. You could have 3 inserters dedicated to putting iron plates on, and 1 inserter putting in the ammunition. Then you have 8 inserter positions remaining to fill the rest of the train.

If you want to change what you're putting on the train without going to the pickup facility, then you can change the cargo wagon's filters but if that's not enough, maybe you should consider taking one trip to change it when you realize the train isn't properly calibrated for your needs, or make a larger train for a long-term solution. I generally have trains move intermediate products, primarily just plates, gear wheels, or circuits. I can use those to make more complex things on-site. If it's more assemblers I need, it takes just a few seconds to craft a stack if I have the gear wheels and circuits already in inventory.

Post Reply

Return to “Ideas and Suggestions”