igc-xc-score icon indicating copy to clipboard operation
igc-xc-score copied to clipboard

How to use with FAI scoring rules

Open hyperknot opened this issue 2 years ago • 79 comments

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

hyperknot avatar Jun 17 '22 19:06 hyperknot

You need to edit scoring-rules.config.js and add a scoring rule with a closingDistanceFixed: 0.4

mmomtchev avatar Jun 17 '22 21:06 mmomtchev

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?

geojson io 2022-06-20 16-17-24

Are FFVL and XContest calculating the closing differently? Also, what is the difference between code: fai and tri?

hyperknot avatar Jun 20 '22 14:06 hyperknot

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.

mmomtchev avatar Jun 20 '22 14:06 mmomtchev

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: image

hyperknot avatar Jun 20 '22 14:06 hyperknot

Ok, so in fact all turnpoints and the start/finish points are 400m cylinders?

mmomtchev avatar Jun 20 '22 14:06 mmomtchev

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.

image

hyperknot avatar Jun 20 '22 14:06 hyperknot

In fact this rule can be interpreted as a 800m closing rule? It is a bijection:

  • All points that a separated by 800m or less can be inside a 400m radius cylinder
  • No points separated by more than 800m can be inside a 400m radius cylinder

mmomtchev avatar Jun 20 '22 15:06 mmomtchev

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.

hyperknot avatar Jun 20 '22 15:06 hyperknot

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?

mmomtchev avatar Jun 20 '22 16:06 mmomtchev

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.

image

A very simple algorithm I could imagine is:

  1. Calculate the start/endpoint as it does currently.
  2. In a loop: Move the start/end 1 meter in a random direction, check if still FAI and still within 400 meter of both. If yes and score is bigger than the previous one, move it.

hyperknot avatar Jun 20 '22 19:06 hyperknot

2r is a better closing then the angled r+r - it keeps more of the track

mmomtchev avatar Jun 20 '22 19:06 mmomtchev

It's true but FAI calculates by the triangle sides, which in our case is determined by the center of the circle.

hyperknot avatar Jun 20 '22 20:06 hyperknot

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?

mmomtchev avatar Jun 20 '22 20:06 mmomtchev

The FAI document is really quite low in details, but here is how I understand it:

  • You put 3 circles, such that they are 400 meter radius and they include 1-1-2 points of the track.
  • You select the closest point of each circle to make up the triangle.
  • For the 2 mid-points, this basically makes no sense, you select a point, put a circle and then select the original point again. Instead it makes sense to select the track point itself.
  • For the start/end point, now I believe it'd be point K on this updated sketch:

FAI calc

hyperknot avatar Jun 20 '22 20:06 hyperknot

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.

mmomtchev avatar Jun 20 '22 20:06 mmomtchev

I am positive that these are similar triangles but I do not see any easy proof trtiangle

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.

mmomtchev avatar Jun 20 '22 20:06 mmomtchev

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 2*400 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 :-)

hyperknot avatar Jun 20 '22 20:06 hyperknot

Do you have any examples of scored flights?

mmomtchev avatar Jun 20 '22 21:06 mmomtchev

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.

hyperknot avatar Jun 20 '22 21:06 hyperknot

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.

hyperknot avatar Jun 24 '22 09:06 hyperknot

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?

mmomtchev avatar Jun 24 '22 10:06 mmomtchev

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. tri

hyperknot avatar Jun 24 '22 10:06 hyperknot

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.

mmomtchev avatar Jun 24 '22 13:06 mmomtchev

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.

hyperknot avatar Jun 25 '22 14:06 hyperknot

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

mmomtchev avatar Jun 25 '22 20:06 mmomtchev

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 image 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.

hyperknot avatar Jun 26 '22 18:06 hyperknot

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.

mmomtchev avatar Jun 27 '22 18:06 mmomtchev

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?

hyperknot avatar Jun 28 '22 14:06 hyperknot

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

hyperknot avatar Jun 28 '22 16:06 hyperknot

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.

mmomtchev avatar Jul 09 '22 10:07 mmomtchev

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.

hyperknot avatar Jul 15 '22 23:07 hyperknot

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.

mmomtchev avatar Jul 16 '22 17:07 mmomtchev