round up fluids reading train inventory

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

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

round up fluids reading train inventory

Post by Optera »

Problem:
Controlling pumps for unloading is cumbersome with stops showing 0 while there's 0.x fluid left in wagons.

Using the empty condition does not work if you want to have that train drop off oil and pick up sulfuric acid.

Solution:
Stops reading train inventories should always round up fluids to next integer.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: round up fluids reading train inventory

Post by steinio »

+1
Image

Transport Belt Repair Man

View unread Posts
deeje
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon May 01, 2017 11:26 am
Contact:

Re: round up fluids reading train inventory

Post by deeje »

+1000

This issue is currently driving me batty.
JohnyDL
Filter Inserter
Filter Inserter
Posts: 535
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: round up fluids reading train inventory

Post by JohnyDL »

you can set it to if fluid is <1 solves the issue mostly for trains you don't intend to carry different fluids at different times.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: round up fluids reading train inventory

Post by Optera »

JohnyDL wrote:you can set it to if fluid is <1 solves the issue mostly for trains you don't intend to carry different fluids at different times.
You don't seem to get the point.
Fluids are double values.
Stops show fluid values by truncating them to integer, making it impossible to discern if something is truly 0 or <1 if you prefer that.
JohnyDL
Filter Inserter
Filter Inserter
Posts: 535
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: round up fluids reading train inventory

Post by JohnyDL »

actually I do get the point of the difference between <1 and =0 what I don't get the point about 100% is why it matters <1 is actually <0.5 thanks to current rounding and a loss of that little only matters once and happens as rounding errors eventually anyway. You need 200+ deliveries for it to prevent 2 oil processes happening that could otherwise have worked 75000 oil per wagon*4/100 gives 3000 processes per train an equivalent loss of 1 in 600,000. it's a negligible loss like asking for a nuclear reactor to deliver 1 extra kilowatt
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: round up fluids reading train inventory

Post by Optera »

JohnyDL wrote:actually I do get the point of the difference between <1 and =0 what I don't get the point about 100% is why it matters <1 is actually <0.5 thanks to current rounding and a loss of that little only matters once and happens as rounding errors eventually anyway. You need 200+ deliveries for it to prevent 2 oil processes happening that could otherwise have worked 75000 oil per wagon*4/100 gives 3000 processes per train an equivalent loss of 1 in 600,000. it's a negligible loss like asking for a nuclear reactor to deliver 1 extra kilowatt
With the way fluids work in factorio a tank gets locked to a fluid with even trace amounts of a fluid inside.
The problem is we don't see these trace amounts in circuit network. It should output 0 only when a tank is truly empty and ready to take in any fluid.
Roxor128
Fast Inserter
Fast Inserter
Posts: 168
Joined: Sun Oct 02, 2016 9:48 am
Contact:

Re: round up fluids reading train inventory

Post by Roxor128 »

Seems to me the real solution to the problem should be "Use integers instead of floats for fluid values". Though that would probably be a headache to change.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: round up fluids reading train inventory

Post by steinio »

Roxor128 wrote:Seems to me the real solution to the problem should be "Use integers instead of floats for fluid values". Though that would probably be a headache to change.
Yes I thought the same a while ago.
Maybe the developers can provide some insights why they decided for floats.
Image

Transport Belt Repair Man

View unread Posts
JohnyDL
Filter Inserter
Filter Inserter
Posts: 535
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: round up fluids reading train inventory

Post by JohnyDL »

Yes I agree if you need to 100% empty to change fluids then that's an issue but if you need to do that then you probably don't need the circuit network interfering at all. if you're using it as a detection to stop mixing fluids the train is probably going back and forth between the same stations if you need to change fluid it's probably a one off procedure and you can turn off the circuit controls to do it. I can't think of any good reason why I'd want to have 2 different fluids using the same wagon even an edge case where you're delivering petroleum gas and taking away sulphuric acid from the same set up I'd want 2 trains so that the train doesn't act as a bottle neck.

Another alternative is adding in a small delay on your detection line, if there's a delay of say 10 ticks that's more than enough time to empty the last tiny bit of fluid.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: round up fluids reading train inventory

Post by steinio »

JohnyDL wrote:Yes I agree if you need to 100% empty to change fluids then that's an issue but if you need to do that then you probably don't need the circuit network interfering at all. if you're using it as a detection to stop mixing fluids the train is probably going back and forth between the same stations if you need to change fluid it's probably a one off procedure and you can turn off the circuit controls to do it. I can't think of any good reason why I'd want to have 2 different fluids using the same wagon even an edge case where you're delivering petroleum gas and taking away sulphuric acid from the same set up I'd want 2 trains so that the train doesn't act as a bottle neck.

Another alternative is adding in a small delay on your detection line, if there's a delay of say 10 ticks that's more than enough time to empty the last tiny bit of fluid.
LOL you should try the Logistic Train Network mod.
Image

Transport Belt Repair Man

View unread Posts
JohnyDL
Filter Inserter
Filter Inserter
Posts: 535
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: round up fluids reading train inventory

Post by JohnyDL »

Love that mod never use it for fluids though there's no point. so few endpoints in that network it's simpler to do it manually
Roxor128
Fast Inserter
Fast Inserter
Posts: 168
Joined: Sun Oct 02, 2016 9:48 am
Contact:

Re: round up fluids reading train inventory

Post by Roxor128 »

steinio wrote:
Roxor128 wrote:Seems to me the real solution to the problem should be "Use integers instead of floats for fluid values". Though that would probably be a headache to change.
Yes I thought the same a while ago.
Maybe the developers can provide some insights why they decided for floats.
As a programmer, I can say there are certainly a few reasons to use floats when writing something. The main ones I can think of off the top of my head being these three:

1. Being the computer equivalent of scientific notation, they have a very large range (10^308 down to 10^-308 for 64-bit floats).

2. Algorithms are often easier to implement with floats rather than just integers.

3. Some APIs require their use for certain functions (eg. OpenGL uses them for things like coordinates and colours, and both HLSL and GLSL use them for all colour values).

Hope that helps give a little insight.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: round up fluids reading train inventory

Post by Optera »

steinio wrote:
Roxor128 wrote:Seems to me the real solution to the problem should be "Use integers instead of floats for fluid values". Though that would probably be a headache to change.
Yes I thought the same a while ago.
Maybe the developers can provide some insights why they decided for floats.
I'm curious for the reasoning behind the usage of float for fluids myself. No recipe needs fractions for crafting.
JohnyDL
Filter Inserter
Filter Inserter
Posts: 535
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: round up fluids reading train inventory

Post by JohnyDL »

most likely it's there to produce the desired flow behaviour on pipes, if there's a drop off of 0.1% per pipe and its calculated pipe by pipe and rounded each time once you drop below 500 fluid in a pipe with integers the drop off effect would stop.
Twinsen
Factorio Staff
Factorio Staff
Posts: 1354
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: round up fluids reading train inventory

Post by Twinsen »

Oh no, not this again.
I remember the rounding method was changed about 2 times due to problems like this.
Won't rounding up(in all cases including storage tanks, since it has to be consistent) cause other problems in other setups?

I'll add this to my TODO and hopefully we can fix it.
We might implement a mechanic where large high pressure fluids would destroy static small amounts of leftover fluid. This would also solve the "delete and replace all pipes because I accidentally put the wrong fluid in it for 1 second" problem.
We are also considering remove all the pipe fluid physics and replacing it with a much simpler model, similar to how electric networks work.
JohnyDL
Filter Inserter
Filter Inserter
Posts: 535
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: round up fluids reading train inventory

Post by JohnyDL »

Twinsen I think it sounds like a better case for a check on disconnect of pump if it's a bug fix (though I'm still not bothered by it)

on event pump disconnect: if fluid in tank <1 then delete fluid from tank force add fluid to pump even if over full
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: round up fluids reading train inventory

Post by Tekky »

Related bug report thread (which was moved to "Not a bug"):

viewtopic.php?f=23&t=47626 0.15.10 Fluid wagon leaving even though condition is not met
dogfire
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Feb 19, 2017 11:42 pm
Contact:

Re: round up fluids reading train inventory

Post by dogfire »

Playing with the Logistic Train Network mod myself, and this fluid rounding problem is destroying my life ;_;

So, first, here's the solution I created for my fluid train depot:
2017-07-16 13_37_08-Factorio 0.15.30 [Streaming].png
2017-07-16 13_37_08-Factorio 0.15.30 [Streaming].png (2.06 MiB) Viewed 15581 times
My current theory is any configuration other than a single unbroken line results in fractions of fluid getting stuck in a pipe. This configuration allows a continuous pressure differential to entirely drain the pipe.

Second, here's my current problem:
2017-07-16 13_42_32-Greenshot.png
2017-07-16 13_42_32-Greenshot.png (1.89 MiB) Viewed 15581 times
The train is set to leave when its contents are empty, or, after a long timeout. Now, I can change both of these settings in the LTN Mod, and I'm going to. But as it stands I have no way to fully empty the train using the circuit network. I can fully empty a cargo wagon using the circuit network, but I can't fully unload a fluid wagon using the circuit network.

Rounding up, from my player's perspective, or maybe decimalizing the circuit network, seem simplest? But then that also introduces fuck-knows-what behind the scenes, which makes sense to me too.
Maybe the simplest solution is to have fluids destroy with the higher pressure winning.

The pressure destruction method would probably open up some really cool options and designs for plumbing too. Maybe single-pipe refinery setups...
Twinsen
Factorio Staff
Factorio Staff
Posts: 1354
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: round up fluids reading train inventory

Post by Twinsen »

It's not as simple as rounding up.

If I round up soon there will be a flood of complaints from a different group of people saying that their storage tank logic no longer works, because there is 0.00001 fluid in their storage tank that they can't pump out. Or similar problems to this.
Post Reply

Return to “Ideas and Suggestions”