[Draft] 349 feat simulated annealing#380
Conversation
- Working commit - Introduces new base classes, and simulated annealing itself - Temporary tester file
- Created a re-usable ObjectiveTerm function which takes in at least an input frame and computes a float from it - Used these reusable objectives and weights in the SimulatedAnnealing class to compute the objective
- Adds a class for generic constraints, which can be computed to check validity based on an input frame and player id - Implemented a specific constraint for simulated annealing that ensures the player is within a TimeToIntercept radius, i.e. the perturbation from simulated annealing is such that the player could get there within X seconds.
- Makes a minor addition of an alpha parameter to visualize.py also
- Move optimization objects into separate classes - Add logging properly instead of print statements - Formatting
Creates a wrapper function around the Algorithm.run() method that can easily be extended to hot swap optimization algorithms
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #380 +/- ##
===========================================
+ Coverage 99.22% 99.28% +0.05%
===========================================
Files 49 67 +18
Lines 3736 5441 +1705
===========================================
+ Hits 3707 5402 +1695
- Misses 29 39 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Previously I was trying to save compute by only passing in what is necessary - It's much cleaner to use if all the constraints and objectives just take in game, frame and some optional extra arguments. - I will revisit this if we want to make the pre-made objectives a bit more flexible
|
Hi @amarshah1999, I really like the implementation, it is clean and structured. I was able to play with it and it worked really nicely. I think this is a great starting point and now we have to make it (1) more customisable and intuitive and (2) production ready. Let me give a few examples of point 1 I think would benefit:
Again, I really like it. It also confirmed what I thought would be the case: not the optimization algorithm but the creation of the right objective function is probably the bottleneck of these use cases, but implementing this will give the community the tools to work on that. I also think that it would be great to be more elaborate on different situations, including/excluding players to change position, etc.. And ideally I would not want the skillcorner but some databally inherintly supported exmaple data (e.g. docs/saved_games/synced_game) to showcase since the integration of skillcorner, kloppy, and databallpy is not really the subject of this project. Let me know what you think and if you want me to help you out anywhere with that! |
- added random state, verbosity, patience - replaced skillcorner data - made it explicit in the docs that you can specify which players to move
Will remove the warnings from the docs later on. Just have it like that because my local setup is overly verbose. |
| if (new_score > best_score) or math.exp( | ||
| (new_score - best_score) / T | ||
| ) > self._rng.random(): |
There was a problem hiding this comment.
I mean this part, when new_score - best_score / T is greater than 709 or smaller than -709 it will result in a overflow warning/error. Just clip it with np.clip((new_score - best_score) / T, -700, 700) or a similar solution.
[Draft] Introduces the simulated annealing project as outlined here #349
ToDo List: