Page 1 of 1

[outdated] Some (maybe) useful tools for factory design

Posted: Thu May 08, 2014 3:07 am
by Palpatine
I find it a lot of fun to optimize factories, so here is some tools to help with that.
1. factorio.py is a script to convert recipes into flowchart using graphviz. Recipes are entered into a table like factorio.csv, where 1st column is the product, 2nd column is the efficiency modifier (blue assembler has 0.75, furnace has 2, etc.), and the 3rd column is the time cost for 1 product. All the things you want as output belong to the first row. temp.dot is an example from my version of factorio.csv, and temp.svg is the factual flowchart, where the number on the arrows show volume and the number on the nodes show the number of factories your need. I know there is a nice lua script that read directly from the game files, but I cannot make it to run.

Update: I got the recipe directly from the game data so it should be accurate now (except for mining and the oil processing shit). Also raw materials are no at the top and output are now at the bottom, separated. The real improvement is that now you only need to modify the demand.csv file to create your own graph for a specific factory and the script will hide anything that's irrelevant.
Here is an example of a bootstrapping factory to beeline logistic bots.
temp.png
temp.png (379.22 KiB) Viewed 31538 times
2. playground.zip is a just an empty scenario with all the essentials (mines and electricity) so you can design your factory in map editor without doing the essentials yourself.

Re: Some (maybe) useful tools for factory design

Posted: Thu May 08, 2014 9:42 pm
by MF-
What is the attached graph actually about?
You chose a pack of things to be made in a fixed ratio?
It would IMO really improve the appearance if you could get rid of that big output node
and get outputs separated.

Also - why the... fractions? Percentages? Why does 0.00<unit> go to the output from the right side?

Also - some lines fork (mmmkay) and some merge (confusing) + there are odd gaps in the lines in there.

Nevertheless, I agree that such tool might indeed be useful for those that want all factories at 100% capacity.
(I don't happen to be one of those, if everything is at 100% capacity, then everything is a bottlenect :D)

Re: Some (maybe) useful tools for factory design

Posted: Thu May 08, 2014 10:15 pm
by ssilk
MF- wrote: if everything is at 100% capacity, then everything is a bottlenect :D)
:lol:

Re: Some (maybe) useful tools for factory design

Posted: Fri May 09, 2014 1:30 am
by Palpatine
MF- wrote:What is the attached graph actually about?
You chose a pack of things to be made in a fixed ratio?
It would IMO really improve the appearance if you could get rid of that big output node
and get outputs separated.

Also - why the... fractions? Percentages? Why does 0.00<unit> go to the output from the right side?

Also - some lines fork (mmmkay) and some merge (confusing) + there are odd gaps in the lines in there.

Nevertheless, I agree that such tool might indeed be useful for those that want all factories at 100% capacity.
(I don't happen to be one of those, if everything is at 100% capacity, then everything is a bottlenect :D)
The set quantity for output is supposed to be unit per second. I didn't round the factory numbers because sometimes fractions helps in case you have speed modules nearby.
I agree having output separated should help with the appearance. I need sometime to modify the script. The 0.00 on the right side just appeared because I set the speed module production at 0.001 per second.
The merge and fork thing is a simple graphviz option, just set the concentration=false at the beginning of the file and it should get fixed. I had the merge on because it sometimes helps with planning belt sharing.
Here is an example of with the merge/fork thing turned off (though I have changed some requirement for my new factory).
temp.png
temp.png (460.57 KiB) Viewed 31876 times

Re: Some (maybe) useful tools for factory design

Posted: Fri May 09, 2014 2:52 am
by Garm
Thank you - this shall be used mercilessly when I will upgrade my manufacturing base.

Re: Some (maybe) useful tools for factory design

Posted: Fri May 09, 2014 9:38 am
by Bleda
this script would be perfect for the tight spot challenge. I did that with a pen and paper to get my factories balanced, which is actually the point of these missions, rather than using few space.

It would be great to have it read directly from the game files though. :)

Re: Some (maybe) useful tools for factory design

Posted: Fri May 09, 2014 11:14 am
by MF-
Ha, much better.
Is it possible to keep "fork" while turning off "merge"?
I don't have anything against forks.

PS: I noticed that Coal input node is rather hidden.
It sure makes the graph more compact, but on the other hand it allows such input to be missed.
I wonder if it would still be compact enough if inputs were forced to the top layer. Or different node border style?
(just a thought, with only a handful of raw materials available it's not that hard to spot something is missing)

one more number question: so.. the number IN the node bubble says how many assembling machines are necessary?

Re: Some (maybe) useful tools for factory design

Posted: Sun May 11, 2014 4:25 am
by Palpatine
MF- wrote:Ha, much better.
Is it possible to keep "fork" while turning off "merge"?
I don't have anything against forks.

PS: I noticed that Coal input node is rather hidden.
It sure makes the graph more compact, but on the other hand it allows such input to be missed.
I wonder if it would still be compact enough if inputs were forced to the top layer. Or different node border style?
(just a thought, with only a handful of raw materials available it's not that hard to spot something is missing)

one more number question: so.. the number IN the node bubble says how many assembling machines are necessary?
Cheers! I got a new version working. I have updated the original post. And yes the number in the bubble means the number of assemblers necessary. It is accurate for furnace and chemical plant but not accurate for oil processing and mining.

Re: Some (maybe) useful tools for factory design

Posted: Sun May 11, 2014 9:49 am
by MF-
Cheers!

Does it get weird when you request an intermediate product (as in the picture currently in the OP for the advanced circuits)?

I guess having the output node had some benefits for the graph structure.
I wonder what it would look like if there were dedicated output nodes for each output item.
Would it improve the overall structure and readability of the already great tool?

Currently its not really obvious how many items get produced, which could be nicely improved by labeling those dedicated output nodes like "82x advanced_circuit"


final number question: What does the number on "Water" say? "8.42" seems too much for the offshore pump count

Re: Some (maybe) useful tools for factory design

Posted: Sun May 11, 2014 1:05 pm
by Choumiko
Nice tool, thank you for that.

I modified dot_print(items) to show the required assembling machines/ furnaces on the arrows/edges (after items per second) when the item is used in different recipes, makes it easier to create "subfactories" :D
Here's the code if anyone is interested:
Code
And the graph for a factory that produces 1.5 solar panels per second:
temp.png
temp.png (58.08 KiB) Viewed 31446 times
What I'd like to see is a way to tell the script that i want to run x assemblers at 100% capacity, so demand.csv could look like:

Code: Select all

solar_panel,1,basic_accumulator,1,speed_module_3,2
mode=0 <- 0 means assemblers, 1 means items per second
I'd try and do it myself, but I don't know Python :?

Re: Some (maybe) useful tools for factory design

Posted: Sun May 11, 2014 9:17 pm
by nepp95
I don't understand graphviz although I'd like to mathematically optimize my factories :P

Re: Some (maybe) useful tools for factory design

Posted: Mon May 12, 2014 8:25 am
by Choumiko
nepp95 wrote:I don't understand graphviz although I'd like to mathematically optimize my factories :P
I'm not really sure what you don't understand, so here's a quick todo list:
0. download, unzip the archive from OP
1. install python and graphviz
2. edit demand.csv to your liking
3. run factorio.py
4. open the Downloads/temp.dot created by factorio.py with Graphviz
5. profit :mrgreen:

Hope this helps, else let us know what's not working/clear.


As a follow-up to my previous post:

Code: Select all

rocket_defense, 1.5
as demand.csv (1 assembling machine producing the rocket defense non-stop) makes me think this factory is impossible
Graph
Challenge accepted, anyone? :twisted:

Re: Some (maybe) useful tools for factory design

Posted: Mon May 12, 2014 9:37 am
by just_dont
I'd imagine getting 150 alien artifacts per second would eventually become the biggest problem. Even several largest chests of AAs will get dry very fast (probably even before you can "debug" your layout).
Although ~150K of iron plates per second seems scary, I'm pretty sure it can be parallelized enough.

Re: Some (maybe) useful tools for factory design

Posted: Mon May 12, 2014 9:49 am
by nepp95
@Choumiko,

Ofcourse I forgot to download python :mrgreen: And I even considered myself a programmer...
I think I get it now :P

-Edit-

The number you put in demand.csv, what should this be if you, for example, want one assembler 2, to produce at max capacity?

Re: Some (maybe) useful tools for factory design

Posted: Mon May 12, 2014 11:37 am
by Choumiko
normaly the numbers is desired items per second, so for 1 assembler lvl 2 it should be x = 1 / crafttime * 0.75
e.g. for SciencePack 1 with craftingtime = 5: 1/5*0.75 = 0.15
put in 0.15 in demand.csv and your good to go
just_dont wrote:Although ~150K of iron plates per second seems scary, I'm pretty sure it can be parallelized enough.
Sure it can, what i menat with impossible is: can Factorio handle the amount of assemblers? (e.g. 6k for speed module 3 assemblers alone :o ) I imagine the engine is going to reach it's limits rather quickly.

Re: Some (maybe) useful tools for factory design

Posted: Fri Aug 01, 2014 9:08 am
by Mikenter
And to think I was doing this all by hand... Though this does confuse me a little. For example, why do you need to mine more iron than iron plates? Shouldn't those be the same or am I just missing something super obvious?

Re: Some (maybe) useful tools for factory design

Posted: Fri Aug 01, 2014 10:24 am
by Blackence
The numbers inside nodes do not describe the number of items you need per second, but the number of furnaces / miners / assembly machines required to produce the required amount of items (the numbers are apparently wrong for oil / chem plants). For the number of "items per second", check the edges. The sum of inputs / outputs add up correctly for the cases where I checked this.

Re: Some (maybe) useful tools for factory design

Posted: Sat Aug 02, 2014 12:13 pm
by Mikenter
Oh okay, so it was something stupid obvious. So you would need 100 something miners for that... Wow. Still this will beat doing to all by hand. Thank you!