How the pathfinder works with stations.
Moderator: OpenTTD Developers
How the pathfinder works with stations.
Simple question , does the pathfinder apply a penalty to trains going via a station when the station isnt in their orders , when there is an alternative route which doesnt involve going thru the station.
eg if there are stations A,B and C and a train has orders to go from A to C , and has 2 options , go directly or go via Station B will it prefer the route which doesnt have station B in it.
tnx
eg if there are stations A,B and C and a train has orders to go from A to C , and has 2 options , go directly or go via Station B will it prefer the route which doesnt have station B in it.
tnx
Re: How the pathfinder works with stations.
A quick test would indicate that there is - see attached photo and closely look at Mr Horsey, who is circled in red.
Mr Horsey is fine with taking the middle line, but if I remove that one, he will refuse to take the outer loop and go through the Ilkley station.
A second test might give us an idea on how big the penalty is:Mr Horsey is fine with taking the middle line, but if I remove that one, he will refuse to take the outer loop and go through the Ilkley station.
Re: How the pathfinder works with stations.
Thanks, sort of explains what Im seeing.
However if the direct route is substantially shorter than the route thru the station, I still get trains going thru the station even though the station isnt in their orders.
The odd thing is there seems to be some randomness involved as some of the trains which go thru the station dont always do it.
Ill have to play around and try and figure out what the penalty is .
However if the direct route is substantially shorter than the route thru the station, I still get trains going thru the station even though the station isnt in their orders.
The odd thing is there seems to be some randomness involved as some of the trains which go thru the station dont always do it.
Ill have to play around and try and figure out what the penalty is .
Re: How the pathfinder works with stations.
You can see the value in openttd.cfg :
https://wiki.openttd.org/en/Archive/Man ... ttd.cfg#pf
I'm assuming the various station penalties are for that. Doesn't seem to be too big. If you want vehicles to avoid stations at all cost if not in their orders I guess you could increase it.
https://wiki.openttd.org/en/Archive/Man ... ttd.cfg#pf
I'm assuming the various station penalties are for that. Doesn't seem to be too big. If you want vehicles to avoid stations at all cost if not in their orders I guess you could increase it.
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: How the pathfinder works with stations.
The pathfinder does not only consider distance, but applies penalties for a lot of things, so maybe your short route sometimes gets additional penalties (because there are trains there that make signals red) making the longer route "cheaper" from a pathfinder perspective.
You can modify the penalties, or add waypoints to force certain routes or make the detour less likely by placing two way path signals against the direction (which trigger the yapf.rail_pbs_signal_back_penalty every time, so that adds quite a penalty quite fast).
You can modify the penalties, or add waypoints to force certain routes or make the detour less likely by placing two way path signals against the direction (which trigger the yapf.rail_pbs_signal_back_penalty every time, so that adds quite a penalty quite fast).
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: How the pathfinder works with stations.
Perhaps if you share a screenshot of the relevant parts of your network, someone will be able to figure out why your train isn't behaving as you expect it to.
Re: How the pathfinder works with stations.
This is a simplified picture of the problem .
The trains all travel from left to right, from the entry points to the exits.
The actual track is much longer than in the picture, the sections A-B,C-D,E-F and G-H are 100 square long undersea tunnels with signals in the tunnels, the entries and the exits are on the land.
The station is on an island , so section D-G is on the land and sect and B-E is a tunnel..
Trains can enter from either entry1 or entry2 , and some of them stop at the station, others dont.
There is no problem with trains which have the station in their orders, as they will either go straight if entering on entry2, or will crossover if entering from entry1 and go thru the station.
The problem is with trains which dont have the station in their orders, and some will randomly still go thru the station regardless of which entry point they enter from.
This can cause the track section from C-D to clog up if there are already trains in the station.
The non station track A,B,E,F is very busy, the station track not so much.
Using JGRs patchpack ver 0.39.
Any ideas welcome.
The trains all travel from left to right, from the entry points to the exits.
The actual track is much longer than in the picture, the sections A-B,C-D,E-F and G-H are 100 square long undersea tunnels with signals in the tunnels, the entries and the exits are on the land.
The station is on an island , so section D-G is on the land and sect and B-E is a tunnel..
Trains can enter from either entry1 or entry2 , and some of them stop at the station, others dont.
There is no problem with trains which have the station in their orders, as they will either go straight if entering on entry2, or will crossover if entering from entry1 and go thru the station.
The problem is with trains which dont have the station in their orders, and some will randomly still go thru the station regardless of which entry point they enter from.
This can cause the track section from C-D to clog up if there are already trains in the station.
The non station track A,B,E,F is very busy, the station track not so much.
Using JGRs patchpack ver 0.39.
Any ideas welcome.
- Attachments
-
- Flarninghead Transport, 1950-03-13.png
- (790.61 KiB) Not downloaded yet
Re: How the pathfinder works with stations.
pathfinder penalties are a delicate thing, a lot of things may go wrong if they are used incorrectly. you can view the current settings when opening the console and typing "list_settings pf.yapf.rail" (most likely the default values)
some basic rules on how to interprete these settings:
some basic rules on how to interprete these settings:
- a basic tile has a penalty of 100. other penalties are usually a multiple of that. this basically means "how many tiles detour are you considering to avoid this tile". whichever path has the lowest cumulative penalties is considered the "shortest"
- there are "static" and "dynamic" penalties.
- static penalties are the same across the whole map, and only change when you change the map (e.g. build something), and are independent of where the trains are. these are things like stations, curves, level crossings, etc.
- dynamic penalties change on their own when trains move. these are things like reserved tiles, red signals or occupied platforms. because these cannot be cached, there is a limit how far ahead of the train this is considered. (default is 10 signals). most notably the results of this will be different whether you use block or path signals
Re: How the pathfinder works with stations.
First of all: pathfinding isn't random. Not at all. It's math. There can be many reasons why trains use certain paths.
The following statements are based on my own knowledge and research and can be wrong. (If this is the case, please correct me in a polite manner.)
YAPF doesn't calculate the best path for infinitely long distances. If the way to the destination is too long, the pathfinder estimates the best path just by the part of each path it can calculate. In your case the problem could be, that the station is just too far away, so it doesn't even appear in the calculation for the best path.
The following statements are based on my own knowledge and research and can be wrong. (If this is the case, please correct me in a polite manner.)
YAPF doesn't calculate the best path for infinitely long distances. If the way to the destination is too long, the pathfinder estimates the best path just by the part of each path it can calculate. In your case the problem could be, that the station is just too far away, so it doesn't even appear in the calculation for the best path.
I tested your simplified version. All the trains use the correct path around the station. (Except I build the station just 1 tile long and put other trains all along the upper track A-F).
Re: How the pathfinder works with stations.
I believe that the YAPF pathfinder also takes previously used routes into account when trying to find a route. I. e. if in a train's previous cycle of its order list it went through a station rather than around it because the path bypassing the station was blocked at that time, it will prefer to take the same route again on this cycle, unless that route is blocked (which incurs a pathfinder penalty) or significantly longer than the alternatives.
Regardless of my personal speculation / semi-knowledge, if you want a train to bypass a station with 100% certainty, you should explicitly order it to do so through use of waypoints and "via" orders.
Regardless of my personal speculation / semi-knowledge, if you want a train to bypass a station with 100% certainty, you should explicitly order it to do so through use of waypoints and "via" orders.
Re: How the pathfinder works with stations.
Yes,the via is also the only solution that I think will work reliably too, so todays fun job is a lot of order changes.
tnx all.
tnx all.
Re: How the pathfinder works with stations.
I found a fix.
It never seems to amaze me what kind of things exist in this game that you never know about.
JGRs patchpack provides for changing the routefinding on a per signal basis.
So implementing the following route finding restriction on the block signal just to the left of the Letter C fixes the problem.
Start
if current order is not Flarninghead Woods
Deny
endif
End
So any trains that dont specifically have the station name Flarninghead Woods in their orders cant get past the block signal near C , so all get routed onto the thru track.
Exactly what I was trying to achieve.
It never seems to amaze me what kind of things exist in this game that you never know about.
JGRs patchpack provides for changing the routefinding on a per signal basis.
So implementing the following route finding restriction on the block signal just to the left of the Letter C fixes the problem.
Start
if current order is not Flarninghead Woods
Deny
endif
End
So any trains that dont specifically have the station name Flarninghead Woods in their orders cant get past the block signal near C , so all get routed onto the thru track.
Exactly what I was trying to achieve.
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: How the pathfinder works with stations.
If the station bypass-track A-B-E-F is very busy, the penalty of the trains on that track might be higher than the penalty of passing the station.mauried wrote: ↑18 Nov 2021 00:14 This is a simplified picture of the problem .
The trains all travel from left to right, from the entry points to the exits.
The actual track is much longer than in the picture, the sections A-B,C-D,E-F and G-H are 100 square long undersea tunnels with signals in the tunnels, the entries and the exits are on the land.
The station is on an island , so section D-G is on the land and sect and B-E is a tunnel..
Trains can enter from either entry1 or entry2 , and some of them stop at the station, others dont.
There is no problem with trains which have the station in their orders, as they will either go straight if entering on entry2, or will crossover if entering from entry1 and go thru the station.
The problem is with trains which dont have the station in their orders, and some will randomly still go thru the station regardless of which entry point they enter from.
This can cause the track section from C-D to clog up if there are already trains in the station.
The non station track A,B,E,F is very busy, the station track not so much.
Using JGRs patchpack ver 0.39.
Any ideas welcome.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: How the pathfinder works with stations.
I don't think this could happen that easily when he didn't change any penalties. The basic penalty for passing stations is 1000 per station tile. The penalty of the red signals for the next 10 signals can get up to about 2000. So if the station is longer than 2 tiles, the penalty should be way higher than the red signals ever are able to be.Transportman wrote: ↑20 Nov 2021 13:46 If the station bypass-track A-B-E-F is very busy, the penalty of the trains on that track might be higher than the penalty of passing the station.
Re: How the pathfinder works with stations.
It doesn't. YAPF is stateless with respect to the vehicles. It does some global caching, but as Eddi said this only for the static penalties which are not influenced by vehicle movement.
Reserved tiles have a penalty by itself, so it is not just the signals but also the amount and length of trains on the section.LaRoso wrote: ↑20 Nov 2021 15:18 I don't think this could happen that easily when he didn't change any penalties. The basic penalty for passing stations is 1000 per station tile. The penalty of the red signals for the next 10 signals can get up to about 2000. So if the station is longer than 2 tiles, the penalty should be way higher than the red signals ever are able to be.
Re: How the pathfinder works with stations.
This is new to me, and I didn't find anything like this in the source code. I know that there is a penalty for red signals and the basic cost for each tile. Would you like to show me the place where this is calculated? (I hope it doesn't spam this thread, so maybe also as private message)
Re: How the pathfinder works with stations.
take a look at these:
these are the costs for a reserved rail tile (includes occupied tiles even without path signals), and a reserved station tile
Code: Select all
yapf.rail_pbs_cross_penalty = 300
yapf.rail_pbs_station_penalty = 800
Re: How the pathfinder works with stations.
Oh I see, thank you very muchEddi wrote: ↑21 Nov 2021 13:56 take a look at these:these are the costs for a reserved rail tile (includes occupied tiles even without path signals), and a reserved station tileCode: Select all
yapf.rail_pbs_cross_penalty = 300 yapf.rail_pbs_station_penalty = 800
-
- Transport Coordinator
- Posts: 283
- Joined: 29 Nov 2014 23:23
Re: How the pathfinder works with stations.
Waypoints are a godsend...the longer the distances inherent in your work orders, the more discombobulated dear YAPF becomes around your comprehensive network...you must dance with and pamper it at all costs to reap its abundant rewards.
The lone weakness I've found with YAPF is its glitchiness with duplicate orders...I had the same destination both at the beginning and the end of a work order; having forgot to eliminate one of the duplicates when saving and exiting, upon opening the corresponding save, the vehicle had been skipped to the last one of the duplicates from the first one, and thus had been flipped to the top of the work order...queer vulnerability, I suppose.
The lone weakness I've found with YAPF is its glitchiness with duplicate orders...I had the same destination both at the beginning and the end of a work order; having forgot to eliminate one of the duplicates when saving and exiting, upon opening the corresponding save, the vehicle had been skipped to the last one of the duplicates from the first one, and thus had been flipped to the top of the work order...queer vulnerability, I suppose.
Re: How the pathfinder works with stations.
That's strange. I have experimented quite a bit with complex order lists, and I have never seen a vehicle skip any orders when it shouldn't. Every time I thought I got such a case, it turned out to be my own error.
For example, if the order list looks like A → A → B → C → .., and there is no direct path from A to A, the train will take the long route through B, C and any other stations on the way. When you spot a train between B and C that's headed for A, this might look as if some orders have been skipped.
For example, if the order list looks like A → A → B → C → .., and there is no direct path from A to A, the train will take the long route through B, C and any other stations on the way. When you spot a train between B and C that's headed for A, this might look as if some orders have been skipped.
Who is online
Users browsing this forum: No registered users and 16 guests