flyXC icon indicating copy to clipboard operation
flyXC copied to clipboard

Add score computation

Open flyingtof opened this issue 2 years ago • 7 comments

flyingtof avatar Sep 02 '23 22:09 flyingtof

There are some issues not resolved yet. The solution is working, according to my personal tests. There is still an issue when you compute the score twice on the same track (the distance displayed becomes incorrect), but I think that this was an already existing issue.

flyingtof avatar Oct 10 '23 05:10 flyingtof

There are some issues not resolved yet. The solution is working, according to my personal tests. There is still an issue when you compute the score twice on the same track (the distance displayed becomes incorrect),

Do you mean that it's correct the first time and become wrong the second time?

but I think that this was an already existing issue.

How would the issue be triggered with the current code?

vicb avatar Oct 10 '23 07:10 vicb

There are some issues not resolved yet. The solution is working, according to my personal tests. There is still an issue when you compute the score twice on the same track (the distance displayed becomes incorrect),

Do you mean that it's correct the first time and become wrong the second time?

exactly

but I think that this was an already existing issue.

How would the issue be triggered with the current code?

I meant that I had this issue with my code from the beginning.

After re-reading the code, I think I found the cause : It is a problem of units (meters vs kilometers). In improvedScorer.ts If I replace

function toScore(solution: Solution): Score {
  return new Score({
    distance: solution.scoreInfo?.distance,
...

by

function toScore(solution: Solution): Score {
  return new Score({
    distance: (solution.scoreInfo?.distance || 0) * 1000,
...

The problem is over.

But I can't explain for sure why it was working the first time you compute the score and not the second time. I would suspect that a state somewhere is not cleaned / initialized properly.

flyingtof avatar Oct 10 '23 21:10 flyingtof

There is still sometimes a little difference between score computed the first time and the second time on the same track. It depends on the track you use in your test. If you want to see that, you can use the test files in igc-xc-score lib The difference is visible with this file : trifai-xcontest-189.65.igc.

An improvement could be to use the igc-xc-score solver in the League subclasses. Another way to improve the solution could be to re-design the planner mechanisms.

flyingtof avatar Oct 10 '23 21:10 flyingtof

I think I have replied to your remarks.

  • The only one I did not catch is this one: https://github.com/vicb/flyxc/pull/144#discussion_r1332698903.
  • FYI, I've just added the computation of the mean speed using data computed from track, instead of using the default value (20km/h). I find this more useful for the user.
  • I had some issues when rebasing... this branch is quite old now :-/

flyingtof avatar May 02 '24 22:05 flyingtof

@flyingtof it would be easier to split this work into multiples CLs.

A possible split would be:

First CL:

Create a solver function taking a (flyxc) track and a contest (and options). It would return an object with an optimize method that optimize the track sync.

There should be an enum with all the contests currently supported.

This lib should probably lives in a libs/optimizer folder (use nx create ...) to bootstrap the library.

This lib is only a wrapper around the solver function from igc-xc-score, should be quite thin.

There should be tests:

  • a track with 2 points,
  • 3 points: free flight, triangle, FAI
  • I think we should tests all the rules for the French CFD and XContest
  • We can also test a few real tracks for all of the supported contests.

Second CL

Add a getGenerator({maxCycleTimeMs: number}) to the return object of the solver function.

This function should be called mutliple time to optimize a track (as should the solver function from igc-xc-score)

Update the test to also test this API.

Third CL

Replace the current scorer with this new API - note that it is only used to optimize route, not track.

Fourth CL

Add the ability to score track - as you have implemented in the current CL.

I think you should drive each CL to completion/merge before working on the next one. It will be much easier to review this way. The best way could be to leave this CL as is and start new CLs based on master.

After that we should add the ability to score live tracks too.

What do you think ?

vicb avatar May 05 '24 15:05 vicb

I agree. We can consider this pr as a prototype and rebuild features step by step

flyingtof avatar May 08 '24 08:05 flyingtof