Maximum throughput of a rail line
Re: Maximum throughput of a rail line
The only problem i see with trains that need to go full speed for their max throughput is that it's not self correcting, if there is a sligth disturbance in the flow, the trains will slow down, and have even less throughput, which will make them slow down and have less throughput and so on. It's risky. They do not mix well with other trains or junctions.
Trains that are smaller can go so fast their start loosing throughput, that's true, but if happens a point in game where one add more trains and the density increase, it will reduce their max speed, and increase their flow, making the system overall more resilient.
If the things you need to ship are "far away", then it's my preference to use small trains instead of bots or belts, even for small quantity, imagine a dedicated subfactory that produce the satelite for the rockets. I would use bots but past a distance a 1-1 train or a 1-1-1 train. Many of my games it would allow me to capitalize on existing rails infrastructure because i have one anyway.
I would not allow such trains to cross the path of the 2-15 trains that i would use if i had to bring water to the nuclear plant. Those would have some sort of reserved network to go from lake to power plant with no junction closer than their length.
But for the other part of the factory, with 1-1 or 1-1-1 or 1-4-1 trains, i would make it easy on myself to make small station for blue circuits or low density structure or sulfuric acic for the uranium mine, or even red circuit you can fit so many in a single wagon. At this stage using "large trains" make the factory less smooth in its production,i do not make huge factory, so i would not want a single train to hold 12 hours worth of production for a single item. And those fast trains in junction-dense networks are not always allowed to reach their max speed but accelerate fast enough to reach a decent one still. That's very subjectuve and depending on one's own factory proportions.
Small trains are more likely to kill you because to transport the same quantity of good they travel more distance which statistically increase risks. High troughput lane are dangerous !
Trains that are smaller can go so fast their start loosing throughput, that's true, but if happens a point in game where one add more trains and the density increase, it will reduce their max speed, and increase their flow, making the system overall more resilient.
If the things you need to ship are "far away", then it's my preference to use small trains instead of bots or belts, even for small quantity, imagine a dedicated subfactory that produce the satelite for the rockets. I would use bots but past a distance a 1-1 train or a 1-1-1 train. Many of my games it would allow me to capitalize on existing rails infrastructure because i have one anyway.
I would not allow such trains to cross the path of the 2-15 trains that i would use if i had to bring water to the nuclear plant. Those would have some sort of reserved network to go from lake to power plant with no junction closer than their length.
But for the other part of the factory, with 1-1 or 1-1-1 or 1-4-1 trains, i would make it easy on myself to make small station for blue circuits or low density structure or sulfuric acic for the uranium mine, or even red circuit you can fit so many in a single wagon. At this stage using "large trains" make the factory less smooth in its production,i do not make huge factory, so i would not want a single train to hold 12 hours worth of production for a single item. And those fast trains in junction-dense networks are not always allowed to reach their max speed but accelerate fast enough to reach a decent one still. That's very subjectuve and depending on one's own factory proportions.
Small trains are more likely to kill you because to transport the same quantity of good they travel more distance which statistically increase risks. High troughput lane are dangerous !
Re: Maximum throughput of a rail line
I agree with pretty much all of that, but trains that need to go *slower* than their top speed to achieve max throughput are, 100% guaranteed, not achieving the maximum throughput of a rail line.
My one real objection is, if you're dealing with trains that have to brake to achieve peak throughput for those trains over that distance, if the route's consistently getting fed traffic at that rate I'm not sure it'll ever recover from introduced congestion. I get the feeling it'd just end up with a standing-wave jam and be reduced to single-line dispatch limits, wayyy below what you can get with metered dispatch into merge lanes.
edit: how about adding route distance and maybe merge-lane length to the parameters here?
My one real objection is, if you're dealing with trains that have to brake to achieve peak throughput for those trains over that distance, if the route's consistently getting fed traffic at that rate I'm not sure it'll ever recover from introduced congestion. I get the feeling it'd just end up with a standing-wave jam and be reduced to single-line dispatch limits, wayyy below what you can get with metered dispatch into merge lanes.
edit: how about adding route distance and maybe merge-lane length to the parameters here?
Re: Maximum throughput of a rail line
I think it is possible to argue although it is slightly different than the "max thoughput". Trains that "need to go slower than their max speed to achieve their max througput", they are "too fast", but that is akin to car on the highway. This is the question of drivers interest vs traffic flow interest. Drivers wants to go at the maximum speed they can achieve to minimize travel time, but that's way too high speed for max throughput. For a factory it's really up to the player to decide i think.
Considering the 1-1 trains that bring the satelite, if my subfactory is 10 km ( 5000 rails ) away from the rocket silo, the optimal speed for throughput is with 700 of those trains running at 100km/h ( rounding from the model) for around 64 satelite per minutes, a 5000 rails loop, considering they do a trip back and forth, is super long ! It may be in this case my interest to not care about the speed they go, allow them to go max speed, because that reduce the amount of trains i need for that particular ressource. Throughput is not the only consideration. If only need say 1 satelite per minute, then 4 trains is enough, they would run at max speed and that's fine. 1 of such train would have much more throughput by itself, because it would travel faster than the same train in a synced flow for max throughput. ( the train is like a taxi driver that gets value for kilometer traveled ). Edit : those numbers are considering trains only carry 1 satelite at a time i realized afterward![Sad :(](./images/smilies/icon_e_sad.gif)
Though if it faces congestion, i would miss on satelites, so i would add more trains, if the network is already dense, adding more trains would only slow those 4 trains, so they couldn't by themselves provide enough satelites, but their slowness would allow me to add 1 or 2 or 3 trains, without increasing the density of the network because they would use the space gained from the reduced braking distance of the 4 trains being in congestion. ( i'm exagerating ).
It is possible to think of "network capacity" based on the quantity of good your trains are able to delivered considering their average speed and their cargo, if you don't divide by the length of your network, faster trains are always better , in terms of efficiency of rolling stock maybe also UPS but it's easier for player to add more trains than more rails sometimes. Adding more rails always solve congestion or standing wave traffic jam, adding more trains , can but there is a limit, but that's what you NEED to do to get more ressources which you need for the factory you don't just add rails for the pleasure. I mean i do, but i dont think that's the majority of players.
The game is fun to me because you feel like you need to add more trains for the factory to grow, also rails to tap new ressources, and there is a invisible metric , unlike power where it's visible if you have enough supply / demand, you cannot know by numbers in game if you have enough rails for your trains, only if you have enough trains for your ressouces in the production tab. You have to look for traffic jams, and solve them, you are the traffic engineer !
Considering the 1-1 trains that bring the satelite, if my subfactory is 10 km ( 5000 rails ) away from the rocket silo, the optimal speed for throughput is with 700 of those trains running at 100km/h ( rounding from the model) for around 64 satelite per minutes, a 5000 rails loop, considering they do a trip back and forth, is super long ! It may be in this case my interest to not care about the speed they go, allow them to go max speed, because that reduce the amount of trains i need for that particular ressource. Throughput is not the only consideration. If only need say 1 satelite per minute, then 4 trains is enough, they would run at max speed and that's fine. 1 of such train would have much more throughput by itself, because it would travel faster than the same train in a synced flow for max throughput. ( the train is like a taxi driver that gets value for kilometer traveled ). Edit : those numbers are considering trains only carry 1 satelite at a time i realized afterward
![Sad :(](./images/smilies/icon_e_sad.gif)
Though if it faces congestion, i would miss on satelites, so i would add more trains, if the network is already dense, adding more trains would only slow those 4 trains, so they couldn't by themselves provide enough satelites, but their slowness would allow me to add 1 or 2 or 3 trains, without increasing the density of the network because they would use the space gained from the reduced braking distance of the 4 trains being in congestion. ( i'm exagerating ).
It is possible to think of "network capacity" based on the quantity of good your trains are able to delivered considering their average speed and their cargo, if you don't divide by the length of your network, faster trains are always better , in terms of efficiency of rolling stock maybe also UPS but it's easier for player to add more trains than more rails sometimes. Adding more rails always solve congestion or standing wave traffic jam, adding more trains , can but there is a limit, but that's what you NEED to do to get more ressources which you need for the factory you don't just add rails for the pleasure. I mean i do, but i dont think that's the majority of players.
The game is fun to me because you feel like you need to add more trains for the factory to grow, also rails to tap new ressources, and there is a invisible metric , unlike power where it's visible if you have enough supply / demand, you cannot know by numbers in game if you have enough rails for your trains, only if you have enough trains for your ressouces in the production tab. You have to look for traffic jams, and solve them, you are the traffic engineer !
Re: Maximum throughput of a rail line
You obviously have to delay trains when you have congestion allowing the blockage to clear. If you really want trains as tight as possible you have to manage each section between junctions separately. And manage it overall too, but then you are guessing at what routes trains will take at each junction.quyxkh wrote: ↑Sun Dec 17, 2023 9:02 pmI agree with pretty much all of that, but trains that need to go *slower* than their top speed to achieve max throughput are, 100% guaranteed, not achieving the maximum throughput of a rail line.
My one real objection is, if you're dealing with trains that have to brake to achieve peak throughput for those trains over that distance, if the route's consistently getting fed traffic at that rate I'm not sure it'll ever recover from introduced congestion. I get the feeling it'd just end up with a standing-wave jam and be reduced to single-line dispatch limits, wayyy below what you can get with metered dispatch into merge lanes.
edit: how about adding route distance and maybe merge-lane length to the parameters here?
But hey, with 2.0 and triggers you could add a traffic directing system. Using triggers and stops like "left, straight, right" to direct which turn a train takes at each junction.
Re: Maximum throughput of a rail line
New graph 2, Remastered edition
-Updated Velocity and friends to be a tiny bit more accurate
-Changed v_max to show the right unit
-Added a formula for S_0 that looks to give a good starting point for Newton's method for all vanilla configurations.
-Added functions for average speed and distance needed to reach minimum speed from rest
The math in this new graph should be equivalent to yours, though I kept the base of e to make finding integrals and derivatives easier. I also changed a and c since their purpose is to hide the mess of the velocity equation.
![Razz :P](./images/smilies/icon_razz.gif)
For a more satisfying explanation, I see it like this:
First train is at the minimum speed with its stop point at the beginning of an empty block.
Second train has its butt at the end of said empty block. Whatever speed the train should have when its end passes the end of a block is the speed this train currently has. This is a valid position because the first train needs to move forward for an entire cycle before a problem can cause it to slow down too much. By that time the second train will have moved an entire cycle, which means it moved an entire block, so the situation ends up right where it started.
Third train. Wait for the second train to finish its current cycle (as in reach the minimum speed), then place the third in front in the same way the second was placed in front of the first.
The same logic for the third train can be used for all the trains, filling up the infinite track. All trains have the same cyclical behavior. While distance between two adjacent trains varies, the amount of time apart they are is constant. Average speed is block length / cycle time.
This still wouldn't be modeling the effects of random disturbances or an imperfect simulation.
-Updated Velocity and friends to be a tiny bit more accurate
-Changed v_max to show the right unit
-Added a formula for S_0 that looks to give a good starting point for Newton's method for all vanilla configurations.
-Added functions for average speed and distance needed to reach minimum speed from rest
I think your formula for velocity is technically more accurate to the game, as mine makes the assumption of a perfect simulation with infinitely small time steps, though the difference seems to be minuscule within the domain relevant to the game. My e^c (after converting seconds to ticks like so: e^(c/60)) was approximately equal to your Rresist. Your Rreason and my -a/c are equal to the max speed due to drag, so I think the only real difference between the two formulas is the base of the exponential.mmmPI wrote: ↑Sat Dec 16, 2023 7:48 pm1) How to make a model for the train speed over time in tick (easier methodwith working example ) https://www.desmos.com/calculator/sd5of8hkgr :
The math in this new graph should be equivalent to yours, though I kept the base of e to make finding integrals and derivatives easier. I also changed a and c since their purpose is to hide the mess of the velocity equation.
That one's easy, the block has to open up when the train slows to the minimum speed otherwise the minimum speed wouldn't be the minimum speed.
![Razz :P](./images/smilies/icon_razz.gif)
For a more satisfying explanation, I see it like this:
First train is at the minimum speed with its stop point at the beginning of an empty block.
Second train has its butt at the end of said empty block. Whatever speed the train should have when its end passes the end of a block is the speed this train currently has. This is a valid position because the first train needs to move forward for an entire cycle before a problem can cause it to slow down too much. By that time the second train will have moved an entire cycle, which means it moved an entire block, so the situation ends up right where it started.
Third train. Wait for the second train to finish its current cycle (as in reach the minimum speed), then place the third in front in the same way the second was placed in front of the first.
The same logic for the third train can be used for all the trains, filling up the infinite track. All trains have the same cyclical behavior. While distance between two adjacent trains varies, the amount of time apart they are is constant. Average speed is block length / cycle time.
I meant that you have to use the graph to find max throughput, or some other iterative method. There's no convenient formula that just spits out the answer.
I'm pretty sure smaller block = better max throughput every time. You'd have to specify starting speed, or something to derive it with, to graph throughput across block sizes. That graph would be more interesting at lower starting speeds, but I don't think it'd be very intuitive.
You should know that even with a starting speed of zero, my graph still assumes the train spends exactly zero time at speed zero. To model a train needing to wait a bit before it can accelerate, I think x needs to represent cycle time. The minimum possible cycle time is when the train is at max speed, with a cycle time of zero only possible with a signal block length of zero. Cycle time in excess of what's needed for a minimum speed of zero represents the train waiting for the block to open up. Maybe negative speed could be used to represent this somehow. Stop and go traffic would need to be modeled this way I think.mmmPI wrote: ↑Sat Dec 16, 2023 7:48 pmAlthough i'm not sure what it means to calculate the maximum flow of a "traffic jam", the minimum throughput makes sense to me. It would represent a traffic jam so bad only 1 train can move at a time and the flow would be the acceleration inversely proportionnal to the number of train factored by their length. I suppose the "maximum" would be something like only 1 vehicule being impacted by the traffic jam otherwise there would be no traffic jam at all
This still wouldn't be modeling the effects of random disturbances or an imperfect simulation.
Good catch, though it looks like the overall results were still correct. This new graph will show the right unit.mmmPI wrote: ↑Sat Dec 16, 2023 7:48 pmEdit: actually i may have spotted something, i think there is a "k" factor missing in the vmax or the V0(max), as it doesn't show properly the correct speed cap when set in km/h i think it is stuck at showing 82.8 when it should be multiplied by 3.6 to show in km/h
Efficient inefficient design.
-
- Smart Inserter
- Posts: 2765
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Maximum throughput of a rail line
Once you all are done over-engineering the solution, something on page 1 will be updated with the answer so others don't need to read through the whole thing, right?
![Laughing :lol:](./images/smilies/icon_lol.gif)
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
![Laughing :lol:](./images/smilies/icon_lol.gif)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Maximum throughput of a rail line
I can add a link to my newest graph to my first post, but I think the last part of my throughput calculation is wrong so you'll have to wait a bit longer.FuryoftheStars wrote: ↑Tue Dec 19, 2023 5:44 pmOnce you all are done over-engineering the solution, something on page 1 will be updated with the answer so others don't need to read through the whole thing, right?![]()
![]()
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Efficient inefficient design.
Re: Maximum throughput of a rail line
I try to answer shortly, If you plan on using more than 1 train and signals , i don't think it's possible to do more than 700 wagons per minutes and that would still be 5000 wagons trains or something. But you will help the cause of science if you can find a counter example ! I need to read and test in game the new explanation and model from farcast.FuryoftheStars wrote: ↑Tue Dec 19, 2023 5:44 pmOnce you all are done over-engineering the solution, something on page 1 will be updated with the answer so others don't need to read through the whole thing, right?![]()
![]()
It's easier to give an answer when you know the train you wish to use, or if you want to compare different train to know how they do versus each other. That's why in the links you can choose the number of wagons and locos, more realistically 100 wagons per minutes is a good score for small trains using rocket fuel and good braking research (1 loco and 1 to 10 wagons ) , 200 wagons per minutes require one loco and 15 to 20 wagons and it becomes impractical in game, but if you use 2 locos then with 50 to 70 wagons you get a shot at more like 300 400 up to 500 wagons per minute depending how perfect condition of speed and many signals, no junctions, and so on.
It is difficult to present the "result" if you have so many parameters that can change the answer , animated graphs have their limits , one cannot make too many parameters varying at the same time and still hope to understand what's being shown. In current case, imagine a 3D coordinate system where one axis is for number of loco, one axis for number of wagon to describe all trains possible, and one axis for the speed at which they can run in game, each point in that 3D space has a different value for throughput. But you'd have such thing duplicated for every different signals placement and fuel and braking research combinaisons. It's ""easier"" to make a formula where you plug parameters and it gives you the value provided that value is accurate, which we are discussing ,it also require testings, the theorical max throughput assume infinite straight rail lane, or a loop with a definite amount of trains circling on it, it's not really what happens in game although i was working on something with recursive blueprint to automate some testings as this is factorio
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
-
- Smart Inserter
- Posts: 2765
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Maximum throughput of a rail line
Sorry, by "result" I was referring to the (OP requested) formula where we can plug in our own parameters and it gives us the answer based on the entered data.mmmPI wrote: ↑Tue Dec 19, 2023 7:24 pmI try to answer shortly, If you plan on using more than 1 train and signals , i don't think it's possible to do more than 700 wagons per minutes and that would still be 5000 wagons trains or something. But you will help the cause of science if you can find a counter example ! I need to read and test in game the new explanation and model from farcast.FuryoftheStars wrote: ↑Tue Dec 19, 2023 5:44 pmOnce you all are done over-engineering the solution, something on page 1 will be updated with the answer so others don't need to read through the whole thing, right?![]()
![]()
It's easier to give an answer when you know the train you wish to use, or if you want to compare different train to know how they do versus each other. That's why in the links you can choose the number of wagons and locos, more realistically 100 wagons per minutes is a good score for small trains using rocket fuel and good braking research (1 loco and 1 to 10 wagons ) , 200 wagons per minutes require one loco and 15 to 20 wagons and it becomes impractical in game, but if you use 2 locos then with 50 to 70 wagons you get a shot at more like 300 400 up to 500 wagons per minute depending how perfect condition of speed and many signals, no junctions, and so on.
It is difficult to present the "result" if you have so many parameters that can change the answer , animated graphs have their limits , one cannot make too many parameters varying at the same time and still hope to understand what's being shown. In current case, imagine a 3D coordinate system where one axis is for number of loco, one axis for number of wagon to describe all trains possible, and one axis for the speed at which they can run in game, each point in that 3D space has a different value for throughput. But you'd have such thing duplicated for every different signals placement and fuel and braking research combinaisons. It's ""easier"" to make a formula where you plug parameters and it gives you the value provided that value is accurate, which we are discussing ,it also require testings, the theorical max throughput assume infinite straight rail lane, or a loop with a definite amount of trains circling on it, it's not really what happens in game although i was working on something with recursive blueprint to automate some testings as this is factorio, i'm saying this because i'm enjoying over-engineering the "solution" and not sure i'd be done anytime soon
![]()
![Smile :)](./images/smilies/icon_e_smile.gif)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Maximum throughput of a rail line
That is puzzling to me, i was unsure if the "solution" would yield something that is like a curve intersecting what the discrete time in game would represent as flat portion right in the middle so that it works for second or tick or even smaller interval of timel. i'm still unsatisfied with my level of understanding but it's making progress. I think looking at the formulas from your graph made me realize where the 36000 newton per locomotive and the 450 drag come from. The 450 drag becomes 0.0075 if you do a unit conversion as ((450/(60*60))*60)/1000. As 450 drag is Newton per (meter per second) but if you want to express that per tick, you have to divide by 60*60 the newton due to s^-2, and multiply by 60 at the end, due to the "meter per second" and the third lane of the wiki's formula divide the mass of the train by 1000 in the equation that is using the 0.0075. So the unit for 0.0075 would be "(grams*tile/tick^-2)/(tile*tick^-1)" to make it look like Newton per (meter per second). The 36000 Newton is the same idea but counting the formula that uses 10*number_of_locos. Because that gives an acceleration in tile per tick, but it takes the mass as kilogram so it's only a weird time unit 36000 kg meter per second squared is 36000/(60*60)=10 kg meter per tick squared , for each locos ( multiplied by fuel bonus, divided by mass of train in kg ).farcast wrote: ↑Tue Dec 19, 2023 5:11 pmNew graph 2, Remastered edition
mine makes the assumption of a perfect simulation with infinitely small time steps,
the only real difference between the two formulas is the base of the exponential.
I'm not quite there yet x) but it gives me hope to make a model readable in second like yours, but using tick interval calculations. I have been shuffling the equations and giving them to some onlline solvers with different number of variable to see what they can do and it's not really the calculus that i'm fearing due to my overconfidence in online tools, but rather what to use the results for. I got this nice formula after some days where it said it couldn't find the result, one time it found it: the time it takes to reach a speed when given another speed :
((y^x)(a-b)+b)*216=c*216 solve for x
https://www.wolframalpha.com/input?i=%2 ... olve+for+x
y is the number between 0 and 1 by which the speed is multiplied to model the air resistance ( Rresist for me )
b is the max speed of the train
a the "initial speed"
c the "goal speed"
the conditions over a b and c means that you shouldn't try to plug a "goal speed" higher than max speed, or lower than "initial speed", 1 tile per tick is "216" km/h but they can be replaced by "d" i figure to help me converting units .
I suppose given the formula used i can replace x by 1 and have the speed of the next tick given the speed of current tick if solving for "c" which would be the way to math acceleration based on current speed (derivative ?) Not sure it is math-correct. In desmos one can write the integral symbol of a function and rely on the calculator to math the value without having the formula that describe the integral, i was planning on either doing that, or giving the formula to an online calculator, or watching some video explaining me why it didn't work but i'm unsure again, what i should try to math to represent how block length impact trains that is an earlier step than getting stuck at calculus
![Smile :)](./images/smilies/icon_e_smile.gif)
I think i understand your description it would represent all trains following a similar pattern of speed over time, which i tried a mockup with labels :
Not considering the speed 0,at first, the train would accelerate with an asymptotic curve, trending toward its max speed, which it may or not reach, because given the block length, it would mean that after accelerating that amount of time, the braking distance would reach the next block still occupied by the next train at which point the train start to decelerate during the amount of time labelled X. This is what is considered for the block lenght interaction ? To me it's not easy x) but if you could confirm that it would be helpful to me to make more sense of the formulas from your graph and/or make sure i can make test in game that are the conditions of the model or approaching.
On previous graph i made "min speed" very low to exagerate, thinking negative velocity would be a curve going lower than the horizontal axis, that should instead be modeled as 0 = flattening for some ticks. But did you mean "min speed" = 0 for exactly 0 time because it touches the axis as a limit and it's very close but still never ? or because min speed can be 50 km/h and it's far away from reaching 0 ? I'm not sure why the need for negative speed.farcast wrote: ↑Tue Dec 19, 2023 5:11 pmYou should know that even with a starting speed of zero, my graph still assumes the train spends exactly zero time at speed zero. To model a train needing to wait a bit before it can accelerate, I think x needs to represent cycle time. The minimum possible cycle time is when the train is at max speed, with a cycle time of zero only possible with a signal block length of zero. Cycle time in excess of what's needed for a minimum speed of zero represents the train waiting for the block to open up. Maybe negative speed could be used to represent this somehow. Stop and go traffic would need to be modeled this way I think.
This still wouldn't be modeling the effects of random disturbances or an imperfect simulation.
This still wouldn't be modeling the effects of random disturbances or imperfect simulation I think for that, or stop and go traffic, calculating the position of a train inside a series of 3 blocks relative to the other trains that are before and after it would be required , that similar to what you did but still a little different because you assume/represent some kind of periodicity after 1 cycle whereas i am considering the same situation to repeat with an offset in time which would be the traffic jam propagating.
I think the graph you made is modeling throughput interaction when block length is "too long" and trains would accelerate more than average speed, and then brake at the end ? so that would be the "worst case" when train enters a new block with the minimum speed they would have given their previous braking from a speed that was the speed they had when entering a block from minimum speed and accelerating up to the point where their braking distance reach the end of the block ? Hence the need for a method to find some polynomial roots ? It would be accurate because in game a train would behave this way instead of keeping a constant 60 km/h for best throughput in theory when the block is super long and the train can go faster it "would" go faster and be forced to start braking for "X" amount of time as i labeled in the prevous graph ?
I share the idea for smaller blocks in a single lane, now when it comes to applying ingame, when considering 2 different path of equal length in "rails" or "tile", i think the more densely signaled is seen as "longer in tile" for the pathfinder. So it could leads to situations where trains prefer going to lane with longer blocks despite them being worse for throughput. Also if you consider a very dense signaling, a train create a whole lot more "red signals" which are adding a flat (but proportionnaly larger and larger given smaller block length ) number of tile to what the pathfinder uses for distance calculation. This would lead to awkward situations when adding what is expected to be a "fast lane" because "smaller blocks" but then many trains avoid it and additionnal trains make the "slow lane" even worse instead. This is not "max throughput" discussion but rather network modelisation, it is related by the questionning of "how to use the model in game?", because "naively" adding the throughput of 3 lane with different signal spacing so that it the sume match expectation , and building them in paralel in game would leave the question of train distribution and descrepancies between model and ingame. I think it's a version of the Braess's paradox which highlights a situation where adding more rails to a network REDUCE throughput. I heard of the name from this video https://www.youtube.com/watch?v=cALezV_Fwi0 just after i said "adding rails reduce congestion" without disclaimer in previous post.farcast wrote: ↑Tue Dec 19, 2023 5:11 pmI'm pretty sure smaller block = better max throughput every time. You'd have to specify starting speed, or something to derive it with, to graph throughput across block sizes. That graph would be more interesting at lower starting speeds, but I don't think it'd be very intuitive.
![Neutral :|](./images/smilies/icon_neutral.gif)
Seeing the curve moving in Desmos while block length is vayring and trying to follow the maximum highlighted as a gray dot leads to already seemingly unpredictable trajectory ( apart from up and down) and the math are tough enough so that there's no need to add more counter intuitive things but it is interesting ! I think players would want to know the theorical throughput of their blueprint, with a given signal spacing based on the trains they use, as the smaller block past a junction is at least the size of a train in most networks, it is not often that i've seen signals closer to each other in between. It could be the default shown instead of 1 or close to 0. That would make one less question to ask oneself when using it for the first time.
Re: Maximum throughput of a rail line
Hot take:
Purely speed-derived train throughput means nothing if cargo is not being actually delivered anywhere.
For usual cargo max throughput is 27.69 items per second per stack inserter working, in ideal case (12 inserters) it'll be 332,28 items per second per wagon loading/unloading.
As unit count per wagon varies depending on cargo, exact load/offload time may vary. Worst case scenario (4000 items in wagon) = 12,04 seconds to fill/empty the wagon.
For liquids, it's ABOUT 12000 units per second per pump, ABOUT 36000 units per second per wagon w/ 3 pumps. Actual speed will be slower due to fluid mechanics peculiarities.
Wiki sez that three pumps are emptying full fluid wagon in 1.8 seconds.
Cheers!
Re: Maximum throughput of a rail line
True but that is not telling the maximum throughput for a rail lane, i think rather how many inserters you need to unload such throughput. The rough maximum ( for illustration) being around 700 wagons per minute (debated) that is 11.66666 wagons/second if it takes 12.04 second to empty a wagon with 12 inserters, then you need 11.6666*12.04 second per wagon * 12 inserter per wagon 1692 inserters !! ready at some unloading stations to deal with the material. Now if your train has say 20 wagons, you can fit 240 inserter per trains, which means you need at least, 1692/240 = 7.05, so 8 train stations working all the time ! But that is a minimum as in games trains are not always unloading, sometimes they move into the unloading stations :EustaceCS wrote: ↑Sat Dec 23, 2023 8:28 amHot take:
Purely speed-derived train throughput means nothing if cargo is not being actually delivered anywhere.
For usual cargo max throughput is 27.69 items per second per stack inserter working, in ideal case (12 inserters) it'll be 332,28 items per second per wagon loading/unloading.
As unit count per wagon varies depending on cargo, exact load/offload time may vary. Worst case scenario (4000 items in wagon) = 12,04 seconds to fill/empty the wagon.
You do need 3 pump per wagons, times the number of wagons in one train times the number of train arriving in 1.8 second. But that's again a minimum, that's considering the pump are working 100% of the time, while in game a train would sit in a station, and then leave, but while leaving the pumps would stop for some time. Let say it takes the same amount of time , that means 50% time uptime for the pump, because half time there is a train to unload, half time there is a train leaving the station, so that is as if they were emptying a wagon in 3.6 seconds, an effective speed of 1/2, so really you would need twice as many pumps as the previously considered minimum. ( or double the number of station since 3 pump for wagon is a maximum, like 12 inserters per wagons).
This is (supposedly) possible to calculate how much time a train takes to move a distance that is equal to the length of the train, so that a second train can come in directly and the pump are active again. the "50%" may be is "45%" maybe "10%". for long train with small number of locos, it will take more stations.If i knew how to calculate this i would explain futher, but i'm still trying to understand how farcast did it.
This is considering the network of trains as looking like [many loading station] => [1 long straigth lane of rail] => [many unloading stations]. The throughput that was discussed was the 1 long straight lane of rail one, what kind of trains and speed and signals to use to have the most wagons crossing a lane in a minute. But it is directly correlated to both how "many" loading and unloading stations are required to service that amount of trains because as you said, at some point cargo need to be loaded or unloaded. What you added is an additionnal constraint on the network, in order to use the models of max throughput , it sets conditions on the size of that loading and unloading area. Maybe also useful to add in the model , hey thanks for the remarks !
(edited the math to remove mistakes, sorry there was some, sorry if there are some still )
Re: Maximum throughput of a rail line
Exactly. There's no point in minmaxing train compositions if you can't use these efficiently.But that is a minimum as in games trains are not always unloading, sometimes they move into the unloading stations
Even with trains optimized for yeeting around cargo with near-instant acceleration to maximum and near-instant stopping, inserters are bottlenecks.
I believe, the only real question is how to make sure that a train arrives at each particular station (with perfect load/offload setup) each 13-16 seconds (for solids) or each 2-5 seconds (for liquids).
For which the answer might vary wildly depending on particular railroad network setup.
In the end, it will be much more convenient just to keep some loaded + some empty trains somewhere near their respective load / unload train stops. Just to make sure that there are always some train ready to occupy the station nearby.
Such resource "caching" shouldn't be much more of a problem, in comparison with tuning train arrival timings to milliseconds by other means just to increase the throughput by... a hundred a second?
Always a pleasure!Maybe also useful to add in the model , hey thanks for the remarks !
Re: Maximum throughput of a rail line
Well minmaxing train composition i don't know, but how to tell the difference between 1-1 trains and 1-1-1 trains and 1-4 or 2-15 trains otherwise, how to make an informed choice on which one to choose, when one only has an inference that it will yield different capacities ? Sure 1-4 trains have more throughput than 1-1 but how much ? In one case you need 4* as many trains ? or more ?EustaceCS wrote: ↑Sat Dec 23, 2023 2:38 pmExactly. There's no point in minmaxing train compositions if you can't use these efficiently.
Even with trains optimized for yeeting around cargo with near-instant acceleration to maximum and near-instant stopping, inserters are bottlenecks.
I believe, the only real question is how to make sure that a train arrives at each particular station (with perfect load/offload setup) each 13-16 seconds (for solids) or each 2-5 seconds (for liquids).
For which the answer might vary wildly depending on particular railroad network setup.
Also you can see the reasonning as you have 2 base separated by a long strech of rail, each base is a complex network, but things have to go through this long stretch of rail and you have oil, or plate ,or circuits, or science packs, and so on, you plan to add a science pack production in one side, but the circuit come from the other side, how many trains do you need ? is it possible to add many trains on that single lane or does it require building another parralel lane ?
Also you can see it as , i have main lane going north, and branches to connect outpost, how many iron can i get from the main lane ? because surely 1 or 2 outpost is fine, but 200 outpost is too many, the train will backlog and not leave the oupost to bring brack the ressource, the models allow to know when this happens. Or at least tell you the hard limit you cannot expect to achieve when using signals.
I agree keeping trains nearby stacked ready to unload is the way to go, but in my view, that would be what happen inside of the 2 bases separated by a network, or near the main base and at each outpost,it is how to deal with practical concern, "how to successfully use the throughput" using engineering techniques and clever station design, the model is not meant to be used to time train by millisecond, although doing so is a way to also fix a limit and help give an order of magnitude on how many station you need, if it's 3 or 76 it does make a huge difference maybe one is able to guess it's 10 to 20 times as much but knowing precisely can help making choice such as oh let's make 80 it's nice and round and the model help knowing those, 72 is also nice, but it wouldn't fit, maybe 92 is better because it gives more margin for imperfections like not timing inserter to the millisecond, but only to 15 second or so . I don't know to be honest what was the purpose of the original question, but i agree that in real game network topolgy and relation of junction is more important in most factories. But nothing prevent you from building only parralel lanes to achieve best efficency either that's all my model is able to predict for now, but it's doing it wellEustaceCS wrote: ↑Sat Dec 23, 2023 2:38 pmIn the end, it will be much more convenient just to keep some loaded + some empty trains somewhere near their respective load / unload train stops. Just to make sure that there are always some train ready to occupy the station nearby.
Such resource "caching" shouldn't be much more of a problem, in comparison with tuning train arrival timings to milliseconds by other means just to increase the throughput by... a hundred a second?
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: Maximum throughput of a rail line
TL DR: It passes the test for me , the numbers shown for max throughput given the impact of bock length seems to be accounted for properly, at least more than the precision of my test can allow for now
![Smile :)](./images/smilies/icon_e_smile.gif)
I have tested in game a loop designed so that the number of trains on it would be optimal,= so that the trains would take all the loop with their braking distance running at the perfect speed for throughput. That could be divided roughly in block of 35 tiles. Which for 1-5 trains according to model should be 173.6km/h per hour for a throughput predicted at 33.646 trains per minutes with a block length of 0, and 219 km/h, for a throughput of 25.863 trains per minutes with a block length of 35 which is significant, the train length being 42 tiles.
The test consisted into first finding a loop with appropriate dimension to fit a number of 1-5 trains so that their length and braking distance would fill the entire loop when they run at a speed close to 173.6 km/h, a Loop with 87 rail of length and 0 of height was choosen for its result are close to be achieved with 5 integers trains.
The measured throughput with block length of 1, is around 32.35 wagons per minutes, the 5 trains are running at 161 km/h , this was supposed to match the 33.646 trains per minutes, it shouldn't be higher otherwise it means the model is wrong, it can be lower, this means my setup is not perfect, i am going to assume it is because a block length of 1 is not possible in corners, but there may be more reason to explain if one wants to be more precise in the measuring.
Now with block length of 35, and 5 trains, it creates a traffic jam, there is not enough block/too much density. As visible in the test loop. So instead i tested with 3 trains.
This would in theory possibly allow them to go a little faster than with 5 trains, but the throughput should be roughly the same maybe a little lower with 3 than with 5 as the number of train doesn't matter for farcast model and sound quite counter intuive that there would be no big difference in train per minutes with 3 or 5 trains in the same small loop. The prediction from the model says the maximum throughput with 35 block length would see trains running at 219 km/h and a total throughput of 25.856 trains per minutes. In game it correspond to trains running at 214km/h and 25.85 trains per minutes. Which is very close and at this point it's also possible it's the signal spacing around corner being 35.8 tile block that creates this or something similar.
in total there are 6 loops, 2 are only 84 tiles long, and the counter have been adjusted to make up for this, same with the number of trains when it's 3 or 5.
It took only 1/10 of the time i alredy spent trying to automate the testings, i have also not been able to find proper way to math the acceleration from the derivative of the speed to try and reproduce the part i understand in what you did, i may try some more but i think instead i will try to do the integral of the speed to try and find the position, to know how much time a stopped train need to leave room for the next in the station. Rather i think i will try to use partial sum for the series because that seem less complicated, and still possibly accurate since time is discrete in factorio that's the same idea than the integral though.
Re: Maximum throughput of a rail line
Used a new formula and compiled some other in this graph : https://www.desmos.com/calculator/qcpjdzlm9e
New formula show the distance travelled by a train during acceleration up to its maximum speed in function of time.
(purple curve => first value: time in tick ; second value : distance travelled in meter)
Speed in game is the black curve
( first value : speed in km/h ; second value : time in tick to achieve from speed 0 )
Speed cap is the red horizontal line, in km/h.
Speed if not capped would be the blue dotted lane that extend.
The distance travelled becomes then inaccurate, the green dotted lane that extend the purple curve is not what happens in game, it would be without the speed cap.
The orange curve is the same as purple = accurate because limited to the correct interval, expressed in km for distance and second of acceleration, it becomes visible when trains are slow to accelerate , it is also possible to change to log scale for the graph, Desmos allows but it may be less intuitive to read though it look cool.
Desmos link contain all the formula for throughput in different folders but only the mentionned curves are set to be visible, and the axis sized and labelled accordingly.
Current preset correspond to a 1-2 train, with nuclear fuel, it reaches max speed between tick 309 and 310, (309.352) and at this time it has travelled 233.302 meters ( or tile). I have tested also with different trains a few value in game for time spent, is speed correctly predicted ? and is train located at the mark made with belt x rails after the starting point ? and it seem to be accurate.
I suppose it's similar to the displacement in the other graph, which is one part necessary to math the interaction with the block length. But it's not clicking yet.
The method used to make the graph is the partial sum of the arithmetico geometric sequence, i think that's the proper wording in english, it makes a function that so far is not piecewise so not yet correct, the second part should be the distance added each tick when the train speed is capped by the game but instead it is using Desmos restrictions so that curve is not drawn past the point when speed is calculated to have reached the game cap.
I learned those in french, and as such i'm still a bit confused between series, sequence, progression and words, on this particular math it would seem that it's only the french that refers to those this way and use the notation Un+1 = aUn + b, it seemed familiar from the textbook i found online last time so reused formula and demonstration, but the partial sum is more advanced i think or at least worse algebra,it was not present in the highschool book and i could only find a wikibook, but it was only in french, and had no translation, that puzzled me, and when trying to find an equivalent in english, i realized it's not just langage translation, but somewhat different method for doing/teaching those.
The formula i used is the last one on this page : https://fr.wikibooks.org/wiki/Les_suite ... 3%A9trique
( you can ignore the french it's mostly math)
with U0 being the initial speed, so 0 in Desmos, but could be any speed really, it would tell how much distance travelled x ticks after starting time, if train begins at 50km/h or 0 km/h, it's U0 that has to change in tile per tick that's why i kept it in the formula as 0- something.
b/(1-a) is Rreason for me , or really the max speed of the train based on the physical constant, not the game cap. The "fix point" would be word to word translation from how they call it in french, and i couldn't find the name in english. from the original speed expression as sequence so that Un+1= aUn+b given from the wiki after combining the 3 lanes.
That makes it the "a" in the formula being the rresist. a number between 0 and 1 , like 0.9987 by which the speed is multiplied each tick to model the air resistance.
and "n" is the time, so it is "x" in Desmos for the graph as everything is expressed "per tick".
Now this page has no translation in other langage , i only found that page seemingly the closest equivalent in english => https://en.wikipedia.org/wiki/Arithmeti ... c_sequence But the formulas and proof are differents, it does mention gabriel staircase which is what helped me understand the demonstration from that french textbook, and the special case of "linear difference equation" but it's not the same, i found this one too https://proofwiki.org/wiki/Sum_of_Arith ... c_Sequence , where it's barely any langage but math both seem related but not the same level of generalization, i was not required to deal with such general form formulas x) i used a shortcut.
I think there is a link between function integrals and sequence sums that was explored and it yielded a method called gregory-newton method but that's not the same as the Newton–Raphson method to find roots to polynomial. That's confusing me because i'm not familiar with any i suppose it's the Newton-Raphson method that is used in the model by farcast,but there's this long video that relate "sequence math" and "function math", https://www.youtube.com/watch?v=4AuV93LOPcE , and at 28 minutes or so it is using the gregory-newton method and the segment is called "sum=integral", it is the video referenced [9]from the wikipage https://en.wikipedia.org/wiki/Finite_difference at Newton's serie , but i went to the wiki because i found the video difficult and too large scope
What seem logical to me is that for discrete time, the speed in tile per tick, at every tick, summed, would amount to the distance travelled. For continous time, it would then be the integral of the speed over time curve, the area of the surface beneath this curve. Where for discrete time it's a sum of areas of rectangle under such curve which when their width is tending to smaller and smaller instead of a constant 1 tick, represent more and more the continuous time that's like "(infinitesimal )calculus", that's what i see in the video also in french it's still 2 words to prevent confusion because "calcul" is the french word used for "computation" or as a verb (also works for calculating person and "gallstone" is "calcul biliaire" not sure the logic). Anyway, it's just extra obvious for french that calculus has to do with things turning infinitly small that's in the name.But i can't explain the formula i used better than showing source. And i'm still not sure how to use this formula to find the throughput based on block length and speed, It can be used to know how much time a train takes to leave a train stop from speed 0 though.![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Edit: updated link to graph now really contains properly labelled axis and is not the older version :/
Also fun fact : If you increase the number of loco at the same rate as the number of wagon, by 1, so 1-1 or 2-2 or 3-3 or 4-4, the distance and time required to reach max speed with nuclear fuel seems to stays the same.
New formula show the distance travelled by a train during acceleration up to its maximum speed in function of time.
(purple curve => first value: time in tick ; second value : distance travelled in meter)
Speed in game is the black curve
( first value : speed in km/h ; second value : time in tick to achieve from speed 0 )
Speed cap is the red horizontal line, in km/h.
Speed if not capped would be the blue dotted lane that extend.
The distance travelled becomes then inaccurate, the green dotted lane that extend the purple curve is not what happens in game, it would be without the speed cap.
The orange curve is the same as purple = accurate because limited to the correct interval, expressed in km for distance and second of acceleration, it becomes visible when trains are slow to accelerate , it is also possible to change to log scale for the graph, Desmos allows but it may be less intuitive to read though it look cool.
Desmos link contain all the formula for throughput in different folders but only the mentionned curves are set to be visible, and the axis sized and labelled accordingly.
Current preset correspond to a 1-2 train, with nuclear fuel, it reaches max speed between tick 309 and 310, (309.352) and at this time it has travelled 233.302 meters ( or tile). I have tested also with different trains a few value in game for time spent, is speed correctly predicted ? and is train located at the mark made with belt x rails after the starting point ? and it seem to be accurate.
I suppose it's similar to the displacement in the other graph, which is one part necessary to math the interaction with the block length. But it's not clicking yet.
The method used to make the graph is the partial sum of the arithmetico geometric sequence, i think that's the proper wording in english, it makes a function that so far is not piecewise so not yet correct, the second part should be the distance added each tick when the train speed is capped by the game but instead it is using Desmos restrictions so that curve is not drawn past the point when speed is calculated to have reached the game cap.
I learned those in french, and as such i'm still a bit confused between series, sequence, progression and words, on this particular math it would seem that it's only the french that refers to those this way and use the notation Un+1 = aUn + b, it seemed familiar from the textbook i found online last time so reused formula and demonstration, but the partial sum is more advanced i think or at least worse algebra,it was not present in the highschool book and i could only find a wikibook, but it was only in french, and had no translation, that puzzled me, and when trying to find an equivalent in english, i realized it's not just langage translation, but somewhat different method for doing/teaching those.
The formula i used is the last one on this page : https://fr.wikibooks.org/wiki/Les_suite ... 3%A9trique
( you can ignore the french it's mostly math)
with U0 being the initial speed, so 0 in Desmos, but could be any speed really, it would tell how much distance travelled x ticks after starting time, if train begins at 50km/h or 0 km/h, it's U0 that has to change in tile per tick that's why i kept it in the formula as 0- something.
b/(1-a) is Rreason for me , or really the max speed of the train based on the physical constant, not the game cap. The "fix point" would be word to word translation from how they call it in french, and i couldn't find the name in english. from the original speed expression as sequence so that Un+1= aUn+b given from the wiki after combining the 3 lanes.
That makes it the "a" in the formula being the rresist. a number between 0 and 1 , like 0.9987 by which the speed is multiplied each tick to model the air resistance.
and "n" is the time, so it is "x" in Desmos for the graph as everything is expressed "per tick".
Now this page has no translation in other langage , i only found that page seemingly the closest equivalent in english => https://en.wikipedia.org/wiki/Arithmeti ... c_sequence But the formulas and proof are differents, it does mention gabriel staircase which is what helped me understand the demonstration from that french textbook, and the special case of "linear difference equation" but it's not the same, i found this one too https://proofwiki.org/wiki/Sum_of_Arith ... c_Sequence , where it's barely any langage but math both seem related but not the same level of generalization, i was not required to deal with such general form formulas x) i used a shortcut.
I think there is a link between function integrals and sequence sums that was explored and it yielded a method called gregory-newton method but that's not the same as the Newton–Raphson method to find roots to polynomial. That's confusing me because i'm not familiar with any i suppose it's the Newton-Raphson method that is used in the model by farcast,but there's this long video that relate "sequence math" and "function math", https://www.youtube.com/watch?v=4AuV93LOPcE , and at 28 minutes or so it is using the gregory-newton method and the segment is called "sum=integral", it is the video referenced [9]from the wikipage https://en.wikipedia.org/wiki/Finite_difference at Newton's serie , but i went to the wiki because i found the video difficult and too large scope
![Neutral :|](./images/smilies/icon_neutral.gif)
What seem logical to me is that for discrete time, the speed in tile per tick, at every tick, summed, would amount to the distance travelled. For continous time, it would then be the integral of the speed over time curve, the area of the surface beneath this curve. Where for discrete time it's a sum of areas of rectangle under such curve which when their width is tending to smaller and smaller instead of a constant 1 tick, represent more and more the continuous time that's like "(infinitesimal )calculus", that's what i see in the video also in french it's still 2 words to prevent confusion because "calcul" is the french word used for "computation" or as a verb (also works for calculating person and "gallstone" is "calcul biliaire" not sure the logic). Anyway, it's just extra obvious for french that calculus has to do with things turning infinitly small that's in the name.But i can't explain the formula i used better than showing source. And i'm still not sure how to use this formula to find the throughput based on block length and speed, It can be used to know how much time a train takes to leave a train stop from speed 0 though.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Edit: updated link to graph now really contains properly labelled axis and is not the older version :/
Also fun fact : If you increase the number of loco at the same rate as the number of wagon, by 1, so 1-1 or 2-2 or 3-3 or 4-4, the distance and time required to reach max speed with nuclear fuel seems to stays the same.
Re: Maximum throughput of a rail line
I was not satisfied with the depth of previous tests, and my understanding of the formulas, so i did some research and found this mod that i think is very useful to test the models :
https://mods.factorio.com/mod/SpeedLimitSignsForTrains
It works as a special signal that when passed once will limit the maximum speed a train will try to achieve when accelerating, so in a loop , after 1 lap for all trains it force them into as much as a constant speed as they can achieve if not forced to brake. Like it would occur in a traffic jam / stop and go traffic.
Here is a gif highlighting how i used it :
In the upper loop, the train are limited to 55 km/h, and it's slightly too much, so traffic jam occurs, you can see the wave propagating fast, if you look closely at 1 train and follow it around, you will notice it stops 7 times before being immobilized back at the same location after 1 lap which is also around the cycle of the gif and some sort of magic number at this stage.
Whereas in the bottom loop trains are limited to 50 km/h, and it's just perfect, there is no traffic jam forming, the throughput is better. Though it's not quite what's predicted by farcat model as the "maximum for this speed". Around 10 trains per minutes when no jam , versus less than 9, something like 8.90 when there is a traffic jam. When there is a jam, the trains failed to reach the average speed of 50km/h but instead only gets around to 44.28 km/h estimated average based on time to go across 1 lap given the number of train and counted train per minutes.
This when the model says the maximum will be as high as 15 train per minute which seem too tough of a challenge, or too generous of a maximum for trains at 50km/h with 34 or 35 signal block length. To me it seems the maximum throughput with this signal spacing at 50 km/h is lower than the model says, and not only due to my imperfect experiment.
Here is the map that features the 2 loops, and 2 extra so all of you can play with the limit yourself
:
Notice there is also a mod so that train are being refueled by robots, so you can really play with the speed limit and fast speed ![Smile :)](./images/smilies/icon_e_smile.gif)
Also some calculus progress https://www.desmos.com/calculator/8ebh1y8mcy
Managed to get the acceleration over time by taking the limit to 0 for h of the sum of 2 term separated by an index h, of the "speed" sequence as given by the wiki.
Then used desmos to draw the integral using the symbol, and it matched the speed that i got previously so i know my formula are properly related.
Then i got a little overboard with algebra and solvers so i rewrote the formulas for speed overtime under another form, checked using the integral symbol that it matched the displacement, this way it is possible to make a function that shows displacement accuratly even after train's acceleration is nullified by game's max speed cap solving earlier limitation of the displacement formula. Which I also rewrote under other forms because why not at this point , it was helpful to find the inverse velocity formula which i kind of of understand why it's going to be useful, but it's slow progress.
Roughly , if you go 1 hour at 50 km/h and 1 hour at a 100 km/h, then the average speed is 75 km/h over 2 hours and 150 km that's easy. but if you travel 50km at 50km/h and then 50 km at 100km/h the time is 1hour 30 or 1.5 hours, this is (50/50)+(50/100) the speed is at the bottom of the fraction, it's distance/speed, and this relate to block length and inverse velocity, in one case the quantity that stays 1 (or constant) is the 1 hour, so they are additionned, but in the other the quantity that stays the same is the distance travelled 50km, the upper part of the fraction. Seems obvious but i never had to think about that.
For now this function is used to draw a vertical lane to show when the train reach max speed as defined by the game, and is yielding undefined, because infinity , when the train has too many wagons to ever stop accelerating in game. 1-5 trains are reaching 298.08 km/h in between 593 and 594 ticks after they begin acceleration and at this stage they have travelled 451 meters, no 452 , oh no when zooming in , the integrals and the other formula are not agreeing exactly by like 0.7 tiles ? Maybe the inverse of the displacement function will help, so one can give it 451 meter, and it will give 593 ticks ,or maybe 592, i mean around 10 second. I think i'm still quite far from "good" understanding but progressing. Though i'm puzzle nowwhy the model says 15 trains per minutes is the maximum at 50 km/h with 1-5 trains nuclear fuel and 34 tile between signal whereas i can't get more than 10 with experiments ? not sure what is source of error because, yeah, the model's math are tough x)
https://mods.factorio.com/mod/SpeedLimitSignsForTrains
It works as a special signal that when passed once will limit the maximum speed a train will try to achieve when accelerating, so in a loop , after 1 lap for all trains it force them into as much as a constant speed as they can achieve if not forced to brake. Like it would occur in a traffic jam / stop and go traffic.
Here is a gif highlighting how i used it :
In the upper loop, the train are limited to 55 km/h, and it's slightly too much, so traffic jam occurs, you can see the wave propagating fast, if you look closely at 1 train and follow it around, you will notice it stops 7 times before being immobilized back at the same location after 1 lap which is also around the cycle of the gif and some sort of magic number at this stage.
Whereas in the bottom loop trains are limited to 50 km/h, and it's just perfect, there is no traffic jam forming, the throughput is better. Though it's not quite what's predicted by farcat model as the "maximum for this speed". Around 10 trains per minutes when no jam , versus less than 9, something like 8.90 when there is a traffic jam. When there is a jam, the trains failed to reach the average speed of 50km/h but instead only gets around to 44.28 km/h estimated average based on time to go across 1 lap given the number of train and counted train per minutes.
This when the model says the maximum will be as high as 15 train per minute which seem too tough of a challenge, or too generous of a maximum for trains at 50km/h with 34 or 35 signal block length. To me it seems the maximum throughput with this signal spacing at 50 km/h is lower than the model says, and not only due to my imperfect experiment.
Here is the map that features the 2 loops, and 2 extra so all of you can play with the limit yourself
![Uber Geek :ugeek:](./images/smilies/icon_e_ugeek.gif)
![Smile :)](./images/smilies/icon_e_smile.gif)
Also some calculus progress https://www.desmos.com/calculator/8ebh1y8mcy
Managed to get the acceleration over time by taking the limit to 0 for h of the sum of 2 term separated by an index h, of the "speed" sequence as given by the wiki.
Then used desmos to draw the integral using the symbol, and it matched the speed that i got previously so i know my formula are properly related.
Then i got a little overboard with algebra and solvers so i rewrote the formulas for speed overtime under another form, checked using the integral symbol that it matched the displacement, this way it is possible to make a function that shows displacement accuratly even after train's acceleration is nullified by game's max speed cap solving earlier limitation of the displacement formula. Which I also rewrote under other forms because why not at this point , it was helpful to find the inverse velocity formula which i kind of of understand why it's going to be useful, but it's slow progress.
Roughly , if you go 1 hour at 50 km/h and 1 hour at a 100 km/h, then the average speed is 75 km/h over 2 hours and 150 km that's easy. but if you travel 50km at 50km/h and then 50 km at 100km/h the time is 1hour 30 or 1.5 hours, this is (50/50)+(50/100) the speed is at the bottom of the fraction, it's distance/speed, and this relate to block length and inverse velocity, in one case the quantity that stays 1 (or constant) is the 1 hour, so they are additionned, but in the other the quantity that stays the same is the distance travelled 50km, the upper part of the fraction. Seems obvious but i never had to think about that.
For now this function is used to draw a vertical lane to show when the train reach max speed as defined by the game, and is yielding undefined, because infinity , when the train has too many wagons to ever stop accelerating in game. 1-5 trains are reaching 298.08 km/h in between 593 and 594 ticks after they begin acceleration and at this stage they have travelled 451 meters, no 452 , oh no when zooming in , the integrals and the other formula are not agreeing exactly by like 0.7 tiles ? Maybe the inverse of the displacement function will help, so one can give it 451 meter, and it will give 593 ticks ,or maybe 592, i mean around 10 second. I think i'm still quite far from "good" understanding but progressing. Though i'm puzzle nowwhy the model says 15 trains per minutes is the maximum at 50 km/h with 1-5 trains nuclear fuel and 34 tile between signal whereas i can't get more than 10 with experiments ? not sure what is source of error because, yeah, the model's math are tough x)
Re: Maximum throughput of a rail line
So it did help understanding a little better what the inverse of function look like on a graph , because unlike the previous inverse of velocity , the inverse of the displacement, a function that can take a distance in meter, and it would tell the time needed for a stopped train to travel that distance, looks real nice in my eyes, and is visually telling.
(orange curve is inverse of displacement, and purple curve is displacement)
https://www.desmos.com/calculator/mo6wfkfv7d
Now the formula itself is not pretty ,it's much more complicated than the displacement, it's an approximation using the lambert W function or productlog function that is not existing in Desmos. and i had never heard of before https://en.wikipedia.org/wiki/Lambert_W_function
When plugging the formulas into wolfram alfpha and asking for "the inverse of the displacement" , literally https://www.wolframalpha.com/input?i2d= ... 5D+inverse
It showed the need for it, i thought i made a mistake because wolfram alpha uses "log" for the natural logarithm but that means log base 10 for Desmos, or something similar, maybe brackets parenthesis, or wrong typing that happens a lot, but several form of the displacement function attempted for an inverse all gave function containing one form of that product log or omega or lambert W function. So i documented from youtube, it sounds like college math , there's plenty videos about it, i watched this serie https://www.youtube.com/playlist?list=P ... ymJ1AlThUN , it's not trying to make it sound overly complex, i'm not going to try paraphrase , just that it's necessary to compute the inverse of function that look like f(x)= a^x +bx or f(x) =x^x which is what the displacement formula contain.
Eventually i found a formula on the internet with no author using search engines, so i linked the original and copied the formula. I could remove most of it because the function has 2 branches, and only 1 is necessary given the value used by the game, as far as i tested the inputs that the inverse displacement function could generate for the W function it contains. The formula is looking similar to those documented in the section "representation" from the wiki, it's not using Newton's method to approximate the value but that was mentionned as a possibility, it's still an approximation but using integrals of another function from 0 to pi and multiplying by pi over x that is a good point for me. There were other Desmos representation people from the internet made but it wasn't always yielding proper result or was defined in the value that the game generate.
This one looks visually right, but is accurate only before train reach its max speed considering the geometric relation with the displacement that i tested in game with 1-0 1-1 and 1-5 trains. After that, it will overestimate the train speed , because it doesn't know under this form that the train has its speed capped by the game. Then there is another source of inaccuracies due to the product log function, but it's not more than 0.5% from the test value plugged in. This is all built on shaky grounds
Thing is , the graph for throughput require a formula even more complex i think. Based on what i think the graph from farcast is doing, that would be similar formula but with the twist that it should be possible to give a certain initial speed. Such speed would be the speed at which a train enters a block. This is because a train running at say 150 km/h will have a braking point that may "hit" the next block still occupied, forcing the train to decelerate, so that the braking point is kept within the block available. Maybe the train will reach 120 km/h , and then start accelerating again because at this point the following block is empty. As such the speed required would be 120 km/h that's the speed when a train enters a block. Then the question, if a train enter a block of length 35 at 120 km/h, it will reach maybe 150 km/h, and then be forced to brake, and re-accelerate. Because in game without limiter that's how train behave when the speed is 135 km/h and that's the expected result from the model. 135 km/h with block length 35 is an average of how much distance is travelled at 120 km/h and 150km/h and all the intermediate during the pattern.
It is possible to find a nice looking formula to express displacement overtime , considering there is a variable "c" that would be the 120 km/h. That could be left as a parameter for a 2 variable function in desmos displacement(x,c)=distance where x is time and will be used to graph, and "c" is to compute based on train and block length, that's a single value, the value at which a train would run when entering the block. The inverse of that function contains too many character for the free version of Wofram alpha https://www.wolframalpha.com/input?i=f% ... 29+inverse
I have attempted with less nice looking formula to express the displacement, to request the inverse too, but it always yield the same exact result written the same way which is too many characters for the wolfram alpha free version, but can be written https://www.wolframalpha.com/input?i=%2 ... %28a%29%29
which is just slightly under the limit when the W function is written as W and not "product log function" which waste a lot of character.
At this point i suppose the next step is to test this formula or to try and express how to compute "c" . it seem to be what's called minimum speed in the other model but also the formulas look like i made a mistake in the exercice or choosen the worst possible method. if anyone has any clue i would consider it carefully x)
I am more confident in the test result for the model at higher speed than 50km/h when considering block length is not 0 or 1. But when looking at it a bit more it's not so surprising that at 50 km/h the model gives "wrong result" considering it also gives a throughput for train at 0 km/h . Maybe it's just an artifact of the approximation method calibrated for speed that are "reasonnable" in vanilla, closer to 150+ 300 km/h or their max speed. At least i learned why omega is 0.56... but i'm still puzzled by 55 km/h leads to traffic jam but not 50 km/h , and why 10 train per minutes or 8.90, and not 15. The original question is really hard eh ?
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Re: Maximum throughput of a rail line
Graph number 5, 5 times the math, 50 times the effort, 5% more accurate.
I must confess, the previous graph was horribly, terribly wrong. My mistake was calculating throughput using the distance between two trains at a single point in time, which can vary over time, as I mentioned before. What I should have done was calculate the amount of time needed for a train to reach the position of the train in front of it. That unfortunately means needing to do all the same calculations again, but slightly differently.
The second set of calculations is for the time it takes the rear of a train at the start of a cycle to reach the end of the block it started in, and adding that to the total number of cycles that can be completed before getting too close to the next train's starting position.
Most of my time spent on this graph was thinking about approximation functions, specifically for the inverse of the displacement of the train's stop point over time. For some reason, the formula for stop point is too hard for wolfram alpha to find an inverse of. I tried, but I can't figure it out either. I simplified it to (e^(-2x) + (a - 2)e^(-x) + ax) = y but couldn't get any further. 'a' is a variable that's based on train stats so I can't just replace it with a constant. I just decided to make my own approximation function.
I know I need the lambert W function for the inverse of train displacement, but I found sqrt(x^2 - 1) is a surprisingly good approximation for the inverse of y = e^(-x) + x. It's not good enough to use directly but it works as a start for Newton's method.
For the inverse of stop point displacement, I thought to use a rational function, since those are good for modeling asymptotic behavior and I somewhat understand them. This is made infinitely harder by needing to define all coefficients in terms of a.
Based on the above equation, and adding (1 - a) to make it pass through point (0 , 0), the inverse function needs to asymptotically approach the line y = (x + a - 1) / a as x -> +infinity.
I found that (d/dx(f(x)))^-1 gets the derivative of the inverse of f at the point (f(x) , x). Using that, and replacing x with sqrt(x) in the original function to effectively square its inverse function, I was able to investigate why a square root seems to work so well for this. While before the slope diverges near x = 0, after being squared, the slope of the inverse function looks to approach 2 / (2 + a). I have no idea how to actually prove this, but looking like it works is good enough for me. All the other derivatives diverge both before and after.
Getting the slope at x = 0 right is important because that forces the %error to approach 0 if the inverse function also passes through (0 , 0). For x = 0, only the constant and linear coefficients in a rational function affect its slope.
Since I've put the entire inverse function inside a square root, then asymptotic behavior becomes y = ((x + a - 1) / a)^2.
I learned that a rational function will asymptotically approach the result of polynomial long division. Put another way, as long as the degree of the numerator is less than the degree of the denominator, the overall function will approach whatever is being added outside the rational function. Rather obvious in hindsight.
From all of this, and spending a bit too much time playing with regressions in desmos and watching how it changes the coefficients, I was able to cobble together something that works about as well as the sqrt(x^2 - 1) function did for values of a >= 0.4.
Eventually, I had to admit to myself that I don't know what I'm doing, and finally looked up what I'm supposed to do.
Pade approximants looks like the right subject. The key detail is a pade approximant is a rational function that matches as many derivatives as possible for a single point of the function you want to approximate. Sadly this didn't work, as I can't take the derivative at x = 0. If I use some other point, I can't guarantee it'll pass through (0 , 0). On top of that, this will only approximate the function near the point you use, and does nothing to prevent vertical asymptotes where you don't want them.
I have more ideas, and I'll probably keep trying different things, but the lowest value for 'a' I've seen from vanilla train stats is ~0.85, so my hand-crafted, artisanal approximation function is already good enough... after using Newton's method, of course.
Here's a graph where you can mess around with a 1/4 pade approximant if you want. It's mostly set up so you just need to insert the derivatives of the function you want to approximate in the taylor series calculations.
I must confess, the previous graph was horribly, terribly wrong. My mistake was calculating throughput using the distance between two trains at a single point in time, which can vary over time, as I mentioned before. What I should have done was calculate the amount of time needed for a train to reach the position of the train in front of it. That unfortunately means needing to do all the same calculations again, but slightly differently.
The second set of calculations is for the time it takes the rear of a train at the start of a cycle to reach the end of the block it started in, and adding that to the total number of cycles that can be completed before getting too close to the next train's starting position.
Most of my time spent on this graph was thinking about approximation functions, specifically for the inverse of the displacement of the train's stop point over time. For some reason, the formula for stop point is too hard for wolfram alpha to find an inverse of. I tried, but I can't figure it out either. I simplified it to (e^(-2x) + (a - 2)e^(-x) + ax) = y but couldn't get any further. 'a' is a variable that's based on train stats so I can't just replace it with a constant. I just decided to make my own approximation function.
I know I need the lambert W function for the inverse of train displacement, but I found sqrt(x^2 - 1) is a surprisingly good approximation for the inverse of y = e^(-x) + x. It's not good enough to use directly but it works as a start for Newton's method.
For the inverse of stop point displacement, I thought to use a rational function, since those are good for modeling asymptotic behavior and I somewhat understand them. This is made infinitely harder by needing to define all coefficients in terms of a.
Based on the above equation, and adding (1 - a) to make it pass through point (0 , 0), the inverse function needs to asymptotically approach the line y = (x + a - 1) / a as x -> +infinity.
I found that (d/dx(f(x)))^-1 gets the derivative of the inverse of f at the point (f(x) , x). Using that, and replacing x with sqrt(x) in the original function to effectively square its inverse function, I was able to investigate why a square root seems to work so well for this. While before the slope diverges near x = 0, after being squared, the slope of the inverse function looks to approach 2 / (2 + a). I have no idea how to actually prove this, but looking like it works is good enough for me. All the other derivatives diverge both before and after.
Getting the slope at x = 0 right is important because that forces the %error to approach 0 if the inverse function also passes through (0 , 0). For x = 0, only the constant and linear coefficients in a rational function affect its slope.
Since I've put the entire inverse function inside a square root, then asymptotic behavior becomes y = ((x + a - 1) / a)^2.
I learned that a rational function will asymptotically approach the result of polynomial long division. Put another way, as long as the degree of the numerator is less than the degree of the denominator, the overall function will approach whatever is being added outside the rational function. Rather obvious in hindsight.
From all of this, and spending a bit too much time playing with regressions in desmos and watching how it changes the coefficients, I was able to cobble together something that works about as well as the sqrt(x^2 - 1) function did for values of a >= 0.4.
Eventually, I had to admit to myself that I don't know what I'm doing, and finally looked up what I'm supposed to do.
Pade approximants looks like the right subject. The key detail is a pade approximant is a rational function that matches as many derivatives as possible for a single point of the function you want to approximate. Sadly this didn't work, as I can't take the derivative at x = 0. If I use some other point, I can't guarantee it'll pass through (0 , 0). On top of that, this will only approximate the function near the point you use, and does nothing to prevent vertical asymptotes where you don't want them.
I have more ideas, and I'll probably keep trying different things, but the lowest value for 'a' I've seen from vanilla train stats is ~0.85, so my hand-crafted, artisanal approximation function is already good enough... after using Newton's method, of course.
Here's a graph where you can mess around with a 1/4 pade approximant if you want. It's mostly set up so you just need to insert the derivatives of the function you want to approximate in the taylor series calculations.
Efficient inefficient design.
Re: Maximum throughput of a rail line
Nice a new graph !farcast wrote: ↑Sun Dec 31, 2023 6:20 amGraph number 5, 5 times the math, 50 times the effort, 5% more accurate.
I must confess, the previous graph was horribly, terribly wrong. My mistake was calculating throughput using the distance between two trains at a single point in time, which can vary over time, as I mentioned before. What I should have done was calculate the amount of time needed for a train to reach the position of the train in front of it. That unfortunately means needing to do all the same calculations again, but slightly differently.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
I was not done understanding the previous one, and i need more time to think about this one, but from a first read, i think you will have no problem understanding what i have attempted to do since my previous one and maybe you'd like to have a look at what it look likes when someone that never heard of the tool you used try to solve the problem while i'd be busy learning some new math
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
https://www.desmos.com/calculator/oyn45fbmql
I was able to get the braking distance over time for an accelerating train that started stopped in function of mass cube
![Smile :)](./images/smilies/icon_e_smile.gif)
Desmos can show the "result" in 2 differents ways, but i am not able to reuse the value that it is drawing. Once it is a vertical line at the exact moment in time, the other it's the moment when the fonction reaches 0. I thought that it is attempting to measure the same as what you did , the displacement of the stopping point over time. And when it is equal to block length train start braking. I played with the inverse of displacement function, but i felt it wasn't enough still to get that moment which would be necessary to know the throughput, despite "knowing" already how much time a train will need to clear itself, or reach the next signal, or even clear the amount of space that it is occupying with its tails in the last block it is partially standing on.( but that would help knowing the propagation rate of stop and go i thought ).
Also i did more research on the lambert W function that i found online and used, and it appers as the first one on the spanish wikipedia page , the integral is a little different bound, but the formula and results are the same maybe i misunderstood but it seem to be the one used in MAPLE reference [1].
Will try to understand the approximation of the displacement of the stop point over time. Because i can understand the reasonning of why one would want to know that, i will try to make it so that desmos can reuse the value it approximate when drawing the curve that is "Braking distance overtime + displacement overtime" or maybe get to understand why it cant. Maybe i could get wolfram to find the inverse of the braking distance over time and try to make the sum of those 2 inverse function , inverse braking distance and inverse displacement. But at this point i'm not yet understanding the reasonning behind the operation.
I wish i knew where to look up what i'm supposed to do
![Smile :)](./images/smilies/icon_e_smile.gif)