please do not use floating point value in Factorio

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 1883
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: please do not use floating point value in Factorio

Post by boskid »

Ambaire wrote: ↑
Fri Jun 04, 2021 3:28 pm
Would it be possible to override that for modded games? Specifically, Pyanodons, and the seablock mod for it? Early game, I'm slowly producing liquid glass from quartz at a rate of 10 fluid units per 10 seconds or so, and with the underground pipe length I was using, I was experiencing 75% fluid loss thanks to that 'feature'.

Even with short range transport from a producer to a consumer, I was losing liquid glass over time at a rate of 0.1 units every minute or so. I could tell since the amount in the destination went from a whole number to .9, .8, etc.

Also, since pipes can only have one fluid type now without exploits, there is zero reason for any automatic flush to ever occur. If a manual flush is desired, it's easy enough to connect a pump to one end of the pipe system.
I am not sure if you are playing on the latest version, but the flush condition when all pipes have less than 0.05 of fluid was removed (97338). Also the hard fluid mixing prevention was replaced with soft fluid mixing prevention where only manual placement of pipes by a player is checked against fluid mixing. Hard mixing prevention was causing too many corner cases to handle.

Ambaire
Fast Inserter
Fast Inserter
Posts: 160
Joined: Fri Jun 26, 2015 11:37 pm

Re: please do not use floating point value in Factorio

Post by Ambaire »

boskid wrote: ↑
Fri Jun 04, 2021 3:46 pm
Ambaire wrote: ↑
Fri Jun 04, 2021 3:28 pm
Would it be possible to override that for modded games? Specifically, Pyanodons, and the seablock mod for it? Early game, I'm slowly producing liquid glass from quartz at a rate of 10 fluid units per 10 seconds or so, and with the underground pipe length I was using, I was experiencing 75% fluid loss thanks to that 'feature'.

Even with short range transport from a producer to a consumer, I was losing liquid glass over time at a rate of 0.1 units every minute or so. I could tell since the amount in the destination went from a whole number to .9, .8, etc.

Also, since pipes can only have one fluid type now without exploits, there is zero reason for any automatic flush to ever occur. If a manual flush is desired, it's easy enough to connect a pump to one end of the pipe system.
I am not sure if you are playing on the latest version, but the flush condition when all pipes have less than 0.05 of fluid was removed (97338). Also the hard fluid mixing prevention was replaced with soft fluid mixing prevention where only manual placement of pipes by a player is checked against fluid mixing. Hard mixing prevention was causing too many corner cases to handle.
Oh. Sorry. Perhaps I was hallucinating it.

jooe
Inserter
Inserter
Posts: 24
Joined: Tue Apr 04, 2017 6:10 pm
Contact:

Re: please do not use floating point value in Factorio

Post by jooe »

Sorry to necro an old thread, but I am experiencing a very similar problem.
Having a long pipe connection (> 500 pipes or more) while the pipes are almost empty causes an extremely high loss of fluids.
In production graphics, while producing ~100 units/second, consumption was staying around 1 units/second (= 99% loss). Direct connection from producer to consumer, getting even worse when adding tanks or pumps in between.

The fact that tanks make it worse points to the float precision problem mentioned before, so there is probably not much to do about it, but I thought I'd mention it anyways.

I was able to improve the system a little by using a train to decrease the pipe lenghts, now losses are down to around 75%. Shorter connections are not really possible (highly modded game with extreme number of different products, cannot produce them all in one place ...)

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 1497
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: please do not use floating point value in Factorio

Post by FuryoftheStars »

jooe wrote: ↑
Mon Jul 18, 2022 8:57 am
Sorry to necro an old thread, but I am experiencing a very similar problem.
Having a long pipe connection (> 500 pipes or more) while the pipes are almost empty causes an extremely high loss of fluids.
In production graphics, while producing ~100 units/second, consumption was staying around 1 units/second (= 99% loss). Direct connection from producer to consumer, getting even worse when adding tanks or pumps in between.

The fact that tanks make it worse points to the float precision problem mentioned before, so there is probably not much to do about it, but I thought I'd mention it anyways.

I was able to improve the system a little by using a train to decrease the pipe lenghts, now losses are down to around 75%. Shorter connections are not really possible (highly modded game with extreme number of different products, cannot produce them all in one place ...)
This sounds like it might be more of a pressure issue than floating point loss: https://wiki.factorio.com/Fluid_system#Transport

Zavian
Smart Inserter
Smart Inserter
Posts: 1632
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zavian »

Whilst a pressure issue is one possibility, the other common cause of very low fluid levels in pipes is demand outstripping supply.

If the output fluid boxes in the supply machines are empty, then that sounds like a case of demand exceeds supply.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 1497
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: please do not use floating point value in Factorio

Post by FuryoftheStars »

I will note that a pressure issue will cause exactly that as well, and considering they mentioned it's over a >500 pipe segment section, that's where I'm leaning. ;)

User avatar
atomizer
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Sat Sep 22, 2018 3:18 pm
Contact:

Re: please do not use floating point value in Factorio

Post by atomizer »

I did a trivial test and can confirm fluid loss: viewtopic.php?f=7&t=102921

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 1497
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: please do not use floating point value in Factorio

Post by FuryoftheStars »

atomizer wrote: ↑
Mon Jul 18, 2022 6:16 pm
I did a trivial test and can confirm fluid loss: viewtopic.php?f=7&t=102921
atomizer wrote: ↑
Mon Jul 18, 2022 6:15 pm
Setup: about 600 pipes between two assemblers

Reproduction:
- add 1 barrel into unbarreling machine
- open the pipe
- observe fluid system contents drop over time, destroying fluid (increase game speed as needed)

The output machine is required, a standalone pipe does not lose fluid.
Using small amounts of fluid (like 1 barrel's worth), you are correct, it appears that the system does experience some kind of loss. Though it does settle at a point and stops losing.

Using as much as 5 barrel's worth, however, and setting the output inserter of the barreler assembler to insert into the unbarreler assembler (creating a closed circuit) does not experience loss.

This demonstrates that the loss only occurs when the pipes have extremely low fluid content per pipe.
Edit: Apologies, missed the fact that it only happens when the barreling assembler is attached. The fluid amounts flowing from the pipes to the assembler must be so low that floating point or something else is kicking in to cause the loss. (The original below should still be valid, though.) /Edit

That said, this should have no bearing on jooe's report as their system is producing ~100 fluid per second.

User avatar
atomizer
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Sat Sep 22, 2018 3:18 pm
Contact:

Re: please do not use floating point value in Factorio

Post by atomizer »

FuryoftheStars wrote: ↑
Tue Jul 19, 2022 12:55 am
That said, this should have no bearing on jooe's report as their system is producing ~100 fluid per second.
Indeed, at 100/s flow rate any pipe that can handle it (i.e. up to 2.4km) seems to not have any problems.

On a hunch, I also tested 100/m input flow and got the following:

Code: Select all

L   | outflow (/m)
1   | 100
220 | 73.3
416 | 14.7
1k  | 7
2k  | 5.5
I didn't reach the reported 99% loss, but it's reasonable to assume there's a configuration that does.

jooe
Inserter
Inserter
Posts: 24
Joined: Tue Apr 04, 2017 6:10 pm
Contact:

Re: please do not use floating point value in Factorio

Post by jooe »

FuryoftheStars wrote: ↑
Tue Jul 19, 2022 12:55 am
That said, this should have no bearing on jooe's report as their system is producing ~100 fluid per second.
I'm sorry for being confused myself, production was only 100/m, so that is well within the range of the tests atomizer did.
The 99% loss might have been when there were still some tanks in the circuit, as their fluid box is much larger, the floating point rounding issue probably kicks in a few magnitudes earlier.

I did solve the problem more or less by just increasing output. "We have 99% wasted production? Well, then let's produce 100 times more so it doesn't matter ..." ;)

Post Reply

Return to β€œGameplay Help”