The fuel consumption of the Burner Mining Drill seems to have a rounding error.
What do I do to reproduce:
- Start a new sandbox game with all techs, items, cheat mode
- Place a Burner Mining Drill on some iron ore, with a wooden chest as target
- Feed exactly 3 pieces of coal to the drill
What do I expect:
As the drill consumes 150 kW and each piece of coal provides 4MJ, the drill should run for 80 seconds (3 * 4MJ / 150kW). With a working speed of 0.25, the drill should complete 20 mining operations in this time. Because of a productivity bonus of 40% due to Mining Productivity research, I expect to see 20 * 1.4 = 28 pieces of ore in the output chest.
What does happen:
Only 27 pieces of ore are produced. At the end the first progress bar of the drill (for ordinary production) is full (indicating that the last ordinary product has not been generated). The productivity bonus bar is empty (indicating that the last bonus item has been generated).
The attached screenshot shows this state.
A separate test with a stone furnace producing 25 pieces of steel over the cource of 400 seconds and consuming 9 pieces of coal shows no rounding error.
[0.17.31] Fuel consumption of Burner Mining Drill: rounding error
[0.17.31] Fuel consumption of Burner Mining Drill: rounding error
- Attachments
-
- Mining drill and output chest after consuming 3 pieces of coal.
- MiningDrill.jpg (208.28 KiB) Viewed 2041 times
Re: [0.17.31] Fuel consumption of Burner Mining Drill: rounding error
I have done more tests:
A Boiler, a Steam Engine, an Electric Mining Drill and 9 pieces of coal produced 279 pieces of ore instead of the expected 280 (with 40% Mining Productivity).
A Boiler, a Steam Engine, a Lab, 3 pieces of coal and 20 Science Packs failed to research Automation 1 and Turrets (each 10 Packs * 10 seconds = 200 seconds of lab time without any lab speed bonus).
In both cases the progress bar is full and in the second case the last Science Pack has a remaining use of "0%".
Edit: yet more tests:
A Boiler, a Refinery running Coal liquefaction, assorted pipes and tanks and a solar array for power run the expected 8 liquefaction cycles for each 3 coal in the boiler (and 80 in the refinery).
A modded lab running on fuel instead of electricity fails to complete the last research.
A modded assembler running on fuel instead of electricity works correctly.
Conclusion:
1. Boiler, furnaces and assemblers don't exhibit a rounding error.
2. All mining drills and labs do.
A Boiler, a Steam Engine, an Electric Mining Drill and 9 pieces of coal produced 279 pieces of ore instead of the expected 280 (with 40% Mining Productivity).
A Boiler, a Steam Engine, a Lab, 3 pieces of coal and 20 Science Packs failed to research Automation 1 and Turrets (each 10 Packs * 10 seconds = 200 seconds of lab time without any lab speed bonus).
In both cases the progress bar is full and in the second case the last Science Pack has a remaining use of "0%".
Edit: yet more tests:
A Boiler, a Refinery running Coal liquefaction, assorted pipes and tanks and a solar array for power run the expected 8 liquefaction cycles for each 3 coal in the boiler (and 80 in the refinery).
A modded lab running on fuel instead of electricity fails to complete the last research.
A modded assembler running on fuel instead of electricity works correctly.
Conclusion:
1. Boiler, furnaces and assemblers don't exhibit a rounding error.
2. All mining drills and labs do.
Last edited by a-mann on Sun Apr 14, 2019 5:52 am, edited 1 time in total.
Re: [0.17.31] Fuel consumption of Burner Mining Drill: rounding error
Could just be related to the goofiness of decimals in programming languages. (0.5 + 0.5) == 1 is not always true, as an example, depending on the specific programming languages implementation of the binary. It could be equaling 0.999999999999998 or something.
That's what I assumed is going on in this case, I could be completely wrong though.
That's what I assumed is going on in this case, I could be completely wrong though.
- TruePikachu
- Filter Inserter
- Posts: 978
- Joined: Sat Apr 09, 2016 8:39 pm
- Contact:
Re: [0.17.31] Fuel consumption of Burner Mining Drill: rounding error
Firstly, all modern (and likely historical as well) floating-point implementations have `0.5 + 0.5 = 1.0` (since 0.5 is exactly a power of two, being 2^-1) -- a better example to use is `0.1 + 0.2 ≠ 0.3`, since none of those numbers have an exact representation in IEEE754.cid wrote: ↑Sat Apr 13, 2019 11:54 am Could just be related to the goofiness of decimals in programming languages. (0.5 + 0.5) == 1 is not always true, as an example, depending on the specific programming languages implementation of the binary. It could be equaling 0.999999999999998 or something.
That's what I assumed is going on in this case, I could be completely wrong though.
However, the issue likely isn't entirely because of a rounding error:
- The piece of coal is put into the furnace; it has exactly 4000000.0 joules of energy available.
- Every tick, 150kW of power is consumed by the furnace -- this is done by subtracting exactly 2500.0 joules of energy from the buffer.
- Each piece of coal lasts for 1600 ticks (26⅔ seconds); three pieces of coal should last for 4800 ticks (80 seconds).
Without pulling out the debugger, I'd wager that the issue is that work towards mining might not be occuring in the tick a new piece of fuel is consumed, while still spending the fuel. There was a similar issue at one point in the past, on crafting machines (which includes furnaces), which was since fixed (which is why the steel smelting doesn't show an issue), but it might still be a problem for miners. In theory, that miner still needs either two or three ticks of fuel to complete its operation (5kJ-7.5kJ).
Re: [0.17.31] Fuel consumption of Burner Mining Drill: rounding error
Well, there will probably always be things like that, but I don't think it is worth changing.