Open hyperknot opened 2 years ago
You need to edit scoring-rules.config.js
and add a scoring rule with a closingDistanceFixed: 0.4
I added the change to the scoring rules here: https://github.com/hyperknot/igc-xc-score/blob/6bca0fe83ed608a09261b2eb8eab982f4ce5e167/scoring-rules.config.js#L124
My problem is that it's not doing the optimal calculation. The best point would not be on the track, but between the "head" and the "tail" of the tracklog, as illustrated here. Do you think you can modify the app to make such calculations?
Are FFVL and XContest calculating the closing differently? Also, what is the difference between code: fai
and tri
?
An fai
triangle must be almost equilateral with none of its sides being smaller than 28% of the total perimeter.
Do you have a link to a document explaining those rules? Normally all points must lie on the track.
Sure, it's here: https://www.fai.org/sites/default/files/civl/documents/sporting_code_s7_d_-_records_and_badges_2022.pdf
It's not an easy read, but I believe it's like on my drawing:
Ok, so in fact all turnpoints and the start/finish points are 400m cylinders?
Yes. But for the turnpoints it makes no sense to make them cylinders, it's easier to calculate them as points. The trick is the start/end cylinder.
In fact this rule can be interpreted as a 800m closing rule? It is a bijection:
I think a straight 800 meter line is not optimal. The optimal solution would be a "buffer" operation around both polylines and then finding the furthest point on this polygon.
I think that it is. You think that a 800m rule will leave out points that will be included in the buffers? I don't see any case where this is possible?
It's very close to optimal but not optimal. I don't know how much we want to optimise those few meters though. I made a Geogebra sketch. The left point is the 800 meter midpoint, the right point is the optimal one.
A very simple algorithm I could imagine is:
2r
is a better closing then the angled r+r
- it keeps more of the track
It's true but FAI calculates by the triangle sides, which in our case is determined by the center of the circle.
Do you mean the turnpoints or the closing? The placement of the closing center does not influence the score, only the part of the track that is included or not influences the score. But this is not true for the turnpoints, this was my first question?
The FAI document is really quite low in details, but here is how I understand it:
All FAI rules use 400m cylinders. This means that if you are following a predefined task, you must cross into the 400m cylinder for the turnpoint to be considered attained.
When scoring a free triangle - which means that you define the best possible task given your existing flight track - it is in your best interest to define the turnpoint 400m away from the actual triangle vertex. This rule will require some adapting of igc-xc-score
.
The closing is defined as a single point that must be not further than 400m from each side of the track. This rule should be perfectly satisfied by using 800m as closing distance.
I wonder if there is some clever way to calculate the size of the biggest triangle that has vertices lying on equal circles around the given triangle - there probably is - as this will be much easier to implement.
I am positive that these are similar triangles but I do not see any easy proof
The inside triangle is the actual triangle on the flight track. The outside triangle is the biggest triangle that fits if its vertices lie on the 400m circles of the inside triangle vertices.
In the FAI rules, every time they calculate using the center of a cylinder (in declared records), you always have to subtract 2 400 meters for that cylinder. With straight or straight-with-3-points free distance records, you don't use cylinders, thus you don't need to subtract 2400 meters for them.
Now for this case, it's really not clear. I'd believe that we cannot cheat, thus if we don't subtract then we have to take the closest points of those circles. (This is the reason why I wrote that for the 2 mid-points it doesn't make any sense to add a circle and then select the original point in the next step).
I'll ask them about clarification, it makes no sense to develop the wrong method :-)
Do you have any examples of scored flights?
Unfortunately here they don't provide any details: https://www.fai.org/records?f%5B0%5D=field_record_sport%3A2026&f%5B1%5D=field_record_category%3A125&f%5B2%5D=field_subclass%3A231&f%5B3%5D=field_type_of_record%3A330
I wrote them an email asking for clarifications.
I got an answer from FAI:
5.2.5. Validation Using Start, Turn or Finish Cylinders The record or badge distance shall be calculated as the minimum distance it is possible to fly by entering the cylinder observation zones. See 1.5.13.3.1. The minimum distance is defined as the straight-line distance between each pair of turn points, decreased by 800 meters for each turn point and 400 meters for each Start/Finish point.
So I believe we can put these circles wherever we want, the calculation is through the centers - 3 * 800 meters.
The way I understand this is that the current scoring method is the right one - because it measures the triangle from the points on the flight track - which are 400m away from the turnpoint - however the placement of the turnpoints is not - because they must be further away. But I don't understand the significance of the 400m for the Start/Finish point since the placement of the Start/Finish point is not supposed to have any effect on the score - except for yes/no validity of the triangle. Can you find at least one example of a scored triangle flight?
The writing "400 meters for each Start/Finish point." I believe is from the straight distance flights, where the points are different. In our case they are the same and it's 800 meters.
I'll ask them if they can share a scored triangle flight, it's not published on the website.
Now I think we need to optimise all 3 points, as the record is calculated by the center points. I don't think it makes sense but the rules say this so we have no choice.
If this is indeed the case, I think this may be done without modifying the underlying search algorithm - once the inner triangle is found, the outer one can be directly computed.
I think for the mid-points we can do that, yes. For the start/endpoint I have no other idea but to make a one-off gradient descent-like algorithm.
FAI replied that they use SeeYou, which optimises the distances totally bad. So it's good to know that there is no software which can actually optimise for what FAI is writing in Section 7D. If we can modify igc-xc-score it'd be the first software to do this correctly.
I don't think there is anything to do for the start finish point? It does not participate in the score at all - it is only about validity - yes/no.
Those triangles can be calculated from their medians - the medians of the outer triangle are exactly the medians of the inner triangle + 400m.
This means that:
Ma = sqrt(2 * AC**2 + 2*AB**2 - BC**2)
Md = sqrt(2 * DF**2 + 2*DE**2 - EF**2) = sqrt(2 * AC**2 + 2*AB**2 - BC**2) + 400m
for each median
I think I just figured it out. Basically igc-xc-score is doing everything perfect as it is now, with closingDistanceFixed: 0.8
.
The drawing in Section 7D about the triangle are wrong.
Free distance around a triangle: • a closed course flight via 3 position checkpoints, independent of the position of the start/finish point. The official distance is given by the sum of the legs of the triangle formed by the position checkpoints.
Basically the question is if the "Mercedes star" type FAI triangles are allowed or not. I really believe they are, and this simplifies our calculation a lot!
Here is an example current world record which is a "Mercedes star" like: https://www.xcontest.org/2019/world/en/flights/detail:brigitte.kurbel/24.06.2019/07:01 and the record: https://www.fai.org/record/18974
igc-xc-score calculates 269.12 km, the FAI record was 269.13 km.
So we have 5 points to optimise: TP1, TP2, TP3, start (cp_in), end (cp_out), which is working perfectly in the current version.
I just did run this IGC and my results are 269.12 when using Vincenty's method (hp=true
) and 269.13 - the same as the FAI record - when using the much faster approximative formula known as the US FTC method (it was first published by the US FTC in some document about measuring distance between radio emitters and it is famous for being mistaken in the first edition).
I think that it is up to the FAI to clarify this situation.
Their official document states that distances are to be measured according the WGS84 ellipsoid. However (there is a very length explanation about this in the project's README), there is no analytical method for calculating this distance. There is the FTC approximation and there is the iterative Vincenty's method which can be repeated as many times as it is needed to obtain arbitrary precision - igc-xc-score stops at 60cm.
Most practical applications use the FTC method which is much faster since normally a distance of 10m won't matter that much over 270km - but since this is a world record, there should probably be a very strict official method for measuring it.
Also, when it comes to scoring the flight, there is one more point that I forgot about - the closingDistanceFree
parameter - because according to some governing bodies, the closing distance is to be substracted from the total distance, while for others (the French FFVL), there is a free (3km) closing distance that does not incur a penalty at all. I am sorry, but I totally forgot about this.
I think for the measurement it has to be Vincenty, that is the reference calculation for geographic distances. FAI currently uses SeeYou which from my experimenting produces the least precise calculation, GPSDump does a much more precise one for example.
For closingDistanceFree
in our case it's equal to closingDistanceFixed
, as the 800 meter is not subtracted at the end.
BTW from what I've seen on the cli, it seems like the distance value is not subtracted (in km), but the point is subtracted (when using 1.0 scoring). So if I looked at the distance value it's the same with or without closingDistanceFree
, is that right?
Not strictly this ticket, but related: this flight gets calculated as 141 km in igc-xc-score (XContest profile) and 138 km in XContest. Do you know what could be the reason? Better optimisation or some rules are wrong? https://www.xcontest.org/world/en/flights/detail:szabbbolcs/27.6.2022/09:20
I am sorry for the late reply, but I was exceptionally busy.
The two programs produce a nearly identical scoring: 220.88 for XContest and 221.15 for igc-xc-score.
The 3km difference comes from the fact that igc-xc-score displays the total distance of the triangle and the penalty for the closing distance while XContest displays the total distance of the triangle minus the penalty.
The 200m difference comes from the higher resolution used by igc-xc-score - the XContest scoring has simplified the line, eliminating some points. igc-xc-score considers every point coming from the GPS.
Thanks for the explanation, so that part is by design.
Now, a much more important question, is it possible to implement out-and-return distance as per FAI definition?
Free out and return distance: a closed course flight having one position checkpoint.
This is similar to "tri", or "flat-triangles", but FAI has a very different definition which makes it a totally different scoring.
Basically it only needs TP1, cp_in, cp_out with closingDistanceFixed: 0.8. I guess it could be a much simplified case of the tri code.
Yes, this is a very simple type of flight with only point that needs searching, I will probably have more time to work on this August.
@hyperknot do you have any examples of flights and their score following this new scoring type?
@hyperknot do you have any examples of flights and their score following this new scoring type?
The current world record: https://www.xcontest.org/2018/world/en/flights/detail:primozs/21.04.2018/06:52 FAI link: https://www.fai.org/record/18462
What you cannot test on this one is how the "unscored leg" is handled, as obviously world record holders make perfectly planned flights. I mean that the normal flat triangle allows you to make a "bonus leg" at the very end, like on a triangle, but on this distance it is not possible. The start point has to be before the first turn point.
In fact, this type of flight has only cp_in
which is also cp_out
(with a fixed closing distance of 800m) and TP1
?
Yes, I believe: takeoff - cp_in - TP1 - cp_out (d=800) - landing
There can be two turnpoints - since you can launch, fly to point 1, then fly to point 2, then fly back to close. Here is a very good example: https://www.xcleague.com/xc/info/rulesflights-circuit.html
I get 303.35km on this flight when using Vincenty's
There can be two turnpoints - since you can launch, fly to point 1, then fly to point 2, then fly back to close. Here is a very good example: https://www.xcleague.com/xc/info/rulesflights-circuit.html
No, this is where FAI differs from anyone else:
It doesn't make any sense for me, but they define it as having only one turnpoint.
Ok, I implemented it with 2 TPs, I will do both variants https://github.com/mmomtchev/igc-xc-score/tree/oar
(by the way, off-topic, was the Enzo 3 available in 2018??)
Thanks, that looks great! I recommend changing all the multipliers to 1.0 to make it easier to get some information out of it, used for scoring.
Enzo 3 came out in 2017, unbelievable!
301,94km with the FAI rules
Do you have a close up screenshot or GeoJSON? I'd be curious to see how does it handle the closing?
@hyperknot Alas, I am missing one optimization that requires me to really rework the closing - in this type of closing, it is in your best interest to move away the closing as much as you can - and to calculate the distance with the far end - and this is currently remarkably slow
But this looks like perfect, isn't it? Do you mean it's not yet optimised perfectly?
The funny thing is that for this scoring type, a simple brute-force approach would work really well.
Yes, but this would require rewriting everything from scratch for this type of flight :smile: I am still trying to find an elegant way to do this with the current architecture
I added both definitions, but I took a shortcut that doesn't work if you allow for closing with a penalty - as the FAI Rules do not
https://github.com/mmomtchev/igc-xc-score/tree/oar
Now that I have some XCLeague rules I will probably add the rest and then the biggest problems is that this needs lots of testing before release
When I did the FFVL and XContest rules I simply downloaded the IGCs from their websites, then ran my scoring and searched for any suspicious differences
Looks good to me. The only problem I see is how do I specify the way I'd like to score a given flight? I mean I definitely want to score a flight based on or1
for example, even if it'd give higher points as a triangle.
The only workaround I could come up with was to make a separate category for each flight kind under FAI. So instead of "FAI" group, I'd have "FAI_OR1" with only one rule in there. I think a better solution would be an option to specify the rule being used.
This would come down to the same - currently you can group rules and leave the scoring program select the highest scoring rule in each group
I'd like to use this with FAI scoring rules, to evaluate record flights. With FAI rules triangle closing needs to be within 400 meter radius fixed. How can I modify it?
So far I find no solution other than copying cli.js and hard coding a different value in my version of cli.js