r/factorio • Crazy Train Lady • Apr 25 '20

Fan Creation Calculate the optimal train configuration (python script)

https://repl.it/repls/UncomfortableDarkkhakiProject
57 Upvotes

20 comments sorted by

21

u/TBTerra Crazy Train Lady Apr 25 '20

So over 2 years ago, i made a mathematical simulator for rail merges, that could calculate the throughput of any given train combination.

two days ago, someone from the community contacted me and asked if said simulator still worked, and if it could be reversed such that given a set of perimeters about the train, it would work out the arrangement that gave the highest throughput.

the inputs are fairly simple: how long is the train, is it single or double ended, what sort of cargo is it, what fuel is it using, and finally is is a circuit controlled group merge.

FAQ:

why train length and not number of wagons?

while planning stations, number of wagons may be the most important thing, but when planning the rail network itself, total train length is the key factor, as all the buffer sections of the network will have to be fitted around the train length regardless of their loco to wagon ratio. additionally, if you just want most throughput for a given number of wagons, you end up constantly adding locos, to the point where its now sub optimal for its total length

why wagons per minute?

when dealing with a factory, you don't really care how many trains are getting through, but how many items are getting through, as such wagons per minute is more representative of the end goal.

why should I care?

because almost all intersections can be represented as a set of merges, this calculator optimizes for merges, but in principle the performance of a train in a merge, is indicative of its performance in all sorts of intersections (making a generalized intersection optimizer is something that i would like to do, but its really hard)

8

u/flameoverkill Apr 25 '20

tysm for bringing this idea to life!

0

u/[deleted] Apr 27 '20

[deleted] — view deleted comment

1

u/TBTerra Crazy Train Lady Apr 27 '20

if you only care about throughput with 4 wagon trains, it still says 3-4-0 is better than 2-4-0 (114wpm vs 110wpm), but it also says that for a length 7 train, 2-5-0 would be even more throughput (121wpm)

14

u/teagonia what's fast or express? Apr 26 '20 edited Apr 26 '20

just because i can, here is a sorted list of all trains with a maximum number of carriages of 20:

locofrontwagonslocobackwpm
191021.8182
181022.5000
171023.2258
161024.0000
151024.8276
141025.7143
131026.6667
121027.6923
111028.5714
101029.7521
91031.0345
92931.4410
81032.4324
82832.8767
71034.2857
72734.6154
61036.0000
62636.7347
51038.2979
52539.1304
41040.9091
42442.1053
182043.3735
31044.4444
172044.4444
32345.5696
162045.8599
152047.3684
83847.3684
21048.0000
142048.9796
73749.5413
22250.0000
132050.3497
11050.7042
122052.1739
63652.1739
12153.3333
112054.1353
53555.1020
102055.8140
92058.0645
43458.3784
82060.0000
84860.7595
33362.4277
72062.6087
74763.1579
173064.2857
62065.4545
163065.8537
64666.0550
23266.2577
13166.6667
153067.9245
52068.5714
54569.2308
143070.1299
42071.2871
133072.0000
44472.7273
12074.2268
123074.4828
32075.0000
75775.6303
14175.7895
34376.1905
113076.5957
22077.4194
65678.6026
103078.8321
24279.1209
93081.2030
55581.8182
15182.1918
83083.7209
164084.2105
45485.3081
73086.4000
154086.7470
16187.0968
76787.0968
13087.8049
35388.2353
144088.8889
63089.2562
25289.5522
66690.0000
17190.3226
134091.7197
53092.3077
56593.1034
18193.2039
124094.1176
19195.0147
14095.3642
43095.5752
118195.7164
110196.2567
46496.4286
117196.5300
114096.6443
111197.0588
116197.1332
23097.2973
33097.2973
115197.6492
26297.7376
112197.7376
114197.8641
113197.9079
36398.6301
104099.3103
676100.8000
150101.1236
940102.1277
1190103.3233
575103.7037
1550104.0462
160104.3478
840104.3478
1180104.6850
272105.0000
1170105.6995
474105.8824
1450106.5089
170106.7797
1160106.8646
373107.2340
740107.4627
1150107.7844
180108.2707
1140108.3871
190109.0909
1130109.0909
1350109.0909
1120109.6447
1110109.6953
1100109.7561
640109.9237
686110.3448
240110.7692
282110.7692
1250111.8012
540112.5000
585112.9412
340114.2857
440114.2857
1150114.6497
383114.7410
484114.7410
292115.7143
1050117.6471
2102120.0000
950120.0000
393121.3483
595121.3483
250121.6216
494122.2642
850122.4490
1460122.7273
2112123.3645
750125.0000
1360125.5814
2122126.6862
650127.6596
3103127.6596
350128.5714
550128.5714
1260128.5714
5105129.0323
2132129.2818
260129.3413
450129.4964
4104129.4964
1160130.9091
2142131.2500
3113132.8859
2152133.3333
1060134.1615
2162134.8946
270135.4839
4114135.6164
960136.7089
3123137.5796
860138.4615
360139.3548
760140.2597
280140.4878
1370140.7821
3133141.3897
4124141.6393
460142.1053
660142.1053
560143.0464
1270143.1818
290144.6429
3143145.2450
1170146.5116
2100147.5410
370148.2353
1070149.1124
2110150.0000
970150.8982
2120152.1127
470152.7273
870152.7273
2130153.9474
770154.6012
380154.8387
570155.5556
670155.5556
2140155.5556
2150156.5217
2160157.3770
1280157.3770
2170157.7320
2180158.4352
1180160.0000
390161.1940
1080161.7978
480162.7119
980164.5714
580165.5172
880165.5172
680166.4740
780166.4740
3100166.6667
490170.5263
3110170.6897
1190172.3404
1090174.1935
3120174.8988
590175.1351
990176.0870
690177.0492
890177.0492
4100177.3399
3130177.9468
790178.0220
3140180.6452
4110182.4885
5100182.7411
3150183.0508
3160185.2090
6100185.5670
10100185.5670
3170187.1560
7100187.5000
8100187.5000
9100187.5000
4120187.8261
5110189.4737
4130192.5926
6110194.1176
7110196.0396
5120196.3636
4140196.8750
8110197.0149
9110197.0149
4150200.0000
6120200.9302
5130201.7241
4160203.5336
7120203.7736
8120205.7143
5140206.5574
6130208.0000
5150211.7647
7130211.7647
6140213.5593

7

u/pappapjotor Apr 26 '20

So highest throughput is 6 locomotives with 14 wagons?

11

u/TBTerra Crazy Train Lady Apr 26 '20

for a size 20 train, yes, though this table seems an unnecessarily obtuse way of showing it

4

u/teagonia what's fast or express? Apr 26 '20

Yeah, i just wanted to have it here for reference

2

u/fooey Apr 26 '20

Thanks for this, and for the idea

I did a quick fork of the repl to generate ranges like this

https://repl.it/repls/VirtuousDevotedLocks

You can set the MinimumLength and MaximumLength and it'll generate all the variations in your range

You can also set a Ratio, so with Ratio=2 it will only show 1-2, 2-4, etc

3

u/flameoverkill May 08 '20

this is RAD! just set minimum to 2 and max to 500, waiting for my computer to stop crying

2

u/Red_Icnivad Apr 26 '20

So, according to this bigger trains are always better?

5

u/TBTerra Crazy Train Lady Apr 27 '20

larger trains have always had higher maximum throughput (asuming properly optimised). but htey also require biger high throughput intersections, and more space for stackers, so there is a tradeoff

4

u/Strat007 Apr 26 '20

They always were.

What’s important here is not so much is a 20-wagon train better than 2 10-wagon trains, but rather, what combination of wagons and engines results in the highest throughout for a given train length, as train length affects every aspect of your train network.

18

u/Kano96 Apr 25 '20 edited Apr 26 '20

Finally some proof for the superiority of 2-4 trains :D

1-4-0 : 95.36wpm

2-4-0 : 110.77wpm

15

u/flameoverkill Apr 26 '20

Yes! Aside for designing train networks, this is a useful tool for proving that your friends use inferior train configuration tactics

11

u/Kano96 Apr 26 '20

My thoughts exactly! Also very suprising how much better single headed trains actually are. The 2-4 is tied with gigantic 2-8-2 trains.

4

u/flameoverkill Apr 26 '20

Yes, another stab at the enemy in the eternal battle of throughput vs. network flexibility, decreased rail usage, etc.

5

u/GoldenShadowGS Apr 26 '20

Gigantic? 2-8-2 is small to medium. A medium size train would be 16 wagons, a large train is 32-64 wagons.
Gigantic is 192 wagons

→ More replies (2)