Encoded Network ID, how does it work?

Adds new train stops forming a highly configurable logistic network.

Moderator: Optera

Blokus
Fast Inserter
Fast Inserter
Posts: 246
Joined: Tue Mar 05, 2019 2:49 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by Blokus »

DaleStan wrote:
Mon Apr 08, 2019 12:30 am
I don't have much experience with LTN networks, but this is what I've gathered:

I believe the design purpose is to use networks to tell LTN which stations are connected. If trains from Depot 1 might attempt to deliver cargo from Provider 2 to Requester 3, and you want to prevent this (either to reduce congestion, or because there's no path), make sure there's no network bit shared by all three stations.

You typically don't need to have separate networks for iron and copper; no train is going to attempt to deliver iron ore to a copper requester or vice versa. The only reason I can come up with for this is if you want to reserve these two trains for copper only, and those two trains for iron only. You'd also have to put the trains in depots with different names and different network IDs. (Unless the train lengths are different; then you can use the train-length filters.)

If you don't want trains to load at "Iron Mine East 3" and then unload at "Iron Smelting West 2", then you probably want to set up two networks, and put the East and West stations on separate networks. You could then have one depot set to network -1 and serve both sides, or you could have East Depot and West Depot with separate networks.
If you have non-overlapping minimum and maximum train lengths (maybe you use only 2-4 trains on the west side, and only 3-6 on the east side) you can use that to control which trains go where, in either a shared-depot (instead of network ID) or split depot (possibly with network ID) arrangement.
Barrels are the best example. In my base, there's a station that requests empty barrels all the time, and then it gives them back to the network (without doing anything with them) at a provider station. The provider is connected to the requester by belts, and the two are on different networks. They have to be on different networks otherwise trains would constantly be dispatched to move them back from the provider to the requester. Most of the stops in my base are on both of those networks at once, so they can both give barrels back to and receive them from the central storage. If you don't have central storage like this, then you need to do more complicated shenanigans to force LTN to take barrels away from builds that are starting to run out of storage for barrels (e.g. dynamically set the provide priority based on how close a build's barrel storage is to being full).

MCDewy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Thu Sep 13, 2018 3:36 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by MCDewy »

Here is what I am doing, (Against Optera's advice!)

I am overly cautious with not wanting to pollute resource lines. So I have assigned allot of the major resources to their own network, with their own depot. That way, Coal Trains only ever pick up from and deliver to coal stations in the coal network.

The advice or use case that was explained to me was when you want to keep trains in a specific "region" of your map, you can assign that region a network ID and your trains should stay there and not travel across the map to get something. (At least I think that was how it was explained).

Example spreadsheet and picture of my depots here:

Image

Image

The fuel network for example, I added a binary 4 to the decimal number: 2097152 becomes 2097156. The fuel depot is 2097152, and the coal providers are 2097156, (Fuel + Coal network which is 4). This allows my fuel trains to go to a coal provider and get coal to fuel the depots. Meanwhile, coal trains in the 4 network get coal from the providers and then deliver to, (for example my steam generators), coal requesters.

I did this mainly because I have problems with trains returning to the depot with cargo still in them. So using the default network for everything results in SOMETIMES getting cargo mixed up. (This is due to errors on my part resulting in missed delivery's, like no path errors, or timeouts because a traffic jam or something).

Its bad because it defeats the purpose of LTN. I have trains just sitting there in depots not contributing, I also have LOTS of trains to do this. I could have one depot with 20- trains and be just fine, but I have 7-10 depots with 10-20 trains each.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Encoded Network ID, how does it work?

Post by Optera »

MCDewy wrote:
Sat Jun 15, 2019 12:10 am
Here is what I am doing, (Against Optera's advice!)

I am overly cautious with not wanting to pollute resource lines. So I have assigned allot of the major resources to their own network, with their own depot. That way, Coal Trains only ever pick up from and deliver to coal stations in the coal network.

Its bad because it defeats the purpose of LTN. I have trains just sitting there in depots not contributing, I also have LOTS of trains to do this. I could have one depot with 20- trains and be just fine, but I have 7-10 depots with 10-20 trains each.
Like you figured out yourself, this configuration removes the ability to maximize train usage, the main reason to use LTN.
MCDewy wrote:
Sat Jun 15, 2019 12:10 am
The advice or use case that was explained to me was when you want to keep trains in a specific "region" of your map, you can assign that region a network ID and your trains should stay there and not travel across the map to get something. (At least I think that was how it was explained).
Yes, that's what Network ID is for.
MCDewy wrote:
Sat Jun 15, 2019 12:10 am
I did this mainly because I have problems with trains returning to the depot with cargo still in them. So using the default network for everything results in SOMETIMES getting cargo mixed up. (This is due to errors on my part resulting in missed delivery's, like no path errors, or timeouts because a traffic jam or something).
Broken record: Use smart stations and the locked slots signal for stations providing more than 1 item.

MCDewy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Thu Sep 13, 2018 3:36 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by MCDewy »

Optera wrote:Broken record: Use smart stations and the locked slots signal for stations providing more than 1 item.
It's my fault. I had a hard time getting the numbers right for requests. This led to trains going to stations to deliver that could not take the whole train full of material, so the train would eventually time out and go back to the depot with stuff still in it.

mrvn
Smart Inserter
Smart Inserter
Posts: 5683
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Encoded Network ID, how does it work?

Post by mrvn »

MCDewy wrote:
Sat Jun 15, 2019 10:50 pm
Optera wrote:Broken record: Use smart stations and the locked slots signal for stations providing more than 1 item.
It's my fault. I had a hard time getting the numbers right for requests. This led to trains going to stations to deliver that could not take the whole train full of material, so the train would eventually time out and go back to the depot with stuff still in it.
I've switched off that timeout for good now in the mod settings. It's far better to have the train stuck at a station than spread the wrong goods all over the map. Even better would be a timeout for loading but not unloading.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Encoded Network ID, how does it work?

Post by Optera »

mrvn wrote:
Sun Jun 16, 2019 9:19 am
MCDewy wrote:
Sat Jun 15, 2019 10:50 pm
Optera wrote:Broken record: Use smart stations and the locked slots signal for stations providing more than 1 item.
It's my fault. I had a hard time getting the numbers right for requests. This led to trains going to stations to deliver that could not take the whole train full of material, so the train would eventually time out and go back to the depot with stuff still in it.
I've switched off that timeout for good now in the mod settings. It's far better to have the train stuck at a station than spread the wrong goods all over the map. Even better would be a timeout for loading but not unloading.
Again I'm feeling like a broken record:
- enable Circuit Conditions
- add the following circuit: arithmetic combinator: current inventory (from stop) - expected inventory (from LTN output) >> decider combinator: anything > 0 red = 1 >> train stop

Done, that train will never leave if it has a single piece loaded incorrect even with stop timeout active.

mrvn
Smart Inserter
Smart Inserter
Posts: 5683
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Encoded Network ID, how does it work?

Post by mrvn »

Optera wrote:
Sun Jun 16, 2019 9:25 am
mrvn wrote:
Sun Jun 16, 2019 9:19 am
MCDewy wrote:
Sat Jun 15, 2019 10:50 pm
Optera wrote:Broken record: Use smart stations and the locked slots signal for stations providing more than 1 item.
It's my fault. I had a hard time getting the numbers right for requests. This led to trains going to stations to deliver that could not take the whole train full of material, so the train would eventually time out and go back to the depot with stuff still in it.
I've switched off that timeout for good now in the mod settings. It's far better to have the train stuck at a station than spread the wrong goods all over the map. Even better would be a timeout for loading but not unloading.
Again I'm feeling like a broken record:
- enable Circuit Conditions
- add the following circuit: arithmetic combinator: current inventory (from stop) - expected inventory (from LTN output) >> decider combinator: anything > 0 red = 1 >> train stop

Done, that train will never leave if it has a single piece loaded incorrect even with stop timeout active.
Careful, that doesn't work with requested fluids as the expected inventory is -1 and the circuit would remain at red=1even when empty. And if it weren't -1 then it would have the rounding down to 0 problem to take care about. It's not as simple as you make it seem.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Encoded Network ID, how does it work?

Post by Optera »

mrvn wrote:
Mon Jun 17, 2019 9:16 am
Optera wrote:
Sun Jun 16, 2019 9:25 am
mrvn wrote:
Sun Jun 16, 2019 9:19 am
MCDewy wrote:
Sat Jun 15, 2019 10:50 pm
Optera wrote:Broken record: Use smart stations and the locked slots signal for stations providing more than 1 item.
It's my fault. I had a hard time getting the numbers right for requests. This led to trains going to stations to deliver that could not take the whole train full of material, so the train would eventually time out and go back to the depot with stuff still in it.
I've switched off that timeout for good now in the mod settings. It's far better to have the train stuck at a station than spread the wrong goods all over the map. Even better would be a timeout for loading but not unloading.
Again I'm feeling like a broken record:
- enable Circuit Conditions
- add the following circuit: arithmetic combinator: current inventory (from stop) - expected inventory (from LTN output) >> decider combinator: anything > 0 red = 1 >> train stop

Done, that train will never leave if it has a single piece loaded incorrect even with stop timeout active.
Careful, that doesn't work with requested fluids as the expected inventory is -1 and the circuit would remain at red=1even when empty. And if it weren't -1 then it would have the rounding down to 0 problem to take care about. It's not as simple as you make it seem.
I told you back when you wanted this special treatment for fluids it would require filtering out fluid signals from unloading circuitry.
https://github.com/Yousei9/Logistic-Tra ... -468930351

However a signal filter can be made with 3 combinators. So no big deal.

mrvn
Smart Inserter
Smart Inserter
Posts: 5683
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Encoded Network ID, how does it work?

Post by mrvn »

Optera wrote:
Mon Jun 17, 2019 9:55 am
mrvn wrote:
Mon Jun 17, 2019 9:16 am
Optera wrote:
Sun Jun 16, 2019 9:25 am
mrvn wrote:
Sun Jun 16, 2019 9:19 am
MCDewy wrote:
Sat Jun 15, 2019 10:50 pm


It's my fault. I had a hard time getting the numbers right for requests. This led to trains going to stations to deliver that could not take the whole train full of material, so the train would eventually time out and go back to the depot with stuff still in it.
I've switched off that timeout for good now in the mod settings. It's far better to have the train stuck at a station than spread the wrong goods all over the map. Even better would be a timeout for loading but not unloading.
Again I'm feeling like a broken record:
- enable Circuit Conditions
- add the following circuit: arithmetic combinator: current inventory (from stop) - expected inventory (from LTN output) >> decider combinator: anything > 0 red = 1 >> train stop

Done, that train will never leave if it has a single piece loaded incorrect even with stop timeout active.
Careful, that doesn't work with requested fluids as the expected inventory is -1 and the circuit would remain at red=1even when empty. And if it weren't -1 then it would have the rounding down to 0 problem to take care about. It's not as simple as you make it seem.
I told you back when you wanted this special treatment for fluids it would require filtering out fluid signals from unloading circuitry.
https://github.com/Yousei9/Logistic-Tra ... -468930351

However a signal filter can be made with 3 combinators. So no big deal.
Never said it was a big deal. I just stated my current preferences. Luckily we do have the choice. My preference is for trains to remain stuck when they can't unload by turning off the timeout. Others might prefer the timeout or adding 2 (5+) combinators per station. Everyone as they like.

headhunter32
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Sep 10, 2018 6:35 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by headhunter32 »

Oke love how its explained here and how it work, i finaly got it working for my self.

But i still have 1 thing i wanted to know, why ad all binary encoded network ID and not just network id 1, 2, 3, 4, 5 etc etc.
Just curius.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Encoded Network ID, how does it work?

Post by Optera »

headhunter32 wrote:
Fri Aug 09, 2019 6:03 pm
Oke love how its explained here and how it work, i finaly got it working for my self.

But i still have 1 thing i wanted to know, why ad all binary encoded network ID and not just network id 1, 2, 3, 4, 5 etc etc.
Just curius.
You can't add decimal together to have any station in any combination of networks.

headhunter32
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Sep 10, 2018 6:35 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by headhunter32 »

ahe thnx i was always curius on why it could not work thnx for explaining great mod btw love it.

mrvn
Smart Inserter
Smart Inserter
Posts: 5683
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Encoded Network ID, how does it work?

Post by mrvn »

Optera wrote:
Fri Aug 09, 2019 6:24 pm
headhunter32 wrote:
Fri Aug 09, 2019 6:03 pm
Oke love how its explained here and how it work, i finaly got it working for my self.

But i still have 1 thing i wanted to know, why ad all binary encoded network ID and not just network id 1, 2, 3, 4, 5 etc etc.
Just curius.
You can't add decimal together to have any station in any combination of networks.
That would be less of a problem with my multi-stop station patch (which reminds me that I still need to comment the code). I'm actually using that a lot just to make stops that have multiple sets of signals instead of actually having multiple stops.

The idea is simple. You build one station normal just like now. Then right next to it place one rail tile and a second LTN stop. Connect the two by wire and name them the same. Now you have a multi-stop station. Except one of the stops is a dummy that can never be reached. But you can connect a LTN combinator to the dummy stop and connect the buffer chests to it. Then you can request and provide goods at the dummy too. That allows for example to request goods at the normal stop with 2 <= train size <= 2 and provide fluids at the dummy with 4 <= train size <= 4. For the network ID instead of having one stop that is in network 2 and network 3 you would make a multi-stop with one stop per network you want to use. No more need to use bit masks. But it's too late to change that now.

Chids
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Sep 01, 2020 11:30 pm
Contact:

Encoded station ID issue

Post by Chids »

I had a working logistic train network in my base, but only for my 1-2 trains, under station id 2. I added another depot under id 1 for my 1-1 trains, and now both of my depots are giving me error messgages that read something like "no trains found between lenghth 0 and 0 found in depot in network 0x2/0x4" and now only the 1-2 trains go to the id 1 providers and requesters, not the 1-1 trains. I tried setting limits to max/min train length, to only allow trains of a lenght of 3 or 2 but it then simply doubled the number to 6 from 3, or from 2 to 4, and still does not work

LouTenant
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Oct 02, 2020 8:35 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by LouTenant »

HI,
I have a problem with the encoded network Ids. I've set up a couple of stations with different Id's. As an example : One station provides an item and the second station requests the same item from the network but it shouldn't request from the provider station. The provider station has the default Network id of -1. The request station has the Id 2. But still the station requests from the provider station.
I've tried other ID's too but nothing seem to work.

Any advice ?

Thank you.

redis
Inserter
Inserter
Posts: 44
Joined: Sat Aug 31, 2019 4:03 am
Contact:

Re: Encoded Network ID, how does it work?

Post by redis »

LouTenant wrote:
Fri Oct 02, 2020 8:41 pm
HI,
I have a problem with the encoded network Ids. I've set up a couple of stations with different Id's. As an example : One station provides an item and the second station requests the same item from the network but it shouldn't request from the provider station. The provider station has the default Network id of -1. The request station has the Id 2. But still the station requests from the provider station.
I've tried other ID's too but nothing seem to work.

Any advice ?

Thank you.
Because your provider network -1 means part of ALL networks including id=2. You can have shared/overlapping networks in LTN (which is awesome). To solve the issue you can set provider station to something different than -1, but make sure that id is not "shared" with id=2 bitwise. RTFM.

LouTenant
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Oct 02, 2020 8:35 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by LouTenant »

redis wrote:
Fri Oct 02, 2020 8:53 pm

Because your provider network -1 means part of ALL networks including id=2. You can have shared/overlapping networks in LTN (which is awesome). To solve the issue you can set provider station to something different than -1, but make sure that id is not "shared" with id=2 bitwise. RTFM.
So I've tried a lot of different Ids for provider and requester station now. Single digit and multiple and even 6,7 or 8 digits. And still it requests from the provider station. Am I stupid ? :D

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2632
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by steinio »

Id -1 means the station is in all networks.
Id 3 for example means the station is in network 1 and 2.

In the binary system you have only numbers which are a factor of 2.

2^0 = 1
2^1 = 2
2^2 = 4
...
Image

Transport Belt Repair Man

View unread Posts

LouTenant
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Oct 02, 2020 8:35 pm
Contact:

Re: Encoded Network ID, how does it work?

Post by LouTenant »

Alright i got it. Thank you very much! :)

MisterFister
Long Handed Inserter
Long Handed Inserter
Posts: 99
Joined: Tue Jun 27, 2017 1:12 am
Contact:

Re: Get stucked with basic LTN ID problem [solved]

Post by MisterFister »

Hi there! Sorry for the necro, but this post is square-on-point what I'm running into.

I agree that cache or buffer locations are of limited utility. That said, I'd care to experiment with using one to accelerate depleting a specific resource patch -- I hate-hate-HATE building atop unharvested resources, and I'd prefer to actually harvest it first instead of using something like the OreEraser mod.

I've asked about binary notations before (I think in the context of encoding wagon positions) but... I am still mystified, I figured out an in-game workaround for that previous issue I was asking about at the time, and I really didn't wanna overburden the time of a person (you, Optera, I think) after you'd already answered me more than once. Especially for a scenario which, at the time, I was so capable of working around anyway.

I can ignore this new issue by building on the recourse field anyway; I can relocate or postpone my plans to build at that location; or I can surrender to using OreEraser. But without understanding how to properly define the networkID to behave the way I want it to... I cannot develop my own workaround otherwise. The closest I can come is to build by buffer location as a requestor-only, which would require that I not be able to use it as an LTN-provider without also disabling the LTN-requestor ability. (The easiest way for this is to have two separate constant_combinators, one for requester and one for provider, and I can use a blueprint from mapview to connect one or the other with a signal wire. Removing the wire means either visiting the location manually, or nuking that combinator with roboport coverage and a bot. I don't consider this multi-step process to be a valid "workaround" within the spirit of Factorio being a game about automation.)

Note that in my map, I have the global-default request-threshold and provide-threshold both set unattainably high to 10^9, which iirc is the longest value accepted. This is to ensure and categorically prevent any mixed-freight train from ever being intentionally dispatched. (L-CCCC and L-TTTT, if relevant.) Also, I voluntarily choose to uniquely name all LTN-stops, everywhere, period. I'm aware that this is not necessary for LTN dispatching to function, as I do so for reasons outside the scope of the LTN mod. Obviously, since I never specify any networkID anywhere so far, all dispatches are on the same networkID.

Is there any way to ONLY prevent the circular-feedback activity at this location, but to leave all other behavior intact? I.e., a city-block with a reduced-priority LTN-requestor intake trainstop, that can generally receive LTN-routed shipments of materials from any valid provider elsewhere; AND an increased-priority LTN-provider trainstop, capable of fulfilling LTN-routed requests for other locations; BOTH active at the same time; without developing that feedback loop described in this thread's OP?

My likely-flawed understanding is that doing this "properly" might involve redefining multiple unique networkID values for various provider and requestor locations map-wide... and, if true, this would make me irrationally sad.

(As always, thanks so much for your work as a modder!)

PS -- willing to delete and re-post if you would prefer, and / or please feel free to fork it with moderator privs, and again, apologies for the necro.

Post Reply

Return to “Logistic Train Network”