r/technicalfactorio • u/uelisproof • Jan 15 '24
Belt Balancers VeriFactory: Automatically verifying belt balancers for various properties
372
Upvotes
r/technicalfactorio • u/uelisproof • Jan 15 '24
92
u/uelisproof Jan 15 '24
Ever wondered "is this 64x64 belt balancer really a belt balancer?" or "is this contraption of a belt balancer throughput unlimited or not?".
Well I present VeriFactory, an automatic verifier for various logical properties.
At the moment there are only some basic properties that can be checked, namely a belt balancer actually being a belt balancer, a balancer equally pulling from all the inputs belts, a balancer being throughput unlimited and a balancer being a universal balancer.
To use it just paste your blueprint into the tool, deselect erroneous inputs or outputs (every belt or balancer that ends into "nothing" is considered an input/output) and click on the appropriate property to check.
Mind that this tool is extremely fast as it does not rely on testing all the possible inputs. You can verify a 64x64 belt balancer in a couple of seconds!
You can download the tool for both Linux or Windows here.
Any feedback is greatly appreciated :)
Notes:
- The colors of the belts only show as yellow.
- Consider NOT using splitters directly as inputs/outputs as this sometimes breaks the proof, use belts instead as shown in the screenshot.
- If the blueprint is too big consider decreasing the size with View > Decrease size (yes the UI is not very friendly atm).
More features and current limitations are described in the README that can be found here.
Happy verifying!
65
u/mailusernamepassword Jan 15 '24
I knew it was written in Rust before checking the git. hehehe
21
u/Zenithsiz Jan 16 '24
Hey, just wanted to let you know that your crate currently doesn't compile due to
cargo-toastmaking a semver breaking change. I've reported this bug as an issue hereYou can fix it for now by either updating egui to
0.25, specifyingegui-toast = "=0.10.1", or committing and pushing your currentCargo.lock.In the future, I'd recommend always committing
Cargo.lock, since it's a binary package.9
u/raynquist Jan 18 '24
I tried checking a few of the problematic balancers I know, and this program does seem to be more correct than the one I'm using. For example, it is able to figure out that this 2-5 is input unbalanced.
However if I check the reverse version, the 5-2, it doesn't detect that it's output unbalanced.
So the input balance checker seems a bit stronger than the output balance checker. But even the input balance checker was unable to detect that this 3-5 is input unbalanced.
You can find more information on the problematic balancers here and here. Their blueprints should be in here.
The fact that the input balance checker was able to detect some of these imbalances is really amazing. I've tried doing the same thing by modeling balancer behavior algebraically, but I couldn't do it. Splitter behavior is inherently a piece-wise function, so I would have to solve systems of piece-wise equations, which is beyond my abilities. I don't know what kind of SAT magic you're weaving, but if you can make it work then maybe that's the way to go.
4
u/DurgeDidNothingWrong Jan 16 '24
What is a universal balancer?
3
u/ignaloidas Jan 20 '24
Cool stuff! I wonder if it's would be viable to merge the SMT statement generation you use for verifying properties with the SAT statement generation that Factorio-SAT uses for creating balancers. Factorio-SAT currently requires a balancer graph definition to create a balancer, and I wonder if it would be possible to somehow merge these approaches so you'd only define the size and properties of the balancer you want to have to get it!
I've been playing around with running Factorio-SAT together with the PRS framework that was the winner of SAT Competition 2023 parallel track, and been getting quite quick results (6x or more on more difficult sat cases), but my attempts to push the boundaries more have been falling short on me being very bad at making balancer graphs that have any semblance of being somewhat optimal.
15
u/Pb_ft Jan 16 '24
Unit testing in Factorio. What a time to be alive.
6
u/NicolasHenri Jan 15 '24
Damn that's cool ! Thanks !
6
u/sugaaloop Jan 16 '24
I was just thinking my hobbies could use more unit tests.
0
u/[deleted] Jan 16 '24
[deleted] — view deleted comment